30 Commits

Author SHA1 Message Date
seb
fb3c8c863a Merge pull request 'feat: motor driver layer — differential drive, steer ramp, estop' (#19) from sl-controls/motor-driver into main 2026-02-28 17:19:42 -05:00
seb
a89297f1d4 Merge pull request 'feat(bd-a2j): Sensor driver integration — RealSense D435i + RPLIDAR A1M8' (#17) from sl-perception/bd-a2j-sensor-drivers into main 2026-02-28 17:19:41 -05:00
seb
f2d2df030e Merge pull request 'feat: STM32 serial bridge — USB CDC to ROS2 topics' (#16) from sl-jetson/stm32-serial-bridge into main 2026-02-28 17:19:25 -05:00
80a41e5008 feat: motor driver layer — differential drive, steer ramp, estop
Adds motor_driver.c/h between the balance PID and the raw
hoverboard UART driver:

- Differential drive: balance_cmd → speed, steer_cmd → steer
- Steer-only ramping at MOTOR_STEER_RAMP_RATE (balance PID keeps
  full immediate authority — no ramp on speed channel)
- Headroom clamp: reduces steer so |speed|+|steer|<=MOTOR_CMD_MAX
  ensuring ESC never clips the balance command
- Emergency stop: latches on TILT_FAULT, clears on BALANCE_DISARMED;
  send path stays in 50Hz ESC tick to avoid flooding UART

main.c: replace bare hoverboard_send() with motor_driver_update();
config.h: MOTOR_CMD_MAX=1000, MOTOR_STEER_RAMP_RATE=20 counts/ms

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 17:15:40 -05:00
76067d6d89 feat(bd-a2j): RealSense D435i + RPLIDAR A1M8 ROS2 driver integration
Adds saltybot_bringup ROS2 package with four launch files:
  - realsense.launch.py  — D435i at 640x480x15fps, IMU unified topic
  - rplidar.launch.py    — RPLIDAR A1M8 via /dev/rplidar udev symlink
  - sensors.launch.py    — both sensors + static TF (base_link→laser/camera)
  - slam.launch.py       — sensors + slam_toolbox online_async (compose entry point)

Sensor config YAMLs (mounted at /config/ in container):
  - realsense_d435i.yaml  — Nano power-budget settings (15fps, no pointcloud)
  - rplidar_a1m8.yaml     — Standard scan mode, 115200 baud, laser frame
  - slam_toolbox_params.yaml — Nano-tuned (2Hz processing, 5cm resolution)

Fixes docker-compose volume mount: ./ros2_ws/src:/ros2_ws/src
(was ./ros2_ws:/ros2_ws/src — would have double-nested the src directory)

Topic reference and verification commands in SENSORS.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 17:14:21 -05:00
7c4e46aaa1 feat: STM32-to-Jetson ROS2 serial bridge node
saltybot_bridge ROS2 Python package (ament_python):
- serial_bridge_node.py: reads USB CDC JSON telemetry from STM32F722 at 50Hz
  Parses exact firmware format: {"p","r","e","ig","m","s","y"} (all ×10 ints)
  State enum: 0=DISARMED, 1=ARMED, 2=TILT_FAULT (matched to balance_state_t)
- Publishes sensor_msgs/Imu on /saltybot/imu (pitch/roll/yaw as angular_velocity)
- Publishes std_msgs/String on /saltybot/balance_state (full PID JSON diagnostics)
- Publishes diagnostic_msgs/DiagnosticArray on /diagnostics (OK/WARN/ERROR by state)
- Auto-reconnects on serial disconnect; IMU fault frames → ERROR diagnostic
- launch/bridge.launch.py with serial_port + baud_rate launch args
- config/bridge_params.yaml (921600 baud, /dev/ttyACM0)
- test/test_parse.py: 8 unit tests covering normal, fault, edge cases (all pass)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 17:11:02 -05:00
seb
b9c8bc1a36 Merge pull request 'fix: Roll axis + yaw telemetry (issues #12, #13)' (#14) from sl-firmware/fix-orientation-telemetry into main 2026-02-28 16:56:09 -05:00
seb
544a52686e Merge pull request 'feat: Prototype base plate — real hub motor axle measurements' (#11) from sl-mechanical/prototype-baseplate into main 2026-02-28 15:17:47 -05:00
6513b04e4e fix: correct roll axis mapping + add yaw telemetry (issues #12, #13)
Issue #12 — Roll displayed as pitch:
- Firmware was sending r=pitch_rate (wrong). Changed to r=roll_deg*10.
- mpu6000.c: add roll complementary filter (accel atan2(ay,az) +
  gyro gy integration, same COMP_ALPHA=0.98 as pitch).
- IMUData: add roll and yaw fields.
- UI: updateIMU() now uses data.r/10 for roll (not client-side filter
  that computed from ax/ay/az which firmware never sent).
- Three.js: roll -> rotation.z (banking), pitch -> rotation.x (tipping)
  — axes were already correct, fix was the firmware data.

Issue #13 — Add yaw telemetry:
- Firmware: gyro Z integration (gz * dt) → s_yaw, sent as y=yaw_deg*10.
  Gyro-only, drifts — no magnetometer.
- IMUData: yaw field added.
- UI: yaw -> rotation.y (spinning on vertical axis). Displayed in HUD.
- UI: YAW RESET button captures current yaw as new zero reference
  (client-side offset, no new firmware command needed).

Closes #12, #13.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 15:07:04 -05:00
914afbc1ca feat: vertical stem architecture — compact baseplate + battery carousel
ARCHITECTURE CHANGE: batteries no longer sit flat on the base plate.
They mount VERTICALLY on a central mast via a height-adjustable carousel.
CG is tuned by sliding the carousel up/down the stem.

Part A — prototype_baseplate.scad (Rev C):
- PLATE_DEPTH: 210mm → 130mm (no battery footprint constraint)
- Removed all battery tray geometry (holes, strap slots, expansion mounts)
- Added central stem socket: Ø38.6mm bore + 4x M5 flange bolt holes on Ø66mm BC
- Added stem_flange() module: laser-cut ring (qty 2, one each side of plate)
- Wiring pass-through slots flanking stem centre
- FC mount relocated to FC_X_OFFSET = -40mm (front of plate, clear of stem)
- New RENDER="stem_flange_2d" DXF export option

Part B — stem_battery_clamp.scad (new):
- Collar: two 3D-printed D-shaped halves, split at Y=0
  - Ø38.6mm bore (1.5" EMT / 6061-T6 tube)
  - 4x M6 clamping bolts + hex nut pockets
  - 1x M6 set screw per half for height/rotation lock
  - Arm attachment pads with M4 through-holes + nut pockets
- Arms: flat bars, laser-cut or printed, ARM_REACH=55mm
- Battery cradles: U-channel, open top, Velcro strap slots at 30% + 65% height
- BATT_COUNT param: 2 (180°), 3 (120°), or 4 (90°) radial batteries
- ARM_START_ANGLE chosen per BATT_COUNT to keep all arms clear of Y=0 split
- Battery ghosts in assembly for visualisation
- Full RENDER control: assembly / collar_half / arm / arm_2d / cradle
- Assembly sequence + CG tuning notes in file footer

BOM.md → Rev C:
- Part A table updated (5 laser-cut parts + stem tube)
- Part B table added (collar halves, arms, cradles, fasteners)
- Battery section: flat-deck layout replaced with vertical stem guide
- Fastener table updated to match new architecture

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 14:57:30 -05:00
seb
257d6ccf26 Merge pull request 'fix(usb): MPU non-cacheable region + IWDG ordering fix (bd-3ulu)' (#10) from sl-firmware/bd-3ulu-usb-dcache-fix into main 2026-02-28 14:54:42 -05:00
5bb5c7f863 fix: update baseplate with real battery dimensions (420x88x56mm)
Replaces placeholder 185x72x52mm battery spec with caliper-verified
pack dimensions. 2 packs side-by-side is the default config.

Geometry impact:
- PLATE_DEPTH reduced to 210mm (2x88mm + 17mm margin each side)
- Battery zone: 420x176mm centred between motor forks (fits 600mm wheelbase)
- Mount holes repositioned: 4 per pack x 2 packs = 8 M4 holes
  at (±(BATT_L/2 - 18), ±BATT_W/2)
- Velcro strap slots: 25mm wide, pierce full plate depth at x=±BATT_L/4
- 4-pack expansion: optional M5 shelf bolt holes when BATT_PACKS=4
  (only viable 4-pack layout is 2+2 underdeck — analysed in BOM)
- Battery ghost in assembly preview shows 2-pack deck layout

4-pack analysis (added to BOM):
  in-line 840mm > wheelbase, side-by-side 352mm > plate depth
  → 2+2 underdeck shelf is the only viable 4-pack configuration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 14:46:50 -05:00
22d7b546f3 feat: prototype base plate with real hub motor measurements
Adds prototype_baseplate.scad — a laser-cuttable / CNC-routable flat
base plate for the self-balancing robot using caliper-verified axle
dimensions from the wiki (replaces placeholder values in PR #7):

  Axle base dia:     16.11 mm (was 14 mm)
  D-cut OD:          15.95 mm (new)
  D-cut flat chord:  13.00 mm (new)
  Total protrusion:  65.50 mm
  Bearing seat OD:   37.80 mm
  Tire OD:          254 mm (10x2.125")
  Axle CL height:   127 mm (was wrong 310 mm)

Design:
- Single flat plate (6 mm Al / 8 mm acrylic), 680x220 mm blank
- Open fork slots (16.51 mm, semicircular tip) at each axle end
- Bearing seat relief cutout prevents Ø37.8 mm collar binding on edge
- Two-piece dropout clamp: lower (round bore) + upper (D-cut bore)
- D-cut profile computed from chord geometry with 0.3 mm all-round clearance
- MAMBA F722S FC holes (30.5x30.5 mm M3), battery mount holes (M4)
- Lightening slots, corner radii via minkowski
- RENDER param switches between 3-D assembly and 2-D DXF projections
  for each of the three laser-cut parts

Updates BOM.md to Rev B: measurement delta table, prototype BOM section,
updated motor entry with verified axle spec.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 14:43:26 -05:00
81d76e4770 fix(usb): MPU non-cacheable region + IWDG ordering fix (bd-3ulu)
Root cause 1 (IWDG reset loop): safety_init() was called before
mpu6000_init() — IWDG 50ms timeout fires during ~510ms IMU init,
causing infinite MCU reset. Moved safety_init() to after all
peripheral inits (IMU, hoverboard, balance).

Root cause 2 (DCache coherency): USB TX/RX buffers merged into a
single 512B-aligned struct in usbd_cdc_if.c. MPU Region 0 configured
non-cacheable (TEX=1, C=0, B=0) in usbd_conf.c USBD_LL_Init() before
HAL_PCD_Init(). DCache stays ON globally — MPU handles coherency.
Removed SCB_DisableDCache() from main.c (caused boot crash).

Also: fix safety.c IWDG_RELOAD macro (float literals not valid in
#if); add crsf.c stub so crsf_state links (UART not yet wired).

Fixes issue #9.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 13:51:02 -05:00
909763494f Merge pull request 'feat(safety): IWDG watchdog, arm hold interlock, tilt alert (bd-3qh)' (#4) from sl-controls/bd-3qh-safety-systems into main 2026-02-28 13:12:18 -05:00
c719cf5467 Merge pull request 'feat(pid): runtime PID tuning via USB + telemetry (bd-18i)' (#3) from sl-controls/bd-18i-pid-tuning into main 2026-02-28 13:12:13 -05:00
098475a606 Merge pull request 'feat(imu): MPU6000 sensor fusion — complementary filter (bd-2dv)' (#2) from sl-controls/bd-2dv-imu-fusion into main 2026-02-28 13:12:09 -05:00
4dd52b47dc feat(safety): IWDG watchdog, arm hold interlock, tilt alert (bd-3qh)
Safety systems implementation:

IWDG Hardware Watchdog (50ms timeout, config.h WATCHDOG_TIMEOUT_MS):
- safety_init() configures IWDG at PSC/32 (0.8ms tick), reload=62
- safety_refresh() must be called every loop iteration
- Cannot be disabled once started — MCU resets if loop hangs
- Started after 3s USB init delay (avoids spurious startup reset)

Arm Hold Interlock (3s, config.h ARMING_HOLD_MS):
- Arm command starts a hold timer, not immediate motor enable
- Motors only enable after ARMING_HOLD_MS consecutive hold
- Disarm or tilt > 10° cancels pending arm
- Prevents accidental arm from single keypress

Tilt Fault Alert:
- safety_alert_tilt_fault() fires one-shot buzzer on TILT_FAULT edge
- Rider hears alarm when tilt cutoff triggers
- Edge-detected (buzzer only fires once per fault event)

RC Timeout (infrastructure):
- safety_rc_alive() checks crsf_state.last_rx_ms vs RC_TIMEOUT_MS
- RC disarm wired but guarded (no CRSF yet) — remove guard when wired
- Compatible with future CRSF implementation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 13:11:43 -05:00
34fdb5d11b feat(pid): runtime PID tuning via USB + improved telemetry (bd-18i)
Add USB command interface for live PID gain adjustment without reflashing:
  P<kp>  I<ki>  D<kd>  T<setpoint_deg>  M<max_speed>  ?

Command parsing runs in main loop (sscanf-safe), not in USB IRQ.
USB IRQ copies command to shared volatile buffer (cdc_cmd_buf), sets flag.
Acknowledgement echoes current gains: {"kp":...,"ki":...,"kd":...}

Bounds checking: kp 0-500, ki/kd 0-50, setpoint ±20°, max_speed 0-1000.
Gains validated before write — silently ignored if out of range.

Telemetry updated from raw counts to physical tuning signals:
  pitch (°x10), pitch_rate (°/s x10), error (°x10),
  integral (x10 for windup monitoring), motor_cmd, state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 13:10:32 -05:00
398cbb9a55 feat(imu): MPU6000 sensor fusion with complementary filter
Add src/mpu6000.c implementing a complementary filter (α=0.98) on top of
the existing icm42688 SPI driver. Fixes wrong scale factors in balance.c
(was ±250°/s / ±2g; hardware is configured ±2000°/s / ±16g). Fusion now
lives in the IMU driver layer; balance_update() consumes IMUData directly.

- mpu6000_init(): calls icm42688_init(), seeds filter state
- mpu6000_read(): reads raw SPI, applies complementary filter, returns
  fused pitch (degrees) + pitch_rate (°/s) + accel_x/z (g)
- balance.c: removes duplicated fusion code, uses IMUData.pitch
- main.c: switches to mpu6000_init()/mpu6000_read(), updates telemetry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 13:09:18 -05:00
29a3030abb Merge pull request 'feat: Jetson Nano platform setup (bd-1hcg)' (#8) from sl-jetson/bd-1hcg-jetson-platform into main 2026-02-28 13:06:48 -05:00
ec54a9cb8f Merge pull request 'feat: Parametric chassis frame design (bd-1iy5)' (#7) from sl-mechanical/bd-1iy5-chassis-frame into main 2026-02-28 13:06:23 -05:00
6b92d7089e Merge pull request 'bd-wax: SLAM setup technical plan — Jetson Nano + RealSense D435i + RPLIDAR' (#1) from sl-perception/bd-wax-slam-setup into main 2026-02-28 13:06:19 -05:00
seb
bfb94fc169 Merge pull request 'fix(usb): resolve USB CDC TX failure — DCache coherency + buffer + IMU API (bd-1lo)' (#6) from sl-firmware/bd-1lo-usb-cdc-fix into main 2026-02-28 12:52:43 -05:00
c47ac41573 feat: Jetson Nano platform setup and Docker env (bd-1hcg)
- Dockerfile: L4T R32.6.1 (JetPack 4.6) base + ROS2 Humble + SLAM stack
  (slam_toolbox, Nav2, rplidar_ros, realsense2_camera, robot_localization)
- docker-compose.yml: multi-service stack (ROS2, RPLIDAR A1M8, D435i, STM32 bridge)
  with device passthrough, host networking for DDS, persistent map volume
- docs/pinout.md: full GPIO/I2C/UART pinout for STM32F722 bridge (USB CDC +
  UART fallback), RealSense D435i (USB3), RPLIDAR A1M8, udev rules
- docs/power-budget.md: 10W envelope analysis with per-component breakdown,
  mitigation strategies (RPLIDAR gating, D435i 640p, nvpmodel modes)
- scripts/setup-jetson.sh: host one-shot setup (Docker, nvidia-container-runtime,
  udev rules, MAXN power mode, swap)
- scripts/build-and-run.sh: build/up/down/shell/slam/status helper

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 12:46:14 -05:00
cd9299ded8 feat: parametric chassis frame design (bd-1iy5)
OpenSCAD parametric model for SaltyBot two-wheeled self-balancing robot chassis:
- 600mm wheelbase, 170mm hoverboard hub motor fork dropouts
- MAMBA F722S FC mount (30.5x30.5mm M3 pattern, 6mm nylon standoffs)
- Battery tray for 24V 4Ah pack (185x72x52mm) with strap slots + vent holes
- Jetson Nano B01 mount plate (58x58mm M3 pattern, 8mm standoffs)
- Front/rear bumper brackets with 22mm EMT conduit saddle clamps
- Longitudinal ribs, lightening holes, cable routing slots
- BOM (32 line items) and step-by-step assembly notes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 12:45:40 -05:00
0bfd617c44 fix(usb): resolve USB CDC TX failure caused by three independent bugs
Bug 1 (PRIMARY — DCache/USB coherency):
SCB_DisableDCache() was buried inside icm42688_init(), called ~3.5s
after USB starts. STM32F7 DCache/USB coherency issue: when DCache is
on (enabled by SystemInit()), CPU writes to TX buffers stay in cache
and the USB hardware reads stale SRAM data. Moved SCB_DisableDCache()
to main() before HAL_Init(), ensuring coherency for all USB transfers.

Bug 2 (USB TX corruption):
CDC_Transmit() passed the caller's stack-allocated buf pointer directly
to the USB stack. The USB TXFE interrupt fires asynchronously; by then
the stack buffer may have been modified by the next loop iteration.
CDC_Transmit() now copies into the static UserTxBuffer before handing
off to the USB hardware, ensuring the buffer is stable for the transfer.

Bug 3 (IMU type mismatch → wrong data to balance):
main.c called icm42688_init()/icm42688_read() directly, passing
icm42688_data_t* (raw int16 ax/ay/az/gx/gy/gz) to balance_update()
which expects IMUData* (float pitch/pitch_rate from complementary
filter). Type mismatch produced garbage balance values. Fixed by using
mpu6000_init()/mpu6000_read() which wraps icm42688 + sensor fusion.
Telemetry updated to report fused pitch/rate instead of raw ADC counts.

Also fix icm42688_init() returning 0 on who==0 (no SPI response),
which falsely indicated IMU success.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 12:37:24 -05:00
00d62a621e bd-wax: add SLAM setup technical plan for Jetson Nano + D435i + RPLIDAR
Scopes Phase 2 perception/SLAM integration:
- RTAB-Map (primary) + ORB-SLAM3 (fallback) recommendation with rationale
- Docker/Humble strategy on JetPack 4.6 (avoids OS reflash)
- ROS2 node graph, static TF frame, sensor params for Nano power budget
- Phased milestones: 2a SLAM bring-up, 2b Nav2 integration (separate bead)
- Power budget analysis and mitigation steps for 10W Nano constraint

Closes: bd-wax (scoping only — implementation tracking in Phase 2a checklist)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 12:17:19 -05:00
Sebastien Vayrette
0afdaea2e1 Add USB CDC bug doc and team requirements 2026-02-28 11:59:53 -05:00
Sebastien Vayrette
ba3e1161b9 Balance firmware + USB CDC bug 2026-02-28 11:58:23 -05:00