iCub Simulator: changing table friction properties

We’ve changed the surface characteristics of the table model which comes built-in with the ODE based iCub simulator. I’m sure there would be more elegant solutions, but this hack seems to suffice for our application.

Following code snippet should be inserted after the following line in the file (“iCub/main/src/simulators/iCubSimulation/odesdl/iCub_Sim.cpp”):

if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;

Code to add:

//++ Kadir && Guner
 const dReal* pos_o1;
 const dReal* pos_o2;
 if (dGeomGetClass(o1) != dPlaneClass && dGeomGetClass(o2) != dPlaneClass)
 {
     pos_o1 = dGeomGetPosition(o1);
     pos_o2 = dGeomGetPosition(o2);
 }
 bool table_collision_point = false;
 if( (fabs(pos_o1[1]-0.5) < 0.01 && fabs(pos_o1[2]-0.45) < 0.01 && fabs(pos_o1[3]) < 0.01 ) {
    // this is the table top, change the surface mu to an appropriate value
    // so that it can be used accordingly when dCollide is called
     table_collision_point = true;
 }
 else if( (fabs(pos_o2[1]-0.5) < 0.01 && fabs(pos_o2[2]-0.45) < 0.01 && fabs(pos_o2[3])< 0.01 )
 {
     // this is the table top, change the surface mu to an appropriate value
     // so that it can be used accordingly when dCollide is called
     table_collision_point = true;
 }
 dContact contact[MAX_CONTACTS]; // up to MAX_CONTACTS contacts per box-box
 for (i=0; i contact[i].surface.mode = dContactSlip1| dContactSlip2| dContactBounce | dContactSoftCFM;
 if(table_collision_point)
    contact[i].surface.mu = 10.0;
 else
    contact[i].surface.mu = dInfinity;
 contact[i].surface.mu2 = 0;
 contact[i].surface.bounce = 0.01;
 contact[i].surface.bounce_vel = 0.01;
 contact[i].surface.slip1 = (dReal)0.000001;
 contact[i].surface.slip2 = (dReal)0.000001;
 contact[i].surface.soft_cfm = 0.0001;
 }
 //-- Kadir && Guner
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s