Vehicle suspension question

RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Vehicle suspension question

Post by RJNelson68 »

I have been integrating Bullet into Troque Game Engine Advanced version 1.81 and have nearly perfected the conversion but I noticed some things would like to ask about.

In Torque you have anti-sway and kinetic/static-friction variables that aid in a more realistic cornering effect. Additionally when the wheels are not in contact with the surface, the springs elongate out to their maximum length.

Has anyone here enhanced the Bullet suspension to do similar things and can show me examples or knows where there are examples other than the vehicle demo that I can look at for alternate suspension solutions?
kester
Posts: 27
Joined: Mon Dec 01, 2008 5:08 am

Re: Vehicle suspension question

Post by kester »

The springs should push the wheels out to their maximum length (m_suspensionRestLength1) automatically.

I tried both anti-sway & kinetic/static friction, but didn't have much luck with either. The sway bar introduced undesirable oscillation, and the kinetic friction model means that once a wheel loses traction, the vehicle tends to spin out, whereas we wanted to maintain control.

My notes on vehicles & suspension are here: http://docs.google.com/Doc?docid=0AXVUZ ... 4Zmo&hl=en
Although, they're not really complete enough to drop in.

For testing a sway bar, add the following at the end of updateSuspension. Note that it's hard-coded for 4 wheel vehicles:

Code: Select all

	// Connect suspension between front & back
	float wheelsSuspensionForce[4];
	static btScalar sideBalanceFactor = 0.02f;
	static btScalar forwardBalanceFactor = 0.02f;
	for (int wheel = 0; wheel < getNumWheels(); ++wheel)
	{
		btScalar sideBalance = m_wheelInfo[wheel ^ 1].m_wheelsSuspensionForce > 0.0f ? sideBalanceFactor : 0.0f;
		btScalar forwardBalance = m_wheelInfo[wheel ^ 2].m_wheelsSuspensionForce > 0.0f ? forwardBalanceFactor : 0.0f;
		btScalar sideForwardBalance = m_wheelInfo[wheel ^ 3].m_wheelsSuspensionForce > 0.0f ? sideBalanceFactor * forwardBalanceFactor : 0.0f;

		wheelsSuspensionForce[wheel] = 0.0f;
		if (m_wheelInfo[wheel].m_wheelsSuspensionForce > 0.0f)
		{
			wheelsSuspensionForce[wheel] = 
				+ sideBalance * m_wheelInfo[wheel ^ 1].m_wheelsSuspensionForce 
				+ forwardBalance * m_wheelInfo[wheel ^ 2].m_wheelsSuspensionForce
				+ sideForwardBalance * m_wheelInfo[wheel ^ 3].m_wheelsSuspensionForce
				+ (1.0f - sideForwardBalance - sideBalance - forwardBalance) * m_wheelInfo[wheel].m_wheelsSuspensionForce;
		}
	}

	for (int wheel = 0; wheel < getNumWheels(); ++wheel)
	{
		m_wheelInfo[wheel].m_wheelsSuspensionForce = wheelsSuspensionForce[wheel];
	}
RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Re: Vehicle suspension question

Post by RJNelson68 »

Interesting. Are you saying this doesn't work correctly?
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Vehicle suspension question

Post by gjaegy »

To Erwin: kester has provided some very useful comments on the btWheelInfo members in the link he posted.
You should definitively add them to the headers, this would let people save a lot of time trying to understand the effect of each of them...
RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Re: Vehicle suspension question

Post by RJNelson68 »

Thank you kester. I have noticed the one down fall to that code which is that if the vehicle is stationary, the suspension will gradually drop until the chassis touches. I was just curious to see if you had worked out some way to prevent that? Also, I just wanted to say, excellent notes and commenting of your work! Thanks again.
kester
Posts: 27
Joined: Mon Dec 01, 2008 5:08 am

Re: Vehicle suspension question

Post by kester »

RJNelson68 wrote:Thank you kester. I have noticed the one down fall to that code which is that if the vehicle is stationary, the suspension will gradually drop until the chassis touches. I was just curious to see if you had worked out some way to prevent that? Also, I just wanted to say, excellent notes and commenting of your work! Thanks again.
I didn't notice that. It shouldn't add any more force, so maybe your suspension damping coefficients are too high?
RJNelson68
Posts: 73
Joined: Tue Oct 06, 2009 3:19 pm

Re: Vehicle suspension question

Post by RJNelson68 »

Sorry I forgot to update this, it was totally my fault. I messed up in a completely different section. Thanks again.