[ODE] Collision problem with geomGroups

Laury MICHEL laury.michel at free.fr
Sun Nov 17 17:42:02 2002


Hello!

I'm quite new to ODE, but I did a little "buggy-like" program that works!
The problem is that when I want to use a geomGroup for my buggy, it does not
collide with the "world geometry" anymore...
My "world geometry" consists of a large box with a smaller rotated box in
the middle playing the role of a ramp...
The buggy geometry is created in space 0 then added to a geomGroup wich is
created in the same space as the world geometry.
But, when running the program the buggy falls through the "world"!
Before, without geomGroups, it worked well beside the fact that I couldn't
put the vehicle wheels too close from the chassis as they collided resulting
in strange behavior as soon as the sim started...
I'm using ode v0.03, I've read the doc and I think I understood the part on
geomGroups so I don't see what I've missed :-(

Please help!
Here is part of the code I use:

void odeBox::InitOde(dWorldID _worldID, dSpaceID _spaceID, dReal _fMass)
{
m_bodyID = dBodyCreate(_worldID);
dBodySetPosition(m_bodyID, 0, 0, 0);
const dReal fDensity = 1.0f;
dMassSetBox(&m_mass, fDensity, m_fLength, m_fWidth, m_fHeight);
dMassAdjust (&m_mass, _fMass);
dBodySetMass(m_bodyID, &m_mass);
m_geomID = dCreateBox(_spaceID, m_fLength, m_fWidth, m_fHeight);
dGeomSetBody(m_geomID, m_bodyID);
}

void odeCar::CreateChassis(float _fWidth, float _fLength, float _fHeight)
{
m_geomGroupID = dCreateGeomGroup (m_spaceID);
m_pChassis = new odeBox;
dReal fMass = 10.0f;
((odeBox*) m_pChassis)->InitBox(_fWidth, _fLength, _fHeight);
m_pChassis->InitOde(m_worldID, 0, fMass); // 0 for space as it is added to a
geomGroup
m_pChassis->SetPosition(5,0,35);
dGeomGroupAdd (m_geomGroupID, m_pChassis->GetGeomID());
}

void odeWheel::InitOde(dWorldID _worldID, dSpaceID _spaceID, dReal _fMass)
{
m_bodyID = dBodyCreate(_worldID);
dBodySetPosition(m_bodyID, 0, 0, 0);
const dReal fDensity = 1.0f;
dMassSetSphere(&m_mass, fDensity, m_fRadius);
dMassAdjust (&m_mass, _fMass);
dBodySetMass(m_bodyID, &m_mass);
m_geomID = dCreateSphere(_spaceID, m_fRadius);
dGeomSetBody(m_geomID, m_bodyID);
}

void odeCar::AddWheel(dReal _posX, dReal _posY, dReal _posZ, float _fRadius,
float _fWidth)
{
// odeWheel
odeWheel* pWheel = new odeWheel;
pWheel->InitWheel(_fRadius, _fWidth);
pWheel->InitOde(m_worldID, 0, m_fDefaultWheelMass); // 0 for space as it is
added to a geomGroup

const dReal *a = dBodyGetPosition(m_pChassis->GetBodyID());
dBodySetPosition(pWheel->GetBodyID(), a[0] + _posX, a[1] + _posY, a[2] +
_posZ);
m_vpWheel.push_back(pWheel);

// Joint
dJointID jointID = dJointCreateHinge2(m_worldID, 0);
dJointAttach(jointID, m_pChassis->GetBodyID(), pWheel->GetBodyID());
dJointSetHinge2Anchor(jointID, a[0] + _posX, a[1] + _posY, a[2] + _posZ);
dJointSetHinge2Axis1(jointID, 0, 0, 1);
dJointSetHinge2Axis2(jointID, 1, 0, 0);
dJointSetHinge2Param(jointID, dParamSuspensionERP, 0.6f);
dJointSetHinge2Param(jointID, dParamSuspensionCFM, 0.08f);
dJointSetHinge2Param(jointID, dParamLoStop, 0);
dJointSetHinge2Param(jointID, dParamHiStop, 0);
m_vJoint.push_back(jointID);
m_vPowered.push_back(false);
m_vSteered.push_back(false);

dGeomGroupAdd (m_geomGroupID, pWheel->GetGeomID());
}