[ODE] Help with car simulation pls! :/

david@csworkbench.com david at csworkbench.com
Mon Apr 7 20:45:02 2003


The friction parameter I was speaking of is mu.  You have it set to 250,
which means a contact joint is allowed up to 250 units of force to oppose
the motion of the stuff in contact, which equates to traction for your
tires.  250 is plenty of force if you kept your masses around 1.0 as
suggested in the docs.

The reason why your car is "sinking" into the ground is because of your
CFM and ERP settings.  CFM is a parameter that helps to take any
singularities out of the system matrix, and has the side effect of making
the system look "spongy" (higher gravity would make a car compress the
ground "sponge" more).  ERP is the amount of joint error to attempt to
correct each time step (say you have a fixed joint between two objects,
and one object is two units away from the other.  With an ERP of 0.5, it
would move the objects one unit closer, or with an ERP of 1.0, it would
bring them all the way together).  It has the effect of making the system
look "bouncy".  A CFM of 0.0 and an ERP of 1.0 might be thought of the way
to keep the system perfectly hard, but is rarely a good idea.  I generally
use a CFM of 1e-5 (or 1e-3 if you're using single precision) and an ERP
around 0.8 unless I'm going for one of the effects I mentioned.  Lowering
the CFM should have the greatest effect on that sinking feeling in your
system.

You want to keep the chassis mass fairly close to the wheel mass for
stability purposes.  The easiest way to keep the car from tipping over is
to lower it's center of gravity.  This is performed by placing the body
lower (even under the ground), and attaching a geomTransform to that body.
 Then set the position of the geom to something like (0,5,0) to mean 5
units above the body it's transform is attached to.  Don't insert the geom
into the space, only it's transform.  I believe the monstor truck demo
linked on the website uses that method.

Hope that helps,
David

>> So what can you do to fix it?  The first best thing is to add a ground
>> plane and gravity, and be sure to set up at least a little bit of
>> friction in your collision callback function.  That should get your
>> car to start moving in the direction you want it to.  But it won't
>> handle the stop problem.  The way you fix that is, down at the very
>> bottom of the code you copied in, where you set the FMax to 2.0, check
>> dHinge2GetAngle1 to see if it returns a number outside of -0.5 and
>> 0.5.  If that's the case, set the FMax to 0 to unpower the joint,
>> otherwise set it to 2.0 as planned.  ODE just doesn't handle powering
>> into stops very gracefully at present.
>>
>
> Thank you very much David! That explination was a great help.
>
> Now that I have my car moving/steering.. I'm trying to tweak the
> settings, but I'm running a little blind. One aspect I'm not to sure
> about is the friction David talked about. Reading the docs seems to
> suggest that fdir1 is calculated itself? But I tried to print out the
> values and got garbage which seems to tell that its not. The docs talk
> about using dContactFDir1 and the FDS to apply tyre friction, it
> mentions to set dContactFDir1 to the direction of travel.. if my maths
> serves me correctly (dodgy ;p) if I get the linear velocity of the body,
> and normalise it..  I should be able to plug this into dContact.fdir
> yes? Or should I use the damping method which has been discussed
> recently?
>
> Another anomality seems to be with the gravity. Any higher value than
> ~(0, -0.05, 0) (i.e. if I try to use -9.81) and the car will just sink
> right down. Either when the cars inital position is at (0, 0, 0) or if I
> drop the car down onto the plane (tried, 10, 50, 100 in the y-axis). I
> must be missing a concept here? Should the contact joint have a specific
> setting here to stop it "sinking" ?
>
> Also, how important is the chassis mass relative to the wheel mass? This
> would help stopping the car tipping on it sides yes?
>
> So far I've come up with these values (mix'd and matched from various
> other source files)
>
> contacts[c].surface.mode = dContactSlip1 | dContactSlip2 |
> dContactSoftERP | dContactSoftCFM | dContactApprox1;
> contacts[c].surface.mu = 250;
> contacts[c].surface.slip1 = 0.1;
> contacts[c].surface.slip2 = 0.1;
> contacts[c].surface.soft_erp = 0.5;
> contacts[c].surface.soft_cfm = 0.3;
>
> Any tips anyone has would be greatly appericated.
>
> Thank you,
>
> Regards
>
> Craig
>
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode