Files
swiftcontrol/lib/widgets/controller
Jonas Acker 08089c5a86 fix(steering): phone steering reads the bars at 50 Hz about the true up axis, and the compass learns the mount
- sensors_plus delivered 5 Hz unless asked, while the estimator capped every
  step at 50 ms: a steer and back left a residual of a few degrees. Samples
  now come at game rate, are timed by the sensor's own timestamps, and a step
  integrates its whole duration.
- The gyroscope is projected onto gravity's axis, so a mount that tilts the
  phone towards the rider reads the full steering angle. The bias is learned
  on all three axes and seeded from the whole still window at calibration.
- Magnetometer mode no longer swaps the gyroscope for a raw compass heading.
  The raw field carries the phone's and the mount's own magnetic offset, far
  larger than the Earth's, which made both turn directions read the same way.
  The compass now fits that offset against the gyro angle while the bars turn
  (a circle fit, linear in the unknowns), and once it holds, a slow PI loop
  pulls the angle and the gyro bias towards the drift-free compass yaw.
- The compass switch is remembered across launches; its row says what it
  does, asks for one left-and-right turn, then reports that it is correcting.

Tests drive the estimator with a simulated phone on a tilted, magnetic mount
with noisy sensors, and the device with scripted sensor streams.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-08 14:37:32 +02:00
..
2026-05-04 12:06:56 +02:00