How to reset one particular object's state at runtime using the Python API #367
-
Dear MuJoCo developers, Currently, my use case involves resetting an object's pose wrt the world frame at runtime. The rationale for doing this is that the object is manipulated by a robotic manipulator, whose states should be preserved after every manipulation, whereas if we could reset only the object's states (pose to be accurate), we could avoid rerun the simulation and wait for the robot to get prepared, which is a tedious process. In other words, this means the object can suddenly move from one pose to another across the rendered scene. I wonder if it is possible to do this using MuJoCo's Python API. A simplified code snippet I used for now looks like this:
But unfortunately, this code cannot move the object to the Thank you for your insights in advance, and I am willing to provide more details if necessary. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
If I understand you correctly, the feature you are looking for is called mocap bodies. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your insight @yuvaltassa! Following the mocap bodies topic, I eventually found the solution suitable for my use case despite that it is not relevant to mocap in the end. The "... second regular body and connect it to the mocap body with a weld equality constraint" inspired me to create a fixed body in the world and use that as an anchor of the operational body, such that by dynamically disabling the weld constraint, I could move the later with a robot, whereas by enabling that, the later will rapidly go back to the original pose defined by the anchor body. Hereby I include some code that hopefully could be helpful for those who come across a similar problem: The XML file:
The Python code:
Some comments about the above code:
|
Beta Was this translation helpful? Give feedback.
Thank you for your insight @yuvaltassa! Following the mocap bodies topic, I eventually found the solution suitable for my use case despite that it is not relevant to mocap in the end.
The "... second regular body and connect it to the mocap body with a weld equality constraint" inspired me to create a fixed body in the world and use that as an anchor of the operational body, such that by dynamically disabling the weld constraint, I could move the later with a robot, whereas by enabling that, the later will rapidly go back to the original pose defined by the anchor body.
Hereby I include some code that hopefully could be helpful for those who come across a similar problem:
The XML file: