[ODE] more newbie help

Ian McMeans imcmeans at telus.net
Wed Mar 31 18:54:03 MST 2004


Hi, I recently sent a question to this mailing list, and thanks for your
help, Cristian. Firstly, a small question: does the debug build of ODE only
prevent errors in ODE itself, or does it show me errors that I cause?

 I've got a new problem - it's for the same project as the last one. For a
while I had the wheels showing up properly for my car (my last problem was
solved), but now dSpaceCollide is freezing (the function doesn't return, and
it takes 100 CPU. It doesn't even call my callback!).

Is there another resource besides the opende.sf.net user guide? I read over
that, but obviously haven't learned enough about how to use ode. Maybe I
just need to read it again (and the example source code). I tried to model
by code after the test_buggy.cpp, but using spaces instead of geom groups.

I have the ground plane initialized like this:
dGeomID ground = dCreatePlane(world_space, 0, 0, 1, 0);

As you can see, the ground plane is in the world_space, the car gets its own
car_space. (Is there a default global space 0 that objects can be put into,
or must you create your own?)

Car::Car(dWorldID world, dSpaceID world_space, Vector3d initialPos)
{
 car_space = dSimpleSpaceCreate(world_space);

 // create the masses that we attach to the body and wheels
 dMass bodyMass, wheelMass;
 dMassSetBoxTotal(&bodyMass, 1000, 2 * wheelOffset.X(), 2 * wheelOffset.Y(),
2 * wheelOffset.Z());
 dMassSetCylinderTotal(&wheelMass, 100, 1, 0.2, 0.1);

 // create the car body
 body = dBodyCreate(world);
 dBodySetPosition(body, initialPos.X(), initialPos.Y(), initialPos.Z());
 dBodySetMass(body, &bodyMass);

 // the car geometry
 dGeomID box = dCreateBox(car_space,0.5, 0.2, 1);
 dGeomSetBody(box, body);

 for (int wheel = 0; wheel < 4; wheel++)
 {
  wheels[wheel] = dBodyCreate(world);
  dBodySetMass(wheels[wheel], &wheelMass);

  dGeomID cylinder = dCreateCCylinder(car_space, wheelOffset.X()/2.0,
wheelOffset.X()/4.0);
  dGeomSetBody(cylinder, wheels[wheel]);
  dSpaceAdd(car_space, cylinder);

  dBodySetPosition(wheels[wheel], x, y, z);  // we have the wheel right on
the hinge2 anchor

  shocks[wheel] = dJointCreateHinge2(world, 0);

  dJointAttach(shocks[wheel], body, wheels[wheel]);

  dJointSetHinge2Anchor(shocks[wheel], x, y, z);
  dJointSetHinge2Axis1(shocks[wheel], 0, 1, 0);
  dJointSetHinge2Axis2(shocks[wheel], 1, 0, 0);
 }
}

Am I calling functions in the wrong order again? I don't think I've changed
the above code significantly since it was last working (when I had fixed the
prior problem), but obviously something is going wrong :/

Here is the physics code (called each frame):
dSpaceCollide(world_space, this, onNear);
dWorldStep(world, deltaTime);
dJointGroupEmpty(contactGroup);

Where "this" refers to my physics class (passed as user data), and onNear is
my callback function which is almost exactly like the one in test_buggy.cpp.
I'm quite certain the problem isn't in onNear, since it's never even being
called. I hope the error is in the code I've posted in this message, since
I've posted everything that is put in world_space.



More information about the ODE mailing list