Robobot teensy interface: Difference between revisions

From Rsewiki
Line 61: Line 61:
* Wheel size and other static configuration data
* Wheel size and other static configuration data
* Logfile settings
* Logfile settings
The configuration file is a text file, and a sample (SVN version 885) is:
[service]
use_robot_hardware = true
logpath = log_%d/
; the '%d' will be replaced with date and timestamp (must end with a '/'). =
max_logging_minutes = 1000
log_service = true
[mqtt]
broker = tcp://localhost:1883
context = drive
clientid = dot
function = drive/
system = robobot/
log = true
print = false
use = true
[teensy0]
use = true
type = robobot
idx = 124
; robot 'name' and 'idx' are read-only, use command line option to change =
name = Dot
device = /dev/ttyACM0
log = true
print = false
confirm_timeout = 0.04
encrev = true
hardware = 8
[robot0]
log = true
print = false
regbot_version = 696
shutdown_file = /home/local/shutdown.now
batteryusedwh = 25.893278
batterycalibrate = 1.0
[encoder0]
interval_pos_ms = 0
interval_vel_ms = 15
print = false
encoder_reversed = true
interval_pose_ms = 5
log_enc = true
log_pose = true
[imu1teensy0]
gyro_offset = 0 0 0
log = true
print_gyro = false
print_acc = false
interval_gyro_ms = 0
interval_acc_ms = 0
[imu2teensy0]
use = false
gyro_offset = 0 0 0
log = true
print_gyro = false
print_acc = false
interval_gyro_ms = 0
interval_acc_ms = 0
[servotn0]
interval_ms = 0
log = true
print = true
[motor_teensy_0]
m1kp = 7.0
m1lead = 0 1.0
m1taui = 0.05
m1feedforward = 0
m1maxmotv = 8.0
m1voffset = 0.0
m2kp = 7.0
m2lead = 0 1.0
m2taui = 0.05
m2feedforward = 0
m2maxmotv = 8.0
m2voffset = 0.0
log_voltage = true
m1log_pid = true
m2log_pid = true
m1print = false
m2print = false
interval_motv_ms = 25
interval_motpwm_ms = 0
[velocity0]
enctickperrev = 68
motorscale = 1 1
useteensyvel = true
log = true
print = false
[current_teensy_0]
log = true
print = false
interval_ms = 10
[distforce0]
interval_ird_ms = 30
log_dist = true
log_force = false
print = false
force = false
[gpio]
pins_out = 12=0 16=0
stop_on_stop = true
blink_period_ms = 600
log = true
print = false
use = false
[mixer]
use = true
log = true
print = false
driveleft = 0 0 -1
driveright = 0 1 -1
wheelbase = 0.22
motor_gear = 18
drive_gear = 1
wheel_radius = 0.09
[joy_logitech]
log = true
print = false
device = /dev/input/js0
device_type = Logitech Gamepad F710
[joy_use]
log = true
print = false
drive_control = true
vel_limit = -1.5
vel_axis = 4
turn_limit = 10.0
turn_axis = 3
button_fast = 5
slow_factor = 0.3
axis_servo = 1
servo = 1
servoScale = 10
[ini]
; set 'saveconfig' to 'false' to avoid autosave =
saveconfig = true
version = 859 2025-01-07 08:37:26
[edge0]
log = true
print = false
interval_liv_ms = 0
interval_livn_ms = 10

Revision as of 09:59, 18 January 2025

Back to Robobot_B

Teensy interface

The Teensy_interface app has the functions:

  • Translate between the USB connection and the MQTT protocol.
  • Adds motor velocity control (allow control using linear velocity and rotation velocity)
  • Allow log of almost all relevant data to individual logfiles. Intended for debugging and import into Matlab.
  • Monitors the IP addresses of the Raspberry and sends the result to the small Teensy display.

The app is configured with the file robot.ini

Teensy to MQTT

The teensy_interface app can interface with more than one Teensy, but for Robobot, only one Teensy board is available.

The Teensy data can be converted to an MQTT message directly, which is the default method.

The Teensy data message for raw line-sensor AD values has the format.:

liv 731 928 962 866 888 902 828 613 50

This will, in MQTT, be split into a topic and a message.

topic: robobot/drive/T0/liv 
message: 1736776814.3819 731 928 962 866 888 902 828 613 50

