Contacts seemingly not recorded?

Discussion in 'Support requests' started by Maxx, May 8, 2020.

  1. Hi,

    I am working with mujoco-py and OpenAI gym's FetchPickAndPlace environment [1] (meaning there is a robotic arm with two gripper fingers and a cubic object to be manipulated). I know very little about physics simulation, so please bear with me.

    I am trying to understand a weird behavior I observed related to the array of detected contacts: the object is moving between two simulation steps, but there is no contact in the array between the gripper fingers and the object (the only contact is between object and table).
    As far as I can tell, there is no other force involved that could have moved the object. Also, if I explicitly disable the contact using

    <exclude body1="robot0:r_gripper_finger_link" body2="object0"></exclude>
    <exclude body1="robot0:l_gripper_finger_link" body2="object0"></exclude>

    the object is not moved, indicating that there actually is contact between fingers and object, it is just not exposed.

    So my question is, is it possible for a contact to occur or to create a force on an object without a corresponding entry being placed into the array?

    Thanks a lot!

  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    All contacts are in If a contact is not there, it cannot generate force. How do you know the contacts are not there? The number of contacts after each step is given by mjData.ncon. The first ncon positions in the contact array are then used.
  3. Hi,

    yes, this is what I figured as well, which is why I am suspecting a bug or maybe a numerical issue.
    I know that the contacts are not there because I am checking the array (only the first ncon entries) after the step the movement occurs and no contact between fingers and object shows up (but other kinds of contacts do).

    I can provide you with screenshots, but I don't know if this is very helpful. Do you have any ideas how to diagnose or debug the issue further?

    Interestingly, this user in the following thread seems to have a similar problem:
  4. Vikash Kumar

    Vikash Kumar Staff Member

    Forces can't be produced without contacts. Few things that I'd recommend checking
    1) Is the simulation starting with colliding-bodies in penetration?
    2) Check all contacts with objects0 to ensure that it's not some other body it's colliding with.
    3) "the object is moving between two simulation steps, but there is no contact in the array between the gripper fingers and the object"-- the object doesn't need to have a contact for it to keep moving i.e. if the object has an initial velocity, it will keep moving even if there is no contact (hope I am not misunderstanding your point here)​
  5. Hi,

    I found my problem! This particular environment is run by mujoco-py with substeps, so for each step that is exposed to the outside, there are actually several Mujoco simulation steps internally. This means that the contacts array will only contain contacts of the last substep, and this way it looked to me that there was no contact, but the object was moving.

    For anyone stumbling on this thread, you can access the contacts from the substeps by registering a C-function as a substep_callback on the MjSim object that stores the contacts in the userdata array. It's a little tricky to get it to work, but doable.

    Thank you for your help! You were of course right that without contact, there is no force.