Robobot teensy firmware: Difference between revisions
Line 49: | Line 49: | ||
The data is preceded with three characters ';99' when CRC check is used. | The data is preceded with three characters ';99' when CRC check is used. | ||
The ''teensy_interface'' will check and remove these characters, but if talking to the firmware from e.g. Putty | The ''teensy_interface'' will check and remove these characters, but this is annoying if you are talking to the firmware from a console, e.g., Putty. | ||
The CRC insert and check can be removed by sending: | The CRC insert and check can be removed by sending: | ||
Line 58: | Line 58: | ||
This will make the teensy echo all the characters received back to the console and it will also turn off the CRC. | This will make the teensy echo all the characters received back to the console and it will also turn off the CRC. | ||
The Teensy will | The Teensy will reply with a ''>>'' prompt for commands. The feature can be turned off by: | ||
i 0 | |||
=== Configuration === | === Configuration === |
Revision as of 15:36, 23 January 2025
Back to Robobot
Teensy firmware
The board and the primary functional modules.
Each module is a class and instantiated with a global name, as shown below the module name in brackets.
The source code filename is mostly the same as the global name but is preceded by the character 'u'.
All sensor modules extensively use Arduino libraries.
Interface
All communication with Teensy is text-based, including both commands and replies.
A complete list of commands to the Teensy can be found here: Help page Teensy_8
Subscription
Sensor data are available on a subscription basis, e.g. to get gyro data every 50 ms use:
sub gyro 50 ;39gyro 0.122865 0.040497 -0.355164 14948.748 ;27gyro -0.151793 -0.051056 -0.233093 14948.799 ;27gyro -0.060240 -0.295197 -0.172058 14948.848 ;51gyro 0.092348 0.162567 -0.294128 14948.897 ;27gyro -0.121275 -0.020538 -0.385681 14948.948 ;25gyro -0.029723 -0.234161 -0.233093 14948.998
All subscriptions start with sub followed by the keyword for the data and ending with the data interval in ms. The fastest update rate is determined by the update rate of the Teensy, typically 2ms.
The USB interface can handle about 4000 messages per second.
The data is preceded with three characters ';99', a simple validity check to ensure half messages are not used (e.g. if the interface is overloaded). The teensy_interface will check and remove these characters.
The remaining part is the data preceded with a unique keyword (here, "gyro"). The data string is sometimes extended with additional (debug) data; here, the fourth value is a timestamp (Teensy time).
All subscribable data can be requested once by adding an 'i' at the end of the keyword; like:
gyroi ;69gyro 0.000795 -0.081573 -0.172058 15693.118
CRC check
The data is preceded with three characters ';99' when CRC check is used. The teensy_interface will check and remove these characters, but this is annoying if you are talking to the firmware from a console, e.g., Putty.
The CRC insert and check can be removed by sending:
i 1 >>
This will make the teensy echo all the characters received back to the console and it will also turn off the CRC.
The Teensy will reply with a >> prompt for commands. The feature can be turned off by:
i 0
Configuration
Commands to the teensy are like:
motv 3 3
setting the motor voltage to 3V for both motors.
leds 16 100 100 0
sets LED number 16 to yellowish, red=100 (out of 255), green=100, blue=0
Configuration should be preceded wit the same three-character check as outgoing messages, but the Teensy will accept commands without - with a complaint:
leds 16 100 100 0 ;67# processing under protest - no CRC 'leds 16 100 100 0' ;87# set LED 16 to 100 100 0
Information and debug
Information and debug messages are always preceded by a '#' character, as shown above.
Log data
NB! this feature does not work and will make the Teensy reboot.
There is a log-to-RAM feature
lognow 100
The lognow 100 will start logging (until the buffer is full). There is allocated something like 300 kBytes.
The logged data can be retrieved by
log ;89# processing under protest - no CRC 'log' ;82% 1 time 253.8890 sec, from Newton (119) ;01;88% 2 3 Motor velocity ref left, right: 0.0000 0.0000 ;34% 4 5 Motor voltage [V] left, right: 0.00 0.00 ;62% 6 7 Wheel velocity [m/s] left, right: -0.0000 0.0000 ;93% 8 9 10 11 Pose x,y,h,tilt [m,m,rad,rad]: 0 0 0 -2.85363 ;37% 12 Battery voltage [V] ;56253.8890 0.0000 0.0000 0.00 0.00 -0.0000 0.0000 0.0000 0.0000 0.000000 -2.853631 12.04
The first part, starting with '%', explains the data; the following lines will start with a number [0-9] character and be numeric only.
This format is intended for Matlab, as Matlab will ignore lines starting with a '%'. The rest can be loaded with the Matlab load command:
dd = load('filename.txt');