fix: Roll axis + yaw telemetry (issues #12, #13) #14

Merged
seb merged 1 commits from sl-firmware/fix-orientation-telemetry into main 2026-02-28 16:56:09 -05:00
Collaborator

Summary

Issue #12 — Roll displayed as pitch:

  • Firmware was sending r = pitch_rate (wrong field name, wrong data). Changed to r = roll_deg × 10.
  • mpu6000.c: added roll complementary filter — accel_roll = atan2(ay, az) + gyro gy integration at COMP_ALPHA=0.98, same as pitch filter.
  • IMUData struct: added roll and yaw fields.
  • UI: updateIMU() now uses data.r / 10 for roll. Previously computed roll client-side from ax/ay/az which firmware never sent → roll was always 0°.
  • 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: pure gyro Z integration (gz × dt → s_yaw), sent as y = yaw_deg × 10. Gyro-only, drifts — no magnetometer on MAMBA F722S.
  • IMUData: yaw field added.
  • UI: yaw applied to boardGroup.rotation.y (vertical axis spin). Displayed in HUD as YAW row.
  • UI: YAW RESET button — captures current yaw as new zero reference (client-side offset, no new firmware command needed).

Test plan

  • Connect USB, verify PITCH/ROLL/YAW HUD all show live values
  • Tilt board forward — PITCH changes, ROLL and YAW stable
  • Tilt board sideways — ROLL changes, PITCH stable
  • Rotate board — YAW accumulates, PITCH/ROLL stable
  • YAW RESET button zeroes the display
  • Three.js model rotates correctly on all three axes

Closes #12, #13.

## Summary **Issue #12 — Roll displayed as pitch:** - Firmware was sending `r = pitch_rate` (wrong field name, wrong data). Changed to `r = roll_deg × 10`. - `mpu6000.c`: added roll complementary filter — `accel_roll = atan2(ay, az)` + gyro `gy` integration at `COMP_ALPHA=0.98`, same as pitch filter. - `IMUData` struct: added `roll` and `yaw` fields. - UI: `updateIMU()` now uses `data.r / 10` for roll. Previously computed roll client-side from `ax/ay/az` which firmware never sent → roll was always 0°. - 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: pure gyro Z integration (`gz × dt → s_yaw`), sent as `y = yaw_deg × 10`. Gyro-only, drifts — no magnetometer on MAMBA F722S. - `IMUData`: `yaw` field added. - UI: yaw applied to `boardGroup.rotation.y` (vertical axis spin). Displayed in HUD as YAW row. - UI: **YAW RESET** button — captures current yaw as new zero reference (client-side offset, no new firmware command needed). ## Test plan - [ ] Connect USB, verify PITCH/ROLL/YAW HUD all show live values - [ ] Tilt board forward — PITCH changes, ROLL and YAW stable - [ ] Tilt board sideways — ROLL changes, PITCH stable - [ ] Rotate board — YAW accumulates, PITCH/ROLL stable - [ ] YAW RESET button zeroes the display - [ ] Three.js model rotates correctly on all three axes Closes #12, #13.
sl-firmware added 1 commit 2026-02-28 15:07:20 -05:00
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>
seb approved these changes 2026-02-28 16:56:08 -05:00
seb left a comment
Owner

Flash-tested: all 3 axes streaming (p/r/y). Yaw accumulates correctly. Merging.

Flash-tested: all 3 axes streaming (p/r/y). Yaw accumulates correctly. Merging.
seb merged commit b9c8bc1a36 into main 2026-02-28 16:56:09 -05: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#14
No description provided.