Skip to content

ffb(engine): band-limit the inertia estimate, let the levels pass 100 - #103

Merged
mescon merged 1 commit into
masterfrom
ffb/inertia-band-limited
Sep 14, 2026
Merged

mescon merged 1 commit into
masterfrom
ffb/inertia-band-limited

Conversation

@mescon

@mescon mescon commented Sep 14, 2026

Copy link
Copy Markdown
Owner

For #89 (and the calibration in #87).

  • FF_INERTIA is fed a band-limited acceleration: the gap between the velocity and a 50 ms one-pole chasing it (hidpp_dd_accel_filter in the effect-math header). A steady acceleration reads exactly as before, so the 4096 scale is untouched; the encoder's quantisation blips become small decaying bumps instead of full-count spikes. Runs every tick on the held velocity, so the G923's 2 ms reports are filtered at the same rate.
  • spring_level, damper_level, friction_level accept 0..400 (was 0..100) and inertia_level is new, so the gains owners measured against the firmware can be tried without a rebuild. Defaults unchanged.
  • Five new effect-math tests; make -C tests/effect-math run and the texture-merge suite pass; the module builds clean against 7.2.4 with clang.

Not felt on hardware: no wheel is attached here tonight.

FF_INERTIA was fed this tick's velocity minus the last one, which on a
quantised encoder is an impulse train: a rim turning smoothly reads as a
burst of full-count accelerations for one tick and nothing the next, and
that came through as grain (#89, where the author of another engine had
met the same thing and suggested the cure). The estimate is now the gap
between the velocity and a 50 ms one-pole chasing it. The gap of a
first-order lag behind a ramp settles at slope times tau, so a steady
acceleration reads exactly as before and the effect's scale is
untouched, while a one-tick blip becomes a bump of a fiftieth the height
that decays over tau. It runs every tick on the held velocity, so a
wheel reporting every 2 ms is filtered at the same rate as one reporting
every tick, and a stop after the hold decays instead of arriving as one
tick of minus the velocity. Fixed point in 1/256ths so sub-count
accelerations survive the division, with a snap to the velocity within
one step so a parked wheel reads exactly zero. Five effect-math tests
cover the steady state, the quantisation case, a step, rest and
symmetry.

spring_level, damper_level and friction_level accept up to 400 instead
of 100, and inertia_level joins them. The engine's gains sit below what
the firmware renders by amounts owners have measured (damper at 0.61 of
the firmware on a G923 Xbox edition, #87; 2.25x damper and 4x spring on
a G PRO, #89), and the cap left no way to try those numbers without a
rebuild. The fields widen to u16; the summed force is clamped to the
wire range after every effect, so a large level saturates. Defaults are
unchanged. Builds clean against 7.2.4 with clang.
@sonarqubecloud

Copy link
Copy Markdown

@mescon
mescon merged commit e18996c into master Sep 14, 2026
18 checks passed
@mescon
mescon deleted the ffb/inertia-band-limited branch September 22, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant