Forces on an Object

Discussion in 'Simulation' started by Karthik, Nov 22, 2016.

  1. Hello,

    I am new to MuJoCo. I would like to analyze the forces on an Object placed on a plane when an external force is applied to it. By reading the documentation, I figured out that we can use xfrc_applied to do that. But, I don't know how to apply it to the specified object. I have also uploaded a xml file of the scene with a plane and an object. I need to apply a external force on it or move it by some distance and analyze the forces on it from mjData.
     

    Attached Files:

  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    First you need to find the integer id of the body you want to apply forces to. The ids correspond to the order in which the bodies appear in the XML, with the world being 0. You could also use the name2id function. Suppose the body id is n. The force and torque corresponding to that body are in xfrc_applied[6*n] ... xfrc_applied[6*n+5]. The first three numbers are the force, followed by the torque you want to apply.