Learn the gyro drift left after calibration while the controller lies still and subtract it, so the aim stops sliding on a table, from pull request #380 (#292, #1267)

The calibration removes the bias measured once; a bias that moves as the controller warms up, or a controller never
calibrated, still turns the aim slowly. motion_fusion.c drift_track learns it from 256 ms windows in which the gyro
stays within 0.04 rad/s and the acceleration within 0.03 G peak to peak, after half a second of rest, with a time
constant of 0.25 s until the estimate settles and 30 s after. The estimate sits on top of the calibrated bias and is
cleared with a new controller, a new or loaded calibration and a change of gyro_calibration. New setting
gyro_auto_bias (live, default 1).

Taken from #380: the rest window by peak to peak, the two time constants, the per-axis limit. Left out: the
0.006 rad/s dead zone, which ate slow aiming; the one global state shared by every fusion instance; the reset at
every StartSixAxisSensor; the 0.5 G acceleration gate, which let a controller in motion count as still. The first
estimate is limited to 0.1 rad/s from zero instead of 0.15; a larger bias is the calibration's job.

Also: a sample without a reading at a restart (#1274) no longer returns before the calibration's log and save.

--probe-services checks the drift with the switch off and on, after a calibration whose bias then moved, a slow
aim in the hand, and the levelling of #1274 with a bias on every axis.

Co-authored-by: airquark <97342227+airquark@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
committed 2026-11-18 09:06:30 +03:00
1 parent 706144d673
commit 45a0cd1f6c
5 files changed
+240 -17

No files matched your search

+3
View File
@@ -149,6 +149,9 @@ int input_motion_calib_state(char *pad, size_t cap);
int input_gyro_calibration_enabled(void);
// The fusion's own read of the same switch (motion_fusion.c); input.c reaches it for the row's state.
int motion_calibration_enabled(void);
// The drift tracker's switch (gyro_auto_bias, live): the drift left after calibration, learned while the controller
// lies still, is subtracted too.
int motion_auto_bias_enabled(void);
// SDL sensor values (accelerometer m/s^2, gyro rad/s, SDL gamepad axes) to the Switch controller frame motion_feed
// takes (acceleration in G as gravity reads, rotation rad/s). The mapping is documented in input_win.c.
void input_motion_axes(const float sdl_acc[3], const float sdl_gyro[3], double acc_g[3], double gyro[3]);