Skip to content

Fix issue 925 (wheel rotation calculation)#945

Open
tomo0613 wants to merge 2 commits into
dimforge:masterfrom
tomo0613:fix_issue_925
Open

Fix issue 925 (wheel rotation calculation)#945
tomo0613 wants to merge 2 commits into
dimforge:masterfrom
tomo0613:fix_issue_925

Conversation

@tomo0613

@tomo0613 tomo0613 commented Jun 7, 2026

Copy link
Copy Markdown

#925

explanation (by Claude):

The Bug
In src/control/ray_cast_vehicle_controller.rs, the wheel rotation update uses a fwd (forward) vector computed independently from the chassis rotation:

let mut fwd = chassis.position().rotation * Vector::ith(self.index_forward_axis, 1.0);
let proj = fwd.dot(wheel.raycast_info.contact_normal_ws);
fwd -= wheel.raycast_info.contact_normal_ws * proj;

But the friction impulse system in update_friction() computes forward as:

self.forward_ws[i] = surf_normal_ws.cross(self.axle[i]).normalize_or_zero();

These two methods produce vectors that can point in opposite directions depending on the axle axis convention. For example, with index_forward_axis = 2 (Z forward) and a wheel axle along -X:

  • forward_ws[i] = Y × (-X) = -Z
  • fwd = +Z ← exact opposite!

The result: delta_rotation has the wrong sign, making the wheel appear to spin backward (and it cancels out to ~0). When steering is applied, the axle rotates, which partially corrupts/corrects the mismatch — which is exactly why rotation only appears when steering.

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