Robobot architecture: Difference between revisions

From Rsewiki
 
(76 intermediate revisions by the same user not shown)
Line 1: Line 1:
Back to [[Robobot B]]
Back to [[Robobot_B | Robobot]]


==NASREM==
== Display and LED-band ==


The software architecture is based on the old NASREM architecture, and this is the structure for the description on this page.
=== O-LED display ===


The National Aeronautics and Space Administration (NASA) and the US National Institute of Standards and Technology (NIST) have developed a Standard Reference Model Telerobot Control System Architecture called NASREM. Albus, J. S. (1992), A reference model architecture for intelligent systems design.
[[file:o-led-display-ann.jpg | 500 px]]


[[File:nasrem.png | 700px]]
The primary function of this display is the battery voltage. The AS encoder is not used by Robobot.


Figure 1. The NASREM model divides the control software into a two-dimensional structure. The columns are software function: Sensor data processing, modelling and behaviour control.
=== LED-band ===


== Level 1 ==
[[file:led-band-annotated.jpg | 750px]]


[[File:robobot_level_1.png | 800px]]
The Teensy maintains the LED band. Most LEDs show sensor values. The last 3 LEDs can be set by commands to the Teensy.


Figure 2. The lowest level in the control software. The encoder ticks are received form the hardware (from the Teensy microprocessor) in the sensor interface. The encoder values are then modeled into an odometry pose. The pose is used to control the wheel velocity using a PID controller.
== Hardware block overview ==
The desired wheel velocity for each wheel is generated in the mixer from a desired linear and rotational velocity.


=== Hardware Teensy ===
[[File:robobot-in-blocks-2024.png | 600px]]


The Teensy handles all the sensors connected to the microprocessor and the wheel motors as well as the up to 5 servos.
Figure 1. The main hardware building blocks.


The sensor data is available as subscriptions with a constant sample rate. The sample can be specified in units of 1 ms.
== Software building blocks ==
The USB connection has a bandwidth of about 4000 sensor messages per second.


All subscription requests start with the 'sub' keyword followed by the message key for the data type and the sample time in milliseconds, e.g:
[[File:robobot-function-blocks.png | 600px]]


sub svo 50
Figure 2. The main software building blocks.


that subscribes to the servo status (for all 5 servos) every 50 ms.
The blocks marked with a blue dot are available in the repository as source code.
The Teensy interface will add the CRC and make sure it is received.


==== Mission app====
The mission app block is the robot's top-level controller.


