Repository navigation
MuJoCo PID plugin #3592
Replies: 1 comment
|
There is a concrete naming problem in the actuator XML shown. Consequently, these actuator lookups can both return Give the actuators explicit names: <actuator>
<plugin name="index_pid" joint="J1_index"
plugin="mujoco.pid" instance="pid_index" actdim="1" />
<plugin name="medium_pid" joint="J1_medium"
plugin="mujoco.pid" instance="pid_medium" actdim="1" />
</actuator>Then use those names and check every lookup before indexing: for joint_name, actuator_name in [
("J1_index", "index_pid"),
("J1_medium", "medium_pid"),
]:
jid = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_JOINT, joint_name)
aid = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_ACTUATOR, actuator_name)
assert jid >= 0 and aid >= 0, (joint_name, jid, actuator_name, aid)
data.qpos[model.jnt_qposadr[jid]] = 0.7156 # scalar hinge joint
data.ctrl[aid] = 0.7156
mujoco.mj_forward(model, data)This fixes the control-indexing error. It doesn't by itself explain a |
Uh oh!
There was an error while loading. Please reload this page.
Intro
Hi!
I am a researcher, and I'm working to simulate the motion of the finger of an hand. I'm using the mujoco PID plugin and it works fine. However, I'm not able to initialize the 2 joints/actuators position but only one.
My setup
`
`
and this is the assignment in the Python code:
--- INDEX ---
joint_id_index = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_JOINT, 'J1_index')
qpos_idx_index = model.jnt_qposadr[joint_id_index]
act_id_index = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_ACTUATOR, "J1_index")
data.qpos[qpos_idx_index] = 0.7156
data.ctrl[act_id_index] = 0.7156
--- MEDIUM ---
joint_id_medium = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_JOINT, 'J1_medium')
qpos_idx_medium = model.jnt_qposadr[joint_id_medium]
act_id_medium = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_ACTUATOR, "J1_medium")
data.qpos[qpos_idx_medium] = 0.7156
data.ctrl[act_id_medium] = 0.7156
mujoco.mj_forward(model, data)
My question
Are there any errors during the initialization? Only one actuator initializes its position at 0.7156 rad, the other remains at 0 rad.
Thank you very much for the help!
Stefano
Minimal model and/or code that explain my question
If you encountered the issue in a complex model, please simplify it as much as possible (while still reproducing the issue).
Model:
minimal XML
Code:
Confirmations
All reactions