Change the gravity for some bodies on the model

Discussion in 'Simulation' started by Iason S., May 4, 2018.

  1. Is it possible to change the gravity for a subset of bodies in the model?

    In particular, I want to implement some kind of gravity compensation of one robot and an easy solution is to set the gravity vector to zero. Of course, changing the physics option of the model affects the whole model, which means that if the model includes a robot and some objects on a table for example, the objects will have zero gravity as well, which is not desired. I would like to ask if it is possible in such a use case to change the gravity only partially (only for the robot). Also I want to keep the inertia properties of the robot, for simulating other external forces, besides gravity.

    From a quick search in the forum it seems that it is not possible to load multiple models in MuJoCo, which means that I cannot have multiple gravity vectors to change. Is there any other way to do the above?
     
  2. In case someone else is interested, based on this thread I can perform the gravity compensation of the robot by just adding to the commanded forces of the robot's joints of interest, the bias forces of qfrc_bias.

    Thus if I want to command a torque (or force for free joints) f_ref to the i-th joint of the model and in the same time to compensate for gravity, I can do:

    qfrc_applied(i) = qfrc_bias(i) + f_ref
     
  3. Emo Todorov

    Emo Todorov Administrator Staff Member

    Gravity is the same for all bodies. However you can add external forces to each body that compensate for gravity, using xfrc_applied.