feat(arch): CAN/UART bridge update for SAUL-TEE ESP32 architecture #714

Merged
sl-jetson merged 2 commits from sl-controls/esp32-can-bridge-update into main 2026-04-04 09:00:10 -04:00
Collaborator

Summary

  • ****: Rewritten for SAUL-TEE CAN protocol per
    • 0x300 DRIVE combined frame (speed+steer+mode, i16 units)
    • 0x301 ARM, 0x302 PID (half-float f16), 0x303 ESTOP (magic 0xE5)
    • 0x400 ATTITUDE (pitch/speed/yaw_rate f16), 0x401 BATTERY (vbat_mv + rssi)
    • VESC STATUS1/4/5 decode helpers; node IDs 56 (left) / 68 (right)
  • ****: Updated for new protocol — /cmd_vel→DRIVE, /estop→ESTOP, /saltybot/arm→ARM; publishes /saltybot/attitude + /can/battery
  • ****: Rewritten as ESP32-IO auxiliary bridge — RC channels + sensor data RX, LED/output TX via inter-board protocol (460800 baud)
  • **** / ****: Updated defaults (esp32-io, 460800 baud)
  • Includes (hal reference doc) + updates from cfd5a15

Test plan

  • Verify struct.pack(">") f16 half-float works correctly for pitch/speed/yaw_rate decoding
  • Confirm VESC STATUS1 CAN ID calculation: (9<<8)|56 = 0x938, (9<<8)|68 = 0x944
  • Test stm32_cmd_node serial parsing with mock ESP32 IO frames at 460800 baud
  • Run can_bridge_node with slcan0 in loopback mode to verify DRIVE frame encoding

🤖 Generated with Claude Code

## Summary - ****: Rewritten for SAUL-TEE CAN protocol per - 0x300 DRIVE combined frame (speed+steer+mode, i16 units) - 0x301 ARM, 0x302 PID (half-float f16), 0x303 ESTOP (magic 0xE5) - 0x400 ATTITUDE (pitch/speed/yaw_rate f16), 0x401 BATTERY (vbat_mv + rssi) - VESC STATUS1/4/5 decode helpers; node IDs 56 (left) / 68 (right) - ****: Updated for new protocol — /cmd_vel→DRIVE, /estop→ESTOP, /saltybot/arm→ARM; publishes /saltybot/attitude + /can/battery - ****: Rewritten as ESP32-IO auxiliary bridge — RC channels + sensor data RX, LED/output TX via inter-board protocol (460800 baud) - **** / ****: Updated defaults (esp32-io, 460800 baud) - Includes (hal reference doc) + updates from cfd5a15 ## Test plan - [ ] Verify struct.pack(">") f16 half-float works correctly for pitch/speed/yaw_rate decoding - [ ] Confirm VESC STATUS1 CAN ID calculation: (9<<8)|56 = 0x938, (9<<8)|68 = 0x944 - [ ] Test stm32_cmd_node serial parsing with mock ESP32 IO frames at 460800 baud - [ ] Run can_bridge_node with slcan0 in loopback mode to verify DRIVE frame encoding 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sl-controls added 2 commits 2026-04-04 08:32:24 -04:00
Spec source: docs/SAUL-TEE-SYSTEM-REFERENCE.md (hal, 2026-04-04)

stm32_protocol.py — rewritten for inter-board UART protocol (ESP32 BALANCE ↔ IO):
- Frame: [0xAA][LEN][TYPE][PAYLOAD][CRC8] @ 460800 baud (was STX/ETX/CRC16)
- CRC-8 poly 0x07 over LEN+TYPE+PAYLOAD
- New message types: RC_CHANNELS(0x01), SENSORS(0x02), LED_CMD(0x10),
  OUTPUT_CMD(0x11), MOTOR_CMD(0x12), HEARTBEAT(0x20)

