[ODE] RE: Wheel rotation problem

McEvoy, Nick nick.mcevoy at dsto.defence.gov.au
Tue Sep 10 17:50:02 2002


Peter Ashford wrote:

>Has anyone fixed the problem with wheel rotations (use of hinge2) which
>rotate too fast and get out of synch.

Not that I know of. :-(


>I know that other people have mentioned this in the past (including me),
>and I know that this is an open source project so that I should fix it
>myself, but while I'm a good coder, I'm a physics bunny.  So. can
>someone help with that one please?

I haven't spoken up before ... but yes this one bugs me too ! :-(


>BTW: before anyone mentions it, I am aware of the 'Buggy' demo, I have
>mailed the author of that demo, and he said that he had the same problem
>of wheels getting 'bent' through rotation as well.
>Please Help!

The user documentation suggests to use dBodySetFiniteRotationAxis() &
dBodySetFiniteRotationMode() to fix this problem ... or to quote from my
code below ... "Attempt to stop wheels freaking out".  I tried it and it
'minimised' the problem, but did not totally remove the 'bendy' wheels
problem when cornering at high speed !?

Actually I have not yet applied the finite rotation to my front wheels yet
and sometimes my front wheels split in different directions ... see my ascii
art of the front & back wheels ... :-)

\  /

|  |

I'm still waiting for a good answer on this one.

--------------------------------------------------
 
// Front and back wheel hinges (nb. 0-1=front wheels, 2-3=back wheels,
4=player, 5=chassis)
for (i = 0; i <= 3; i++)
{
	mODEJoint[i] = dJointCreateHinge2(reGetODEWorldId(),0);
	dJointAttach(mODEJoint[i], mODEBody[5], mODEBody[i]);
	const dReal *a = dBodyGetPosition(mODEBody[i]);
	dJointSetHinge2Anchor (mODEJoint[i], a[0], a[1], a[2]);
	dJointSetHinge2Axis1(mODEJoint[i], 0, 0, 1);
	dJointSetHinge2Axis2(mODEJoint[i], 1, 0, 0);

	// Set joint suspension
	dJointSetHinge2Param(mODEJoint[i], dParamSuspensionERP, 0.8f);
	dJointSetHinge2Param(mODEJoint[i], dParamSuspensionCFM, 0.2f);

	// Lock back 'wheels' along the steering axis
	if (i >= 2)
	{
		// Set stops to make sure 'wheels' always stay in alignment
		dJointSetHinge2Param(mODEJoint[i], dParamLoStop, 0);
		dJointSetHinge2Param(mODEJoint[i], dParamHiStop, 0);

		// Attempt to stop wheels freaking out
		dBodySetFiniteRotationAxis(mODEBody[i], 0, 0, 0);
		dBodySetFiniteRotationMode(mODEBody[i], 1);
	}
}

Nick
http://members.ozemail.com.au/~ndmcevoy/