[ODE] Car steering

Nate W coding at natew.com
Tue Aug 20 10:56:02 2002


On Tue, 20 Aug 2002, Thomas Harte wrote:

> As I see it, what I would would to do is implement two hinge-2's, once
> for each front wheel, but then how would I add an additional
> constraint that will keep the orientation of body 2 (i.e. the wheel)
> of one hinge-2 and the orientation of the other body 2 the same?
> Alternatively, if I am thinking about this all wrong, what is the
> correct way to go about this?

I'd implement that 'constraint' in the application code.  That is, with
each simulation step:

1) compute the desired steering angle (axis 1) of each hinge-2 joint
2) look at the actual axis-1 angle of each hinge-2 joint
3) compute a desired velocity for axis 1 that will bring the actual angle
closer to the desired angle
4) apply that force

Here's a couple lines cut-and-pasted from Si Brown's buggy demo:

double steeringVelocity = (desiredPosition - actualPosition) * 10;
dJointSetHinge2Param(carJoints[i], dParamVel, steeringVelocity);

That's in a loop so it's applied to all four hinge-2 joints so you get
four wheel steering.  That demo is worth downloading if you want to use
ODE, especially if you want to do a car simulation.  It's also really fun,
I burned many hours trying to do 180s over the jump ramps and figure-8s
around the playground and stuff like that. :-)

> NB I am aware that on a real car the two body 2's will not necessarily
> have identical orientation, but may concern themselves with Ackerman
> steering geometry, however I am ignoring this fact for now, and
> possibly forever if it proves complicated to communicate to ODE.

This is computationally expensive, but it's kind of neat:

http://www.natew.com/juice/images/Buggy3.jpg

I used ball joints around the "spindle" bodies, and the T-shaped set of
bodies above the chassis is the steering linkage.  The little ball joints
at the ends of the steering linkage are connected to the spindle bodies,
though that connection isn't shown visually.

I haven't done any serious performance measurements, but I think it runs
around 50-60 hz on my 1.4ghz K7 using Demeter and the tri-collider for
terrain rendering and collision detection.

-- 

Nate Waddoups
Redmond WA USA
http://www.natew.com