Hi, I'd like to essentially use mujoco's collision detection to record distances between geoms. To do this, I'm setting margin=gap=<large number> for all contacts but the distances I'm seeing in d->contact.dis don't align with what I would expect. I've attached an mjcf file which reproduces the behavior. Particularly, note that when joint0 > 0.5 the distance between the geoms is recorded as <0 despite the geoms being visually far apart. When I reduce the value of margin/gap this behavior goes away. Is this expected? Is there a better way to get true distances between geoms? Edit: after some investigation it seems like this might only be a problem with cylinder-box contacts too Thanks,
Yes this calculation can produce unexpected results for some geom pair types. Intuitively you would expect the geoms to be inflated somehow, but the collision algorithms do not always work that way.