google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
7.56k stars 747 forks source link

model grasping of a cable #1338

Open giorgionicola opened 6 months ago

giorgionicola commented 6 months ago

Hi,

I'm a researcher and I'm trying to use MuJoCo to simulate the manipulation of elastic cables.

I'm looking for some help with constraining one body element of the cable to the gripper. Specifically, I have modeled the elastic cable as a series of body with connected with joints and springs and I would like to constrain online with a "weld" equality one of the bodies to my gripper. Before the beginning of the simulation, I suppose that I do not know which element of cable is going to be attached to the gripper.

I cannot understand if equalities can be added online by python bindings. If it is not possible, which solution do you suggest to me?

  1. Create weld constraint between each cable element and the gripper, set them as inactive at the start of the simulation and programmatically activate them
  2. Use the ⁠adhesion actuator; however, I am not sure how to avoid multiple cable elements attaching. I am not sure using groups is going to work
quagla commented 5 months ago

You can't add equalities but you might be able to change the eq_ fields in https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/mjmodel.h#L948 such that your weld changes meaning. See https://github.com/google-deepmind/mujoco/blob/main/src/engine/engine_setconst.c#L272 for the meaning of those fields.