[ODE] hinge-2 and coordinate systems
maddocks@metservice.com
maddocks at metservice.com
Thu Jul 25 14:36:02 2002
I never had any problems with the hinge2 joint. It was surprisingly easy
to get working. Heres my set up code....
bool Suspension::SetUp( graphics::Scene* scene, Body* body, dGeomID
geomGroup)
{
assert( brake);
assert( wheel);
brake->SetUp( scene, geomGroup);
wheel->SetUp( scene, geomGroup);
// wheel hinge
odeJoint = new dHinge2Joint( *scene->World(), 0);
odeJoint->attach( *body->getBody(), *wheel->getBody());
odeJoint->setAnchor( position.x, position.y - restLength,
position.z); // hub position
odeJoint->setAxis1( 0.0f, 1.0f, 0.0f);
odeJoint->setAxis2( 1.0f, 0.0f, 0.0f);
// set joint suspension
// h = Simulation timestep FIXME hardcoded
Scalar h = 0.01;
// k_p = Spring Constant
// k_d = Spring Damping
//
// ERP = h k_p / (h k_p + k_d)
// CFM = 1 / (h k_p + k_d)
Scalar springERM = h * springConstant / ( h * springConstant +
springDamper);
Scalar springCFM = 1 / ( h * springConstant + springDamper);
odeJoint->setParam( dParamSuspensionERP, springERM);
odeJoint->setParam( dParamSuspensionCFM, springCFM);
if( !steering)
{
odeJoint->setParam( dParamLoStop, 0);
odeJoint->setParam( dParamHiStop, 0);
}
return true;
}
This function is called after the car is oriented and the suspension
position is in world coordinates but from memory I don't think it made
any difference.
I just ignored the coordinate system and assumed everything was as per
opengl (Z = up axis). One thing that could be a problem is your body may
be too heavy for your suspension springs.
Any questions, email me.
Henry
On Thursday, July 25, 2002, at 09:09 AM, Timothy J. Wood wrote:
>
>
> I'm new to ODE and I'm having trouble with joints. I'm building a
> basic 4-wheel car from a chassis block and 4 wheels (drawn as
> cylinders, but simulated as spheres).
>
> My code is based fairly closely off the buggy test, but when I use
> hinge-2 joints, the chassis just falls to the ground. When I use fixed
> joints (just for debugging), the wheels stay attached, but they quickly
> spin 90 degress CCW about the up vector. This is maybe expected since
> when I create my wheels, I rotate them and fixed joints apparently
> don't support non-identity relative orientations.
>
> One difference between my code and the buggy code is that I'm using
> the standard OpenGL coordinate system instead of the coordinate system
> that ODE seems to use (with Z being up instead of Y). Both are
> right-handed, so I would assume all should be OK. The other difference
> is that I'm not currently using a geometry group since that should just
> optimize stuff, not actually change the results in this case.
>
> I've positioned and oriented my objects before attaching them. Are
> there any other obvious things that would cause hinge-2 joints to
> completely fail to keep the anchor points together? A search on the
> mailing list archive shows only that others are able to make hinge-2
> work, not any failure modes of this variety that I could find.
>
> Thanks!
>
> -tim
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
>
>
"Two is not equal to three, even for large values of two"