Setting model state in Unity #137
-
Hello, I'm taking a look at the new Unity plug-in and I'm really excited to apply it to a ML Agents learning environment. Between episodes I'd like to reset the model to a state determined by a Unity MonoBehaviour. I'd like to set the root position and each joints rotation, as well as linear and angular velocities. This would have to be with a "Teleporting" method if possible (to avoid spikes in velocity/momentum). Previously I had a setup like this with Unity ArticulationBodies. What is the right way to do this with the MuJoCo API with the Unity Plug-in? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can set the MuJoCo state (e.g., You can see an example of this workflow in |
Beta Was this translation helpful? Give feedback.
You can set the MuJoCo state (e.g.,
data->qpos
for root position and joint angles, anddata->qvel
for respective velocities) at any stage. In order to force Unity to sync to the new state, first callmj_kinematics(model, data)
(to update e.g.,data->xpos
according to the newqpos
) and thenMjScene.SyncUnityToMjState()
(to update Unity transforms according to the newxpos
).You can see an example of this workflow in
MjScene.RecreateScene()
.