Weird behavior when changing margin and gap to large numbers

Discussion in 'Priority support' started by Pedro Morais, Mar 12, 2020.

  1. 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,
     

    Attached Files:

    • test.xml
      File size:
      641 bytes
      Views:
      130
    Last edited: Mar 14, 2020
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    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.