[ODE] TriMesh

TongKe Xue tongke at gmail.com
Wed Aug 17 14:30:02 MST 2005


Hi,

  I have this serpentine robot I'm simulating in ODE. It's just a
bunch of boxes connected together by hinges. I'm having some problems
with having it stay on tri-meshes (as opposed to falling through).

My nearCallbackk looks like:

void nearCallback (void *data, dGeomID o1, dGeomID o2)
{
  int i,n;

  dBodyID b1 = dGeomGetBody(o1);
  dBodyID b2 = dGeomGetBody(o2);

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

  const int N = 10;
  dContact contact[N];
  n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
  if (n > 0) {
    for (i=0; i<n; i++) {
      contact[i].surface.mode = dContactSoftERP | dContactSoftCFM|
dContactApprox1;
      //contact[i].surface.mode = dContactSlip1 | dContactSlip2 |
dContactSoftERP | dContactSoftCFM| dContactApprox1;
      contact[i].surface.mu = dInfinity;
      contact[i].surface.soft_erp = 0.2;
      contact[i].surface.soft_cfm = 0.001;
      contact[i].surface.bounce = 0.01;
      dJointID c = dJointCreateContact (G_simul_world,
G_simul_contactgroup, contact+i);
      dJointAttach (c,b1,b2);
    }
  }
}


  What works:
    * snake robot does NOT fall through the floor (dPlane)
    * snake robot does NOt fall through boxes (dBox)

  However, now that I play with tri-meshes, I have the following problem:
    * in some positions (like 0, 0, 0) if I drop the snake, it lands
      on the trimesh, takes it's contour, and everything is good.
    * however, if I move the tri-mesh around a bit, using
      dGeomSetPosition, the snake will fall right through the trimesh

  The entire trimesh is constructed in the same way, as follows:

  for(int i=0; i<width; ++i)
    for(int j=0; j<length; ++j)
      locs[i][j] = some_random_value();
  smooth(locs, window, iterations);

  for(int i=0; i<width; ++i)
    for(int j=0; j<length; ++j) {
      vertex[i*length+j][0]=i;
      vertex[i*length+j][1]=j;
      vertex[i*length+j][2]=locs[i][j];
    }

  // and then I construct triangles for the following pairs:

  (i, j) (i, j+1), (i+1, j)
     and
  (i+1, j) (i, j+1), (i+1, j+1)

  for i<width-1; j<length-1;

  // basically, I create a grid, and chop each square into two
  // triangles

  this Trimesh also displays properly in ODE

  things I've tried:
  * tuning the step size down to 0.001 (for time step size)
  * tuning the CFM down to 0.000001

  neither of which helped



  Any ideas what might be going on?

Thanks,
--TongKe



More information about the ODE mailing list