[ODE] Re: nearCallback

Daniel Marbach daniel.marbach at epfl.ch
Sat Nov 13 13:07:24 MST 2004


> What nearCallback do and what can I do with nearCallback?
> The nearCallback is just to calculate the collision?

Refer to the ode user guide, section 10:
http://ode.org/ode-latest-userguide.html#sec_10_0_0

Actually I also have some questions about spaces / collisions. Newbies always
ask the same questions - we should improve the doc or put some more advice
somewhere in the Wiki area (since I'm not 100% sure if what I'm doing is right I
can't do that...). My questions:

1. I have several modular robots, each one consisting of dozens of modules. They
are for the moment just on a flat environment (a plane). I
created a 'global' hash space. Then I inserted a hash space for each robot into
this 'global' space. Is that good? Or do you recommend a Quadtree spaces?

2. I have no clue what are good parameters for a multi-resolution hash space
(obviously this depends on the application, but how can I guess what might be
good?) - so far I just created the spaces without setting any levels.

3. What is a good value for the maximum number of contact points in the
nearCallback? I think there was a discussion on this but I don't find it anymore
in the archives. I remember that somebody said that it is good to generate a lot
of contacts (how many exactly? 10? 100?) and to sort them, creating contact
joints only for the most important ones. But which ones are important? Can't I
expect ODE to give me 'important' ones if I request very few (e.g. 3)? If
somebody could post / send me the code of this 'sorting' function that would be
very nice.

4. Is the following nearCallback OK? It should collide everything except for
bodies that are connected by a joint.


void nearCallback(void *data, dGeomID o1, dGeomID o2) {
  if (dGeomIsSpace(o1) || dGeomIsSpace(o2)) {
    // colliding a space with something
    dSpaceCollide2(o1, o2, data, &nearCallback);
    // collide all geoms internal to the space(s)
    if (dGeomIsSpace(o1))
      dSpaceCollide((dSpaceID)o1, data, &nearCallback);
    if (dGeomIsSpace(o2))
      dSpaceCollide((dSpaceID)o2, data, &nearCallback);

  // don't generate contact points if the two bodies are connected by a joint
  } else if (not dAreConnected(dGeomGetBody(o1), dGeomGetBody(o2))) {
    // Maximum number of contact points to generate
    const int N = 10; // ???
    dContact contact[N];
    // n is the number of contact points that has actually been generated
    int n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));

    for (int i=0; i<n; i++) {
      contact[i].surface.mode = dContactApprox1;
      contact[i].surface.mu = 0.3; // ???
      dJointID c = dJointCreateContact(world, contactGroup, &contact[i]);
      dJointAttach (c, dGeomGetBody(contact[i].geom.g1),
dGeomGetBody(contact[i].geom.g2));
    }
  }
}


Thanks in advance!

   Daniel

----------------------------------------
Daniel Marbach
Bitziusstr. 9
CH-3006 Bern

Tel: 031 351 11 09
WWW: http://icwww.epfl.ch/~marbach/
----------------------------------------


More information about the ODE mailing list