Communication bus between Raspberry Pi 5 and Raspberry Pi Pico 2¶
This bus has several constraints:
- It must use as little of the Pico 2's processing time as possible.
- It should keep the system wiring simple.
- It must use pins that are available on the Pico 2.
UART is a suitable solution: it is supported by both boards and can operate asynchronously, allowing the Pico 2 to perform other work between received bytes. A full-duplex UART connection requires at least three conductors: TX, RX, and a common ground. Two signal wires are sufficient only when both boards already share a ground through another connection, such as their power supply.
Two types of data are sent from the Pi to the Pico: punctual commands and frames.
Current UART frames¶
Raspberry Pi 5 to Raspberry Pi Pico 2¶
Cadence: 30-50 Hz
| Position | Variable | Wire type | Firmware type | Unit | Range | Description |
|---|---|---|---|---|---|---|
| 0 | sequence |
Incrementing frame counter. | ||||
| 1 | head_angle_1 |
Head angle 1. | ||||
| 2 | head_angle_2 |
Head angle 2. | ||||
| 3 | head_angle_3 |
Head angle 3. | ||||
| 4 | v_target |
normalized | [-1, 1] |
Target speed: -1 backward, 1 forward. |
||
| 5 | yaw_rate_target |
normalized | [-1, 1] |
Rotation around the center of gravity: -1 left, 1 right. |
||
| 6 | height_cmd |
normalized | [0, 1] |
Torso height: 0 low, 1 high. |
||
| 7 | roll_cmd |
normalized | [-1, 1] |
Torso roll: -1 left side down, 1 right side down. |
||
| 8 | armed |
Authorizes motor actuation. | ||||
| 9 | balance_enabled |
Requests balance control mode. | ||||
| 10 | tilt_setpoint_deg |
degrees | Target balance angle. | |||
| 11 | emergency_stop |
Immediately requests a safe stop. | ||||
| 12 | choreography_id |
Identifier of a prerecorded movement sequence; 0 means no choreography. |
Raspberry Pi Pico 2 to Raspberry Pi 5¶
Cadence: 10 Hz
| Position | Variable | Wire type | Firmware type | Unit | Range | Description |
|---|---|---|---|---|---|---|
| 0 | sequence |
Incrementing telemetry-frame counter. | ||||
| 1 | torso_inclination_x |
Torso inclination on the X axis. | ||||
| 2 | torso_inclination_y |
Torso inclination on the Y axis. | ||||
| 3 | torso_inclination_z |
Torso inclination on the Z axis. | ||||
| 4 | forward_speed |
Measured forward/backward speed. | ||||
| 5 | lateral_speed |
Measured left/right speed. | ||||
| 6 | height |
Measured height. | ||||
| 7 | robot_state |
Current robot state, such as off, booting, ready, standing up, standing, sitting down, sitting, or fault. | ||||
| 8 | status_flags |
Controller and hardware status flags. | ||||
| 9 | left_wheel_speed |
Measured left wheel speed. | ||||
| 10 | right_wheel_speed |
Measured right wheel speed. |
Frame behavior¶
sequence increments for every frame and wraps to zero after reaching its maximum value. The receiver can use it to detect duplicate or missing frames.
emergency_stop is latched: setting it back to 0 does not re-arm the robot. Re-arming requires an explicit safe sequence after the emergency-stop condition has been cleared.
choreography_id starts a choreography only when its value changes from 0 to a non-zero value. Keeping the same value in subsequent frames must not restart the choreography.
Current UART Commands¶
Every frame must end with \n.
USB - Serial¶
Via the 'commander'
| Command | Target variable / object | Description |
|---|---|---|
R<FOC_command> |
motor_right |
Sends a SimpleFOC command to the right drive motor. |
L<FOC_command> |
motor_left |
Sends a SimpleFOC command to the left drive motor. |
S<angle> |
tilt_setpoint |
Sets the target balance angle in degrees. |
B<value> |
motor_balance |
Scales the right motor voltage to compensate motor mismatch. |
Y<value> |
yaw_trim |
Adds a constant steering correction to both motor commands. |
P<value> |
Kp_tilt |
Sets the proportional gain of the tilt PID controller. |
I<value> |
Ki_tilt |
Sets the integral gain of the tilt PID controller. |
D<value> |
Kd_tilt |
Sets the derivative gain of the tilt PID controller. |
V<value> |
Kv_outer |
Sets the position-hold gain of the outer velocity loop. |
A<value> |
Kvel_p |
Sets the velocity damping gain of the outer loop. |
W<value> |
Kyaw_p |
Sets the proportional gain for unwanted rotation damping. |
Z<value> |
Kyaw_i |
Sets the integral gain for heading hold. |
X |
log_buffer |
Prints the captured balance-run log as CSV data. |
? |
Commander command list | Prints all commands registered in this Commander instance. |
@<mode> |
verbose |
Selects the Commander response verbosity mode. |
#<n> |
decimal_places |
Selects the number of digits printed after the decimal point. |
Raspberry Pi - Serial1 (commander_ctrl)¶
| Command | Target variable / object | Description |
|---|---|---|
F<value> |
v_target |
Sets normalized forward speed from -1 to 1. |
T<value> |
yaw_rate_target |
Sets normalized turn rate from -1 to 1. |
H<value> |
height_cmd |
Sets the leg height command from 0 to 1. |
S<angle> |
tilt_setpoint |
Sets the target balance angle in degrees. |
P<value> |
Kp_tilt |
Sets the proportional gain of the tilt PID controller. |
I<value> |
Ki_tilt |
Sets the integral gain of the tilt PID controller. |
D<value> |
Kd_tilt |
Sets the derivative gain of the tilt PID controller. |
? |
Commander command list | Prints all commands registered in this Commander instance. |
@<mode> |
verbose |
Selects the Commander response verbosity mode. |
#<n> |
decimal_places |
Selects the number of digits printed after the decimal point. |