IMU Calibration
The IMU Calibration module (imu_cal.c) is responsible for re-zeroing and configuring the external 6-axis IMU sensor via the CAN bus.
Calibration Sequence
When a recalibration is requested (typically via a dashboard input mapped to can_rx_data.dash_inputs.IMU_Recal), the module executes a 5-step sequence targeting CAN ID 0x050:
- Step 0 (0 ms): Unlock Configuration.
- Step 1 (+200 ms): Enable 6-Axis mode.
- Step 2 (+200 ms): Start acceleration calibration.
- Step 3 (+6.6 s): Exit calibration mode.
- Step 4 (+200 ms): Reset heading (yaw).
CAN Bus Timing
To ensure the calibration commands are not lost or corrupted by dense CAN traffic, the imu_cal_tick() function carefully orchestrates the transmission. It monitors the time elapsed since the last incoming IMU frame. It waits for a specific "quiet window" (between 4ms and 14ms since the last frame) to dispatch the outgoing calibration command, ensuring it sneaks in between the IMU's high-frequency broadcast bursts.
