Drift-free steering roll: SensorFusion.gravityRollRadians() (#314)#109
Merged
Conversation
…(#314) Roll extracted from the accelerometer-anchored gravity vector instead of Euler-Z of the integrated orientation. Euler-Z mixes in YAW — the one axis a 6-axis IMU can't anchor — so it drifts without bound and "fuses to one side" (the in-game symptom on Steam Controllers). Reading roll straight from the gravity vector depends only on which way is currently down, so it can't drift, is naturally bounded, and never touches the gyro (also immune to gyro bias/sign errors). The game (input-manager.js) already has a 'gravity' roll mode that calls fusion.gravityRollRadians(), but the method never existed in controller-core, so it silently fell back to the drift-prone Euler-Z path — the #314 feature was half-built. This completes it. - new gravity-roll.js: pure rollFromGravity(gx, gy) = atan2(gx, -gy), THREE-free (mirrors yaw-return.js so the core test job stays dependency-free). - SensorFusion.gravityRollRadians() delegates to it over _gravityVec. - Sign matches the -EulerZ convention the game already steers by, so it's a drop-in (no steering inversion) that only removes the drift. - Tests lock sign, yaw-immunity (roll identical at every heading, incl. 5 turns of accumulated drift), and pitch-does-not-leak. 144 core tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Qnt4svMm6b8zkWfSk75vW
🔎 PR #109 preview — torn downThis PR is closed; its web preview and desktop prerelease have been removed. |
petegordon
added a commit
that referenced
this pull request
Jul 9, 2026
Adds SensorFusion.gravityRollRadians() — drift-free roll from the gravity vector for lean-to-steer input (#109). Backward-compatible with 0.4.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Qnt4svMm6b8zkWfSk75vW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SensorFusion.gravityRollRadians()— roll derived from the accelerometer-anchored gravity vector instead of Euler-Z of the integrated orientation. This is the fix for the in-game symptom where a Steam Controller's steering "fuses to one side" and drifts (reported after playing RIDE TOGETHER / VERSUS with two Steam Controllers).Why
The half-built feature this completes
The game (
input-manager.js, #314) already has a'gravity'roll mode that callsfusion.gravityRollRadians()— but that method never existed in controller-core, so the game silently fell back to the drift-prone Euler-Z path. Both modes were effectively the drifting one. This lands the missing method so the game's default actually works.Changes
gravity-roll.js: purerollFromGravity(gx, gy) = atan2(gx, -gy), THREE-free (mirrorsyaw-return.jsso the dependency-free core test job stays green).SensorFusion.gravityRollRadians()delegates to it over_gravityVec.-EulerZconvention the game already steers by → drop-in, no steering inversion; it only removes the drift.Tests (144 core pass)
gravity-roll.test.jslocks the gameplay-critical invariants with plain-quaternion math (no three):-φ(matches-EulerZ);Rollout
After merge → release
core-v0.4.1→ re-sync the game (PR petegordon/Tandemonium#361) → in-game feel test.🤖 Generated with Claude Code