[ODE] Car steering

Martin C. Martin martin at metahuman.org
Mon Aug 26 19:29:02 2002


Nate W wrote:
> 
> On Mon, 26 Aug 2002, Thomas Harte wrote:
> 
> > But how would this account for, e.g. a turned wheel hitting a side
> > wall and being forced into the forward position correctly forcing the
> > wheel on the other side to turn?
> 
> Good question... it wouldn't account for that.
> 
> (Warning: I'm making this up as I go along.)
> 
> You might try using an intermediate body between each hinge-2 and the
> wheel.


Ah, but then you've introduced extra degrees of freedom for the solver to
worry about. You've also introduced extra "squishiness," since the wheels
aren't directly coupled, only indirectly.  E.g. if the intermediate body
gets out of sync, it could lead to some strange forces indeed.

One thing you could do is, at each time step, apply a torque to each wheel
proportional to the difference in their angles.  That is:

diff_angle = angle_of_wheel_1 - angle_of_wheel_2

wheel_1.AddTorque( - k * diff_angle );
wheel_2.AddTorque( + k * diff_angle );

This adds a torque that "pushes" each wheel in the direction needed to
keep them equal.  If you get oscillation, you could add a torque
proportional to the difference of their angular velocities.

Of course, you could also create your own joint type to do this.  When you
use the solver to do this, it adjusts the force to (try to) balance out
any other forces.  So, if something is pushing the two wheels in opposite
directions, the restoring forces will be increased to overcome those.  But
writing a joint can be a little tricky, so if you're not comfortable with
it, try using the solution above.

Good luck,
Martin