mamba_protocol.py — updated CAN IDs and frame formats:
- Orin→BALANCE: DRIVE(0x300) f32×2 LE, MODE(0x301), ESTOP(0x302), LED(0x303)
- BALANCE→Orin: FC_STATUS(0x400) pitch/vbat/state, FC_VESC(0x401) rpm/current
- VESC node IDs: Left=56, Right=68 (authoritative per §8)
- VESC extended frames: STATUS1(cmd=9), STATUS4(cmd=16), STATUS5(cmd=27)
- Replaced old MAMBA_CMD_*/MAMBA_TELEM_* constants

can_bridge_node.py — updated to use new IDs:
- ORIN_CMD_DRIVE/MODE/ESTOP replace MAMBA_CMD_VELOCITY/MODE/ESTOP
- FC_STATUS handler: publishes pitch→/can/imu, vbat_mv→/can/battery
- FC_VESC handler: publishes rpm/cur→/can/vesc/left|right/state
- VESC STATUS1 extended frames decoded per node ID (56/68)
- Removed PID CAN command (not in new spec)

CLAUDE.md — updated with ESP32-S3 BALANCE/IO hardware summary + key protocols

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update CAN and serial bridge code to match authoritative protocol spec
from docs/SAUL-TEE-SYSTEM-REFERENCE.md §5-6 (hal, 2026-04-04).

mamba_protocol.py (CAN, Orin ↔ ESP32 BALANCE):
- 0x300 DRIVE: [speed:i16][steer:i16][mode:u8][flags:u8][_:u16] — combined frame
- 0x301 ARM:   [arm:u8]
- 0x302 PID:   [kp:f16][ki:f16][kd:f16][_:u16]  — half-float gains
- 0x303 ESTOP: [0xE5] — magic byte cut
- 0x400 ATTITUDE: [pitch:f16][speed:f16][yaw_rate:f16][state:u8][flags:u8]
- 0x401 BATTERY:  [vbat_mv:u16][fault_code:u8][rssi:i8]
- Add VESC STATUS1/4/5 decode helpers; VESC IDs 56 (left) / 68 (right)

can_bridge_node.py:
- /cmd_vel → encode_drive_cmd (speed/steer int16, MODE_DRIVE)
- /estop → encode_estop_cmd (magic 0xE5); clear → DISARM
- /saltybot/arm → encode_arm_cmd (new subscription)
- Watchdog sends DRIVE(0,0,MODE_IDLE) when /cmd_vel silent
- ATTITUDE (0x400) → /saltybot/attitude + /saltybot/balance_state JSON
- BATTERY  (0x401) → /can/battery BatteryState
- VESC STATUS1 frames → /can/vesc/left|right/state

stm32_cmd_node.py — rewritten for inter-board protocol API:
- Imports from updated stm32_protocol (BAUD_RATE=460800, new frame types)
- RX: RcChannels → /saltybot/rc_channels, SensorData → /saltybot/sensors
- TX: encode_led_cmd, encode_output_cmd from /saltybot/leds + /saltybot/outputs
- HEARTBEAT (0x20) timer replaces old SPEED_STEER/ARM logic

stm32_cmd_params.yaml: serial_port=/dev/esp32-io, baud=460800
stm32_cmd.launch.py: updated defaults and description

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson added 1 commit 2026-04-04 08:41:34 -04:00
Per MANDATORY CLEANUP: no file names may reference Mamba or STM32.

Renames:
  mamba_protocol.py    → balance_protocol.py   (saltybot_can_bridge)
  stm32_protocol.py    → esp32_protocol.py      (saltybot_bridge)
  stm32_cmd_node.py    → esp32_io_bridge_node.py (saltybot_bridge)

Updated:
  can_bridge_node.py     — import from balance_protocol
  saltybot_bridge/setup.py — entry point: esp32_io_bridge_node
  saltybot_can_bridge/__init__.py + setup.py — remove "Mamba" from descriptions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson force-pushed sl-controls/esp32-can-bridge-update from 34162784ab to fda6ab99ff 2026-04-04 09:00:08 -04:00 Compare
sl-jetson merged commit fe84ff6039 into main 2026-04-04 09:00:10 -04:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#714
No description provided.