The first part of the topic, robobot/drive/T0, is the same for all messages from the Teensy.

If you want to subscribe to all MQTT messages, the topic request could be robobot/drive/#.

The message is preceded by a timestamp, which is when the message was received from Teensy. The timestamp is seconds from the start of the epoch (1 Jan 1970) that is standard for all PCs

Data extract

The most relevant data is decoded in the interface and, in some cases, slightly reformatted before being sent to MQTT.

The decoded data can further be saved to individual logfiles.

Motor control

Motor control translated drive command, linear velocity (m/s) and rotation speed (rad/s), into motor voltage sent to the Teensy.

The mixer module calculates each wheel's needed velocity to satisfy the drive command.

The motor module uses a closed loop control to implement wheel velocity. The controller is a PID type. The parameters are configured in the robot.ini file. The measured velocity is taken from the velocity data module.

Gamepad control

There is an optional possibility of controlling the robot from a gamepad (Logitech is supported only).

The manual control takes over when the back button on the gamepad is pressed.

Configuration file

All modules are configured by the settings in the robot.ini file. Especially:

  • data subscription from the Teensy for essential data (like wheel velocity)
  • Wheel size and other static configuration data
  • Logfile settings

The configuration file is a text file, and a sample (SVN version 885) is:

[service]
use_robot_hardware = true
logpath = log_%d/
; the '%d' will be replaced with date and timestamp (must end with a '/'). = 
max_logging_minutes = 1000
log_service = true

[mqtt]
broker = tcp://localhost:1883
context = drive
clientid = dot
function = drive/
system = robobot/
log = true
print = false
use = true

[teensy0]
use = true
type = robobot
idx = 124
; robot 'name' and 'idx' are read-only, use command line option to change = 
name = Dot
device = /dev/ttyACM0
log = true
print = false
confirm_timeout = 0.04
encrev = true
hardware = 8

[robot0]
log = true
print = false
regbot_version = 696
shutdown_file = /home/local/shutdown.now
batteryusedwh = 25.893278
batterycalibrate = 1.0

[encoder0]
interval_pos_ms = 0
interval_vel_ms = 15
print = false
encoder_reversed = true
interval_pose_ms = 5
log_enc = true
log_pose = true

[imu1teensy0]
gyro_offset = 0 0 0
log = true
print_gyro = false
print_acc = false
interval_gyro_ms = 0
interval_acc_ms = 0

[imu2teensy0]
use = false
gyro_offset = 0 0 0
log = true
print_gyro = false
print_acc = false
interval_gyro_ms = 0
interval_acc_ms = 0

[servotn0]
interval_ms = 0
log = true
print = true

[motor_teensy_0]
m1kp = 7.0
m1lead = 0 1.0
m1taui = 0.05
m1feedforward = 0
m1maxmotv = 8.0
m1voffset = 0.0
m2kp = 7.0
m2lead = 0 1.0
m2taui = 0.05
m2feedforward = 0
m2maxmotv = 8.0
m2voffset = 0.0
log_voltage = true
m1log_pid = true
m2log_pid = true
m1print = false
m2print = false
interval_motv_ms = 25
interval_motpwm_ms = 0

[velocity0]
enctickperrev = 68
motorscale = 1 1
useteensyvel = true
log = true
print = false

[current_teensy_0]
log = true
print = false
interval_ms = 10

[distforce0]
interval_ird_ms = 30
log_dist = true
log_force = false
print = false
force = false

[gpio]
pins_out = 12=0 16=0
stop_on_stop = true
blink_period_ms = 600
log = true
print = false
use = false

[mixer]
use = true
log = true
print = false
driveleft = 0 0 -1
driveright = 0 1 -1
wheelbase = 0.22
motor_gear = 18
drive_gear = 1
wheel_radius = 0.09

[joy_logitech]
log = true
print = false
device = /dev/input/js0
device_type = Logitech Gamepad F710

[joy_use]
log = true
print = false
drive_control = true
vel_limit = -1.5
vel_axis = 4
turn_limit = 10.0
turn_axis = 3
button_fast = 5
slow_factor = 0.3
axis_servo = 1
servo = 1
servoScale = 10

[ini]
; set 'saveconfig' to 'false' to avoid autosave = 
saveconfig = true
version = 859 2025-01-07 08:37:26

[edge0]
log = true
print = false
interval_liv_ms = 0
interval_livn_ms = 10