IMU mount angle calibration — save offset to flash, expose recal via USB + remote monitor #680

Closed
opened 2026-03-17 22:34:43 -04:00 by seb · 0 comments
Owner

Problem

Mamba F7 MK2 is mounted at ~12-15° offset on the SaltyBot frame. The current mpu6000_calibrate() only zeros gyro bias, not the static pitch/roll mount offset. This causes:

  • Arm check fails even when robot is vertical (pitch reads 12-15° when flat)
  • Balance setpoint is wrong — robot thinks it is tilted when balanced

Required changes

1. Mount angle calibration (firmware)

  • Add float mount_pitch_offset and float mount_roll_offset to flash config alongside PID gains
  • Add C USB command: samples 50 IMU readings at rest → computes mean pitch/roll → stores as mount offset
  • Apply offset in mpu6000_read(): corrected_pitch = raw_pitch - mount_pitch_offset
  • On boot: load offset from flash (default 0.0 if not calibrated)
  • Telemetry: add "cal":1 field when mount calibration has been done

2. Recalibrate from remote monitor

  • Add WebSocket command {"cmd":"calibrate_imu"} handler in saltybot_cmd_node (bridge)
  • Bridge sends C\n to FC via serial
  • Remote monitor: add Calibrate IMU button that sends this command

3. Show calibration status in remote monitor

  • Add imu_calibrated field to balance_state topic
  • Remote monitor shows CALIBRATED / UNCALIBRATED badge on ATTITUDE panel

Notes

  • C command should only work when DISARMED
  • Hold robot still for ~1s during calibration
  • After C, FC should auto-recalibrate gyro bias too (call mpu6000_calibrate() as well)
## Problem Mamba F7 MK2 is mounted at ~12-15° offset on the SaltyBot frame. The current `mpu6000_calibrate()` only zeros gyro bias, not the static pitch/roll mount offset. This causes: - Arm check fails even when robot is vertical (pitch reads 12-15° when flat) - Balance setpoint is wrong — robot thinks it is tilted when balanced ## Required changes ### 1. Mount angle calibration (firmware) - Add `float mount_pitch_offset` and `float mount_roll_offset` to flash config alongside PID gains - Add `C` USB command: samples 50 IMU readings at rest → computes mean pitch/roll → stores as mount offset - Apply offset in `mpu6000_read()`: `corrected_pitch = raw_pitch - mount_pitch_offset` - On boot: load offset from flash (default 0.0 if not calibrated) - Telemetry: add `"cal":1` field when mount calibration has been done ### 2. Recalibrate from remote monitor - Add WebSocket command `{"cmd":"calibrate_imu"}` handler in saltybot_cmd_node (bridge) - Bridge sends `C\n` to FC via serial - Remote monitor: add **Calibrate IMU** button that sends this command ### 3. Show calibration status in remote monitor - Add `imu_calibrated` field to balance_state topic - Remote monitor shows CALIBRATED / UNCALIBRATED badge on ATTITUDE panel ## Notes - `C` command should only work when DISARMED - Hold robot still for ~1s during calibration - After `C`, FC should auto-recalibrate gyro bias too (call `mpu6000_calibrate()` as well)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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