Simulating a Car

Hi everyone,

I'm attempting to make a car, but the wheels keep popping off. Other than that, it's pretty neat. Something like this might be good to add to the test bed... I always loved the car simulations I found in other physics engines.

If anyone wants to take a look at it, I've uploaded the (VS2005) project here: http://www.sfu.ca/~mnb2/SpiritWalkers.zip (windows executable included).

Image
I tried printing out the joint translation of the shocks. They exceed the lower and upper translation limits. I guess exerting a force to push them back into place not only didn't work, but causes the car to pretty much explode. I'm going to try and manually set the translation if it exceeds the limits...

This is a really hacky fix, but it at least prevents the car from exploding. If someone knows a better way... I'd be happy to hear it.

Code:
   float wheel, shock, lowerTrans, upperTrans;
   
   wheel      = world->m_leftWheel->GetCenterPosition().y;
   shock      = world->m_leftShock->GetAnchor2().y;
   lowerTrans   = world->m_leftShock->m_lowerTranslation;
   upperTrans   = world->m_leftShock->m_upperTranslation;

   if(shock-wheel<lowerTrans)
      world->m_leftWheel->m_position.y = shock+lowerTrans;
   if(wheel-shock>upperTrans)
      world->m_leftWheel->m_position.y = shock+upperTrans;

   wheel      = world->m_rightWheel->GetCenterPosition().y;
   shock      = world->m_rightShock->GetAnchor2().y;

   if(shock-wheel<lowerTrans)
      world->m_rightWheel->m_position.y = shock+lowerTrans;
   if(wheel-shock>upperTrans)
      world->m_rightWheel->m_position.y = shock+upperTrans;

   world->m_leftWheel->m_position.x = world->m_leftShock->GetAnchor2().x;
   world->m_rightWheel->m_position.x = world->m_rightShock->GetAnchor2().x;
I've downloaded the demo, but it tells me that freeglut.dll is missing on the release version and that the program failed to start because the configuration is wrong on the debug version. Where can I get a precompiled version of freeglut.dll?

I can't find anything on google or findfiles.
Oh shoot... totally forgot about that. No wonder no one has responded. Thanks for pointing this out!

Freeglut is available here: http://www.sfu.ca/~mnb2/freeglut.dll
I changed each of the prismatic joints into pairs of distance joints. The car is still getting a lot of bounce (there's no restitution). I guess this is from the wheels being projected out of the ground plane when going up a slope. Theoretically, this shouldn't cause the car to jump... I think it's exerting too much force to keep the tires out of the ground. CCD didn't fix this unfortunately...

Am I dumb, or is the physics wrong?
I'm working on a car example for 2.0. Please be patient as there are some major changes going on in the engine right now.
Okay, that's cool 🙂 Just wanted to know if I was doing wrong or I should wait it out. Lots of other cool stuff I can still do.
I have the car example now in SVN. I removed the axle bodies and it is quite stable now.

Original thread: https://box2d.org/forum/viewtopic.php?t=163