[ODE] walking

Esra Suel esrasuel at su.sabanciuniv.edu
Wed Aug 24 19:45:20 MST 2005


Hello -I am actually new in ODE and I am trying to simulate a 4-legged robot. 
I dont even have knees, all I have is a body and 4 legs each connected to the 
body via hinge joints and I have amotors for setting the limits etc. 

But in the simulation loop I am getting some problems, all I am trying to do 
is this. First, the front-right and rear left leg should step forward. this 
should cause the body to move forward as well which I should see on the 
screen. After a few steps the front-left and rear-right leg should step 
forward. So it should be walking this way. But no. All I see is 4 legs each at 
a certain angle like the figure below, and then at the next world step, I see 
the same figure at a different x position. 
 ----- 
|     | 
 ----- 
 \    \ 
  \    \
   \    \  

here is the code i have, 
If someone could help I would be very glad. Because I am stuck. 

if (!pause) {
if (true) 

dQuaternion q1; 
dQFromAxisAndAngle (q1,0,1,0,-ANGLE); 
dGeomSetQuaternion(leg[1],q1); 


const dReal *l1 = dGeomGetPosition(leg[1]); 
dGeomSetPosition (leg[1],(l1[0] + sin(ANGLE)*L_LEG/2),l1[1],(cos(ANGLE)
*L_LEG/2)); 
dGeomSetQuaternion (leg[1],q1); 
dSpaceCollide (space,0,&nearCallback); 
dWorldStep (world,0.01); 



const dReal *l3 = dGeomGetPosition(leg[3]); 
dGeomSetPosition (leg[3],(l3[0] + sin(ANGLE)*L_LEG/2),l3[1],(cos(ANGLE)
*L_LEG/2)); 
dGeomSetQuaternion (leg[3],q1); 
dSpaceCollide (space,0,&nearCallback); 
dWorldStep (world,0.01); 



const dReal *l0 = dGeomGetPosition(leg[0]); 
dGeomSetPosition (leg[0],(l0[0] + sin(ANGLE)*L_LEG/2),l0[1],(cos(ANGLE)
*L_LEG/2)); 
dGeomSetQuaternion (leg[0],q1); 
dSpaceCollide (space,0,&nearCallback); 
dWorldStep (world,0.01); 



const dReal *l2 = dGeomGetPosition(leg[2]); 
dGeomSetPosition (leg[2],(l2[0] + sin(ANGLE)*L_LEG/2),l2[1],(cos(ANGLE)
*L_LEG/2)); 
dGeomSetQuaternion (leg[2],q1); 
dSpaceCollide (space,0,&nearCallback); 
dWorldStep (world,0.01); 

dJointGroupEmpty (contactgroup); 
} 
dReal sides_body[3] = {BODY_LENGTH,BODY_WIDTH,BODY_HEIGHT}; 

dsSetTexture (DS_WOOD); 
dsSetColor (1,1,0); 
dsDrawBox (dBodyGetPosition(body[0]),dBodyGetRotation(body[0]),sides_body); 
dsSetColor (0,1,0); 
dsDrawCappedCylinder(dBodyGetPosition(body[1]),dBodyGetRotation(body
[1]),ULEG_LENGTH,ULEG_RADIUS); 
dsSetColor (0,1,0); 
dsDrawCappedCylinder(dBodyGetPosition(body[2]),dBodyGetRotation(body
[2]),ULEG_LENGTH,ULEG_RADIUS); 
dsSetColor (0,1,0); 
dsDrawCappedCylinder(dBodyGetPosition(body[3]),dBodyGetRotation(body
[3]),ULEG_LENGTH,ULEG_RADIUS); 
dsSetColor (0,1,0); 
dsDrawCappedCylinder(dBodyGetPosition(body[4]),dBodyGetRotation(body
[4]),ULEG_LENGTH,ULEG_RADIUS); 

} 

Thank you, 
esra


More information about the ODE mailing list