openai / mujoco-py

MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3.
Other
2.89k stars 813 forks source link

Apply external forces to the model. #535

Open daichi-3110 opened 4 years ago

daichi-3110 commented 4 years ago

Hello.

I want to apply external forces to the model. Is there a way to apply an external force to the model?

kevincheng3 commented 4 years ago

add actuator/motor

mfogelson commented 3 years ago

You can also set sim.data.xfrc_applied or sim.data.qfrc_applied xfrc_applied is (nbody, 6) 3D force and 3D torque qfrc_applied is (nv, 6) 3D force and 3D torque applied at generalized position

To set these variables you need to update the matrix values since they are not explicitly writeable: sim.data.xfrc_applied[:] = new_xfrc # Or something like that

I hope this helps

justinberi commented 3 years ago

For xfrc_applied where is the force applied?

Ie center of mass? or at some other position?

efahnestock commented 3 years ago

Based on this, xfrc_applied is applied at the center of mass for the body.

fcycq commented 1 month ago

If you want to apply force on object in a short time, just add it to data->xfrc_applied, this work on next step only, xfrc_applied() will apply the force forever.