=== Teensy i/f ===
It can subscribe to data streams from the Teensy interface and command the robot to perform actions (like forward and turn velocity).
It attaches to the camera video stream and connects to the IO board (e.g. the start and stop buttons.


This is the Teensy interface controlling the USB interface to the Teensy.
The mission app is in svn/robobot/mqtt_python; its main file is ''mqtt-client.py.''


Commands to the Teensy can be sent in two ways, trusted or best effort.
==== Teensy interface ====
The trusted commands await a confirmation from the Teensy, if this is not received within 30ms, then it is resent - up to 3 times. If still not confirmed, then the message is dropped (most likely the connection is dead or two applications are listening to the same USB device.
The 'best effort' tye is sent once only, this is the fastest communication - like motor voltage in a control loop. If one message is lost, then a similar value will be sent at the next sample time.


Both types are further secured by a simple CRC check.
The Teensy interface connects the Teensy USB interface and the MQTT protocol.


All received messages are sent to the service module for decoding.
The Teensy interface further has closed-loop control for forward velocity and implements turn-rate commands.
All outgoing messages use the send method in this module.


All communication on the interface can be logged.
The interface decodes many essential data types and allows these data streams to be logged.
The logged files are text-based and intended for Matlab for analysis and debugging.
See more details in [[Robobot teensy interface]].


The module is coded in the steensy.h/steensy.cpp files.
==== Mosquitto MQTT server ====


The messages look like this - timestamped by the logging function
This Mosquitto server is an open-source MQTT protocol server - see https://mosquitto.org/.
This server is running as a service.


% teensy communication to/from Teensy
==== Camera streamer====
% 1 Time (sec) from system
% 2 (Tx) Send to Teensy
%  (Rx) Received from Teensy
%  (Qu N) Put in queue to Teensy, now queue size N
% 3 Message string queued, send or received
1687200276.5853 Tx ;75!setid robobot
1687200276.5853 Rx ;04hbt 47.9792 128 1581 4.64 0 7 74.1
1687200276.5866 Rx ;57# got new name (get with 'id')
1687200276.5867 Rx ;65confirm !setid robobot
1687200276.5869 Tx ;80!setidx 2
1687200276.5880 Rx ;70confirm !setidx 2
1687200276.5881 Tx ;47!idi
1687200276.5892 Rx ;37confirm !idi
1687200276.5893 Rx ;57dname robobot Sofia
1687200276.7838 Qu 1 ;01!sub enc 7
1687200276.7839 Qu 2 ;04!sub hbt 500
1687200276.7842 Qu 3 ;34!sub gyro0 12
1687200276.7842 Qu 4 ;78!sub acc0 12
1687200276.7842 Qu 5 ;37!gyrocal 0 0 0
1687200276.7842 Tx ;01!sub enc 7
1687200276.7853 Qu 6 ;81!sub svo 50
1687200276.7853 Rx ;90confirm !sub enc 7


The CRC is coded as two numeric characters that are the sum of all non-control characters in the message. The sum is reduced to two digits by a modulus 99 and 1 is added to avoid '00'. The two numbers are preceded by a semicolon ';'.
The camera streamer is a small Python app that takes data from the camera and streams the video to socket port 7123.
Messages that need a confirmation are queued and an '!' are added after the CRC code. The '!' is included in the CRC calculation.
This means that the stream is also available on Wi-Fi.
See [[Robobot webcam server]] for more details


Messages are coded as a character line, coded in 7-bit ASCII, i.e. no Danish characters.
==== IP-disp ====


All messages are terminated by a 'new line', a '\n'.
IP_disp is a silent app that is started at reboot (by ''on_reboot.bash'') and has two tasks:
* Detect the IP net address of the Raspberry and send it to the small display on the Teensy board (inactive if the Teensy_interface is running.)
* Detect if the "start" button is pressed, and start the mission app.
* Detect if the "start" button is pressed for more than 5 seconds to shut down the robot.


== Level 2 ==
==== Digital IO ====


[[File:robobot_level_2.png | 800px]]
This is the board on top of the Robobot. It provides digital IO and a power supply for external devices.


Figure 3. At level 2 further sensor data is received, modelled and used as optional control sources.
The IO is connected to the Raspberry PI pins GPIO06 (stop), 13 (start), 16, 19, 20, 21, and 26.
See details in [[Robobot circuits]].
 
==== Teensy PCB ====
 
The Teensy board is a baseboard used in the more straightforward 'Regbot' robot.
This board has most of the hardware interfaces and offers all sensor data to be streamed in a publish-subscribe protocol.
All communication is based on clear text lines.
 
The firmware is in ''svn/robobot/teensy_firmware_8'', compiled with ''./compile'' and uploaded to the Teensy by ''./upload''. NB! An upload will cut the battery power, so press the ''power'' switch during upload.
See details in [[Robobot circuits]].
 
== Start buttons (and external power) ==
 
[[file:start-buttons.png | 600px]]
 
The two start buttons are quite different. The Arduino mission start will start the mission code in the Teensy. The mqtt-client reads the Python mission start.
 
Both buttons can shut down the robot when pressed for 5 seconds.
 
The digital-io can only be used for a shutdown if a mission is not running (mqtt-client will reserve all IO).
 
=== External power ===
 
On the digital-io board, there are power pins available for 3V, 5V, and 12V. 12V is the battery voltage, which can vary from 10 to 16V.

Latest revision as of 12:57, 9 February 2025

Back to Robobot

Display and LED-band

O-LED display

The primary function of this display is the battery voltage. The AS encoder is not used by Robobot.

LED-band

The Teensy maintains the LED band. Most LEDs show sensor values. The last 3 LEDs can be set by commands to the Teensy.

Hardware block overview

Figure 1. The main hardware building blocks.

Software building blocks

Figure 2. The main software building blocks.

The blocks marked with a blue dot are available in the repository as source code.

Mission app

The mission app block is the robot's top-level controller.

It can subscribe to data streams from the Teensy interface and command the robot to perform actions (like forward and turn velocity). It attaches to the camera video stream and connects to the IO board (e.g. the start and stop buttons.

The mission app is in svn/robobot/mqtt_python; its main file is mqtt-client.py.

Teensy interface

The Teensy interface connects the Teensy USB interface and the MQTT protocol.

The Teensy interface further has closed-loop control for forward velocity and implements turn-rate commands.

The interface decodes many essential data types and allows these data streams to be logged. The logged files are text-based and intended for Matlab for analysis and debugging. See more details in Robobot teensy interface.

Mosquitto MQTT server

This Mosquitto server is an open-source MQTT protocol server - see https://mosquitto.org/. This server is running as a service.

Camera streamer

The camera streamer is a small Python app that takes data from the camera and streams the video to socket port 7123. This means that the stream is also available on Wi-Fi. See Robobot webcam server for more details

IP-disp

IP_disp is a silent app that is started at reboot (by on_reboot.bash) and has two tasks:

  • Detect the IP net address of the Raspberry and send it to the small display on the Teensy board (inactive if the Teensy_interface is running.)
  • Detect if the "start" button is pressed, and start the mission app.
  • Detect if the "start" button is pressed for more than 5 seconds to shut down the robot.

Digital IO

This is the board on top of the Robobot. It provides digital IO and a power supply for external devices.

The IO is connected to the Raspberry PI pins GPIO06 (stop), 13 (start), 16, 19, 20, 21, and 26. See details in Robobot circuits.

Teensy PCB

The Teensy board is a baseboard used in the more straightforward 'Regbot' robot. This board has most of the hardware interfaces and offers all sensor data to be streamed in a publish-subscribe protocol. All communication is based on clear text lines.

The firmware is in svn/robobot/teensy_firmware_8, compiled with ./compile and uploaded to the Teensy by ./upload. NB! An upload will cut the battery power, so press the power switch during upload. See details in Robobot circuits.

Start buttons (and external power)

The two start buttons are quite different. The Arduino mission start will start the mission code in the Teensy. The mqtt-client reads the Python mission start.

Both buttons can shut down the robot when pressed for 5 seconds.

The digital-io can only be used for a shutdown if a mission is not running (mqtt-client will reserve all IO).

External power

On the digital-io board, there are power pins available for 3V, 5V, and 12V. 12V is the battery voltage, which can vary from 10 to 16V.