[ODE] bad wheels
Johnson, Erik USA
rejohnso at nps.edu
Thu Feb 10 14:33:07 MST 2005
Here's mine (it's a combination of all ODE-car-steering code I've ever
seen). This works fairly well for me. The mAckermanRatio is kind of a
hack. There is (was?) an issue with the dParamLoStop/dParamHiStop where
you need to set them twice.
Hope this helps!
void SetSteeringControl(const float amount)
{
//positive = turn to right
dReal v0 = amount - dJointGetHinge2Angle1(mHingeJoint[0]);
dReal v1 = amount - dJointGetHinge2Angle1(mHingeJoint[1]);
v0 *= 10.0;
v1 *= 10.0;
if (amount > 0.f) v1 *= mAckermanRatio;
else v0 *= mAckermanRatio;
if (mSteeringEnabled)
{
dJointSetHinge2Param(mHingeJoint[0], dParamVel, v0);
dJointSetHinge2Param(mHingeJoint[1], dParamVel, v1);
dJointSetHinge2Param(mHingeJoint[0], dParamFMax, 2.0);//<max force
dJointSetHinge2Param(mHingeJoint[1], dParamFMax, 2.0);//<max force
dJointSetHinge2Param(mHingeJoint[0], dParamFudgeFactor, 0.5);
dJointSetHinge2Param(mHingeJoint[1], dParamFudgeFactor, 0.5);
dJointSetHinge2Param( mHingeJoint[0], dParamLoStop,
-35.0*SG_DEGREES_TO_RADIANS );
dJointSetHinge2Param( mHingeJoint[0], dParamHiStop,
35.0*SG_DEGREES_TO_RADIANS );
dJointSetHinge2Param( mHingeJoint[0], dParamLoStop,
-35.0*SG_DEGREES_TO_RADIANS );
dJointSetHinge2Param( mHingeJoint[0], dParamHiStop,
35.0*SG_DEGREES_TO_RADIANS );
dJointSetHinge2Param( mHingeJoint[1], dParamLoStop,
-35.0*SG_DEGREES_TO_RADIANS );
dJointSetHinge2Param( mHingeJoint[1], dParamHiStop,
35.0*SG_DEGREES_TO_RADIANS );
dJointSetHinge2Param( mHingeJoint[1], dParamLoStop,
-35.0*SG_DEGREES_TO_RADIANS );
dJointSetHinge2Param( mHingeJoint[1], dParamHiStop,
35.0*SG_DEGREES_TO_RADIANS );
}
else
{
dJointSetHinge2Param( mHingeJoint[0], dParamLoStop, 0.0 );
dJointSetHinge2Param( mHingeJoint[0], dParamHiStop, 0.0 );
dJointSetHinge2Param( mHingeJoint[0], dParamLoStop, 0.0 );
dJointSetHinge2Param( mHingeJoint[0], dParamHiStop, 0.0 );
dJointSetHinge2Param( mHingeJoint[1], dParamLoStop, 0.0 );
dJointSetHinge2Param( mHingeJoint[1], dParamHiStop, 0.0 );
dJointSetHinge2Param( mHingeJoint[1], dParamLoStop, 0.0 );
dJointSetHinge2Param( mHingeJoint[1], dParamHiStop, 0.0 );
}
}
> -----Original Message-----
> From: ode-bounces at q12.org [mailto:ode-bounces at q12.org] On
> Behalf Of THD
> Sent: Thursday, February 10, 2005 1:19 PM
> To: ODE at q12.org
> Subject: [ODE] bad wheels
>
> hello, I've got problems with my vehicle-steering in ODE
>
> My vehicle is a box with 4 spheres as wheels
> (hinge2-jointed), it's driving on a trimesh. My problem is
> steering. Sometimes the left wheel locks steering full left,
> sometimes the wheels steer in different direction, also
> problem increases when I drive faster.
>
> As you see beneath I ty to solve it setting
> dParamLoStop/dParamHiStop, but it doesn't seem to help...
>
> This piece of code is called every frame:
> (m_isSteering is a bool checking if the steering keys are
> down, m_steer is float that increases if I press the steering keys.)
>
>
> if(m_isSteering == false)
> {
> m_steer = 0.0f;
> dJointSetHinge2Param (wheel1id, dParamLoStop, 0);
> dJointSetHinge2Param (wheel1id, dParamHiStop, 0);
> dJointSetHinge2Param (wheel2id, dParamLoStop, 0);
> dJointSetHinge2Param (wheel2id, dParamHiStop, 0); } else {
> dReal v = m_steer - dJointGetHinge2Angle1(wheel1id);
> if (v > 0.1f)
> v = 0.1f;
> if (v < -0.1f)
> v = -0.1f;
> v *= 10.0f;
>
> dJointSetHinge2Param (wheel1id, dParamVel, v);
> dJointSetHinge2Param (wheel1id, dParamFMax, 0.2f);
> dJointSetHinge2Param (wheel1id, dParamLoStop, -0.5f);
> dJointSetHinge2Param (wheel1id, dParamHiStop, 0.5f);
> dJointSetHinge2Param (wheel1id, dParamFudgeFactor, 0.1f);
>
> dJointSetHinge2Param (wheel2id, dParamVel, v);
> dJointSetHinge2Param (wheel2id, dParamFMax, 0.2f);
> dJointSetHinge2Param (wheel2id, dParamLoStop, -0.5f);
> dJointSetHinge2Param (wheel2id, dParamHiStop, 0.5f);
> dJointSetHinge2Param (wheel2id, dParamFudgeFactor, 0.1f); }
>
>
> Shouldn't this work?
> Anyone who got any better steering-"algoritm" or suggestion?
>
> /Sepultang
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>
More information about the ODE
mailing list