[ODE] My rays don't want to stay
Frugier Kevin
Kevin.Frugier at insa-lyon.fr
Thu Oct 21 10:59:54 MST 2004
Hello there,
I'm a programming a robot simulation.
My robot has 8 sensors.
For each sensor I create a ray like this :
sensors_bodies[i] = dBodyCreate (world); //this is only a body but
i'll use it for the drawing stuff of the sensor's box
dMassSetBoxTotal (&m, SENSOR_MASS,SENSOR_SIZE,
SENSOR_SIZE,SENSOR_SIZE);
dBodySetMass (sensors_bodies[i],&m);
sensors_geom[i] = dCreateRay (space, 2*BOX_SIZE); //here i create it
sensors_distance[i]=2*BOX_SIZE;
dGeomSetBody (sensors_geom[i],sensors_bodies[i]); //i attach my ray
to the sensor's body
Then I put my ray in the good position and direction :
For exemple the first :
dGeomRaySet
(sensors_geom[i],1.5*SENSOR_SIZE,KHEP_RADIUS-1.5*SENSOR_SIZE,WHEEL_RADIUS+KHEP_HEIGHT+SENSOR_SIZE,0,1,0);
And to finish I attach the sensor to my robot's body, because the
sensors move and turn with it...
sensors_joint[i] = dJointCreateFixed (world,0);
dJointAttach (sensors_joint[i],khep_bodies[0],sensors_bodies[i]);
dJointSetFixed (sensors_joint[i]);
In my NearCallback i look at what my sensor's see :
for (unsigned int i=0; i<8; i++)
{
if ((o1 == sensors_geom[i])||(o2 == sensors_geom[i]))
{
dContact contact;
n = dCollide (o1,o2,1,&contact.geom,sizeof(dContact));
if (n == 1)
{
sensors_distance[i]=contact.geom.depth;
}
return;
}
}
For the first Time Step everything is ok !
But At the second, my rays have ALL changed there orientation : they all
look UP. (Z axis)
So the sensors don't see anything anymore....except the beauty of the sky.
I think my mistake is easy to find but this is the first time i use rays
so maybe i don't understand everything.
Thanks a lot for your (coming) answers
Kevin
More information about the ODE
mailing list