[ODE] wheels attached at the wrong spot
Ian McMeans
imcmeans at telus.net
Sat Apr 3 15:28:53 MST 2004
Nope, removing that line of code didn't fix it.I added some code to draw the
axles - the yellow line goes from the wheel centre to the anchor point. As
you can see, it appears that the anchor point isn't fixed relative to the
car body. It appears to stay within a certain radius of the car, though, and
it doesn't move side-to-side much (right now, at least).
http://www.imageshack.us/my.php?loc=img2&image=axles1.JPG
http://www.imageshack.us/my.php?loc=img2&image=axles3.JPG
----- Original Message -----
From: "akio" <cullum_a at bellsouth.net>
To: "Ian McMeans" <imcmeans at telus.net>; <ode at q12.org>
Sent: Saturday, April 03, 2004 2:21 PM
Subject: Re: [ODE] wheels attached at the wrong spot
> I see a problem in the car() function:
>
> > dBodySetLinearVel(body, 0.05, 0.05, 0.05);
>
> This causes the body to move in the direction specified and have the
wheels
> stationary. Can you tell me what happens if you remove this line and if
the
> body still moves.
>
>
> ----- Original Message -----
> From: "Ian McMeans" <imcmeans at telus.net>
> To: <ode at q12.org>
> Sent: Saturday, April 03, 2004 4:03 PM
> Subject: Re: [ODE] wheels attached at the wrong spot
>
>
> > I actually am using spheres, I'm just drawing them as cubes for now
(it's
> > easier to see their orientation).
> >
> > I've posted my source code recently, here is the relevant part for
setting
> > up each wheel:
> > (LRfactor is -1 for wheels on the left, 1 for wheels on the right)
> >
> > // If I change the arguments below to x,y,z, ODE blows up :/
> > // Why can't the wheel position be right on the anchor? I've seen
example
> > code doing that.
> > dBodySetPosition(wheels[wheel], x + 0.5 * LRfactor, y, z);
> >
> > shocks[wheel] = dJointCreateHinge2(world, 0);
> > dJointAttach(shocks[wheel], body, wheels[wheel]); // does the order of
> args
> > here matter?
> > dJointSetHinge2Anchor(shocks[wheel], x, y, z);
> >
> > dJointSetHinge2Axis1(shocks[wheel], 0, 1, 0);
> > dJointSetHinge2Axis2(shocks[wheel], 1, 0, 0);
> >
> >
> > What really bothers me is that it seems the wheels aren't being
> constrained
> > in the way hinge2's are supposed to constrain wheels! The wheels should
> only
> > be able to move along axis 1 (the axis with suspension), and rotate
about
> > axis 2, however in the pictures I showed you, the wheels are moving in
the
> X
> > and Z axes, and if I enable gravity then they lean sideways and no
longer
> > spin around their correct axis.
> >
> > Here's what I'm talking about:
> > http://www.imageshack.us/my.php?loc=img1&image=broken1.JPG
> > How can that possibly be a hinge2? The wheels don't look constrained at
> all,
> > and there aren't even any forces acting on them because the car is
> floating
> > (no gravity) above the ground plane. And the wheels aren't oriented
along
> > the right axis.
> >
> > Car::Car(dWorldID world, dSpaceID world_space, Vector3d initialPos)
> > {
> > Vector3d carSize(0.5, 0.2, 1);
> > Vector3d wheelOffset(0.25, -0.5, 0.5); // wheel offsets from the
> car
> > centre
> >
> > car_space = dSimpleSpaceCreate(world_space);
> >
> > // create the masses that we attach to the body and wheels
> > dMass bodyMass, wheelMass;
> > dMassSetBoxTotal(&bodyMass, 50, carSize.X(), carSize.Y(),
> carSize.Z());
> > dMassSetSphereTotal(&wheelMass, 10, 0.2);
> >
> > // create the car body
> > body = dBodyCreate(world);
> > dBodySetMass(body, &bodyMass);
> > dBodySetPosition(body, initialPos.X(), initialPos.Y(),
> initialPos.Z());
> > dBodySetLinearVel(body, 0.05, 0.05, 0.05);
> >
> > // the car geometry
> > box = dCreateBox(car_space, carSize.X(), carSize.Y(), carSize.Z());
> > dGeomSetBody(box, body);
> >
> > // set up the wheels and their joints/geoms
> > for (int wheel = 0; wheel < 4; wheel++)
> > {
> > wheels[wheel] = dBodyCreate(world);
> > dBodySetMass(wheels[wheel], &wheelMass);
> >
> > wheelGeoms[wheel] = dCreateSphere(car_space,
wheelOffset.X()/2.0);
> > // change to cylinders?
> > dGeomSetBody(wheelGeoms[wheel], wheels[wheel]);
> >
> > // factors for knowing if the wheel is on the left or right
> > float LRfactor = ((wheel == 0 || wheel == 3)?1:-1);
> > float FBfactor = ((wheel == 0 || wheel == 1)?1:-1);
> >
> > dReal x = initialPos.X() + LRfactor * wheelOffset.X(); //
wheel
> 0
> > and 3 on the right
> > dReal y = initialPos.Y() + wheelOffset.Y();
> > dReal z = initialPos.Z() + FBfactor * wheelOffset.Z(); // wheel
0
> > and 1 at the front
> >
> > // should we have the wheel right on the hinge2 anchor?
> > // If I change the arguments to x,y,z, ODE blows up :/
> > // Why can't the wheel position be right on the anchor? I've
seen
> > example code doing that.
> > dBodySetPosition(wheels[wheel], x + 0.5 * LRfactor, y, z);
> >
> > shocks[wheel] = dJointCreateHinge2(world, 0);
> > dJointAttach(shocks[wheel], body, wheels[wheel]); // does the
> > order of args here matter?
> > dJointSetHinge2Anchor(shocks[wheel], x, y, z);
> >
> > dJointSetHinge2Axis1(shocks[wheel], 0, 1, 0);
> > dJointSetHinge2Axis2(shocks[wheel], 1, 0, 0);
> >
> > // dBodySetFiniteRotationMode(wheels[wheel], 1); // it
> apparently
> > makes wheels turn better
> >
> > if (wheel <= 1) // front wheels can turn left and right
> > {
> > dJointSetHinge2Param(shocks[wheel], dParamHiStop, M_PI/6.0);
> > dJointSetHinge2Param(shocks[wheel],
dParamLoStop, -M_PI/6.0);
> > }
> > else
> > {
> > dJointSetHinge2Param(shocks[wheel], dParamHiStop, 0); //
no
> > back wheel steering
> > dJointSetHinge2Param(shocks[wheel], dParamLoStop, 0);
> >
> > // the finite rotation axis needs to be constantly updated
for
> > the front wheels :/
> > dBodySetFiniteRotationAxis(wheels[wheel], 1, 0, 0);
> > }
> >
> > // is there a way to make the suspension "bottom out"? It seems
> not,
> > // unless we add an additional slider joint at each wheel.
> >
> > dJointSetHinge2Param(shocks[wheel], dParamFMax, 5); // force
to
> > steer
> > dJointSetHinge2Param(shocks[wheel], dParamFMax2, 200); //
force
> > to accelerate
> >
> > dJointSetHinge2Param(shocks[wheel], dParamVel2, 2);
> >
> > // feel free to fiddle with the below two numbers - increasing
one
> > means you should decrease the other, though
> > dJointSetHinge2Param(shocks[wheel], dParamSuspensionERP, 0.9);
> > // "spring strength"
> > dJointSetHinge2Param(shocks[wheel], dParamSuspensionCFM, 0.004);
> > // simulation "squishyness"
> > }
> >
> > }
> >
> >
> > ----- Original Message -----
> > From: "akio" <cullum_a at bellsouth.net>
> > To: "Ian McMeans" <imcmeans at telus.net>; <ode at q12.org>
> > Sent: Saturday, April 03, 2004 10:49 AM
> > Subject: Re: [ODE] wheels attached at the wrong spot
> >
> >
> > > Those pics are great. Love the wheels, hehe. Why don't you use
spheres
> > > instead.
> > >
> > > You've not copied and pasted any configuration, so it's difficult to
> > analyze
> > > the problem but I will make some suggestions.
> > > One or two possible invalid configurations:
> > > 1) your body is configured as hinge2 - it'll make the body spin as if
it
> > was
> > > a wheel (like the pic).
> > > 2) hinge2 axis alignment possibly could be off - all wheels must be
the
> > same
> > > otherwise you'll see weird body movements.
> > >
> > > ----- Original Message -----
> > > From: "Ian McMeans" <imcmeans at telus.net>
> > > To: <ode at q12.org>
> > > Sent: Saturday, April 03, 2004 1:49 AM
> > > Subject: [ODE] wheels attached at the wrong spot
> > >
> > >
> > > > Here are two pictures that I think illustrate my problem:
> > > > http://www.imageshack.us/my.php?loc=img2&image=normal1.JPG
> > > >
> > > > This is how my car looks with no gravity. Once I press forward and
the
> > > > wheels start spinning around their centres (IE in the normal way
> wheels
> > > > spin), my car looks like this:
> > > > http://www.imageshack.us/my.php?loc=img2&image=after1.JPG
> > > >
> > > > It appears the pairs of wheels are revolving around an axis at the
> > centre
> > > of
> > > > the car body, and the car body is spinning in the opposite direction
> (I
> > > > guess it's preserving linear momentum). Has anyone run into this
weird
> > > issue
> > > > (or understand why it's happening ot me)? I'm using hinge2's, and
the
> > each
> > > > wheel's joint's anchor is position at the centre of the wheel.
> > > >
> > > > _______________________________________________
> > > > ODE mailing list
> > > > ODE at q12.org
> > > > http://q12.org/mailman/listinfo/ode
> > >
> >
> > _______________________________________________
> > ODE mailing list
> > ODE at q12.org
> > http://q12.org/mailman/listinfo/ode
>
More information about the ODE
mailing list