Allowing Base Motion with Mocap Weld-Constrained Arms #2635
-
IntroHi! I am a Lead ML Engineer at ArenaX Lab., I use MuJoCo for my research on robotics manipulation control using reinforcement learning. My setupMuJoCo 3.1.6 My questionI have a robot model with a mobile base (driven by three wheel motors) and two 7-DOF arms. The end-effectors are controlled using mocap bodies with weld equality constraints, following the approach used in Gymnasium-Robotics' FetchEnv. However, when I move the mobile base, the arms remain pinned in place rather than moving with the base, due to the weld constraints. To address this, I temporarily deactivate the welds during base movement and reactivate them afterward. While this partially resolves the issue, it’s not fully reliable. I also tried using an IK controller to update the mocap targets, but that didn’t work. Is there a more robust or efficient way to support mobile base movement while maintaining mocap-based end-effector control? Minimal model and/or code that explain my questionIf you encountered the issue in a complex model, please simplify it as much as possible (while still reproducing the issue). Model: minimal XML<mujoco>
<include file="robot.xml" />
<include file="shared.xml" />
<worldbody>
<body mocap="true" name="l_arm_mocap" pos="0.01831491 0.3605796 0.38745686"
quat="-0.13003985 0.98767075 -0.08640984 0.01137859">
<geom conaffinity="0" contype="0" pos="0 0 0" rgba="0 0.5 0 0.7"
size="0.005 0.005 0.005" type="box"></geom>
<geom conaffinity="0" contype="0" pos="0 0 0" rgba="0 0.5 0 0" size="0.005 0.005 0.005"
type="box"></geom>
<geom conaffinity="0" contype="0" pos="0 0 0" rgba="0 0.5 0 0" size="0.005 0.005 0.005"
type="box"></geom>
<geom conaffinity="0" contype="0" pos="0 0 0" rgba="0 0.5 0 0" size="0.005 0.005 0.005"
type="box"></geom>
</body>
<body mocap="true" name="r_arm_mocap" pos="0.01831507 -0.36058052 0.38745713"
quat="0.13001045 0.98767462 0.08641017 0.01137606">
<geom conaffinity="0" contype="0" pos="0 0 0" rgba="0 0.5 0 0.7"
size="0.005 0.005 0.005" type="box"></geom>
<geom conaffinity="0" contype="0" pos="0 0 0" rgba="0 0.5 0 0" size="0.005 0.005 0.005"
type="box"></geom>
<geom conaffinity="0" contype="0" pos="0 0 0" rgba="0 0.5 0 0" size="0.005 0.005 0.005"
type="box"></geom>
<geom conaffinity="0" contype="0" pos="0 0 0" rgba="0 0.5 0 0" size="0.005 0.005 0.005"
type="box"></geom>
</body>
</worldbody>
<equality>
<weld body1="l_arm_mocap" body2="l_wrist_out_link" solimp="0.95 0.99 0.001"
solref="0.01 1"></weld>
<weld body1="r_arm_mocap" body2="r_wrist_out_link" solimp="0.95 0.99 0.001"
solref="0.01 1"></weld>
</equality>
</mujoco>
Code: import mujoco
model = mujoco.MjModel.from_xml_string(xml)
data = mujoco.MjData(model)
def _step_action(self, action):
action = np.clip(action, -1.0, 1.0)
# Mobile base
mobile_base_action = action[:3]
if any(mobile_base_action != 0):
self.data.eq_active[-2:] = 0
mujoco_utils.reset_mocap_welds(self.model, self.data)
mujoco.mj_forward(self.model, self.data)
self.mobile_base.move(mobile_base_action)
mujoco.mj_step(self.model, self.data, nstep=200)
mujoco_utils.reset_mocap2body_xpos(self.model, self.data)
reset_mocapbody2body_xpos(self.model, self.data)
self.data.eq_active[-2:] = 1
mujoco.mj_forward(self.model, self.data)
l_delta_pos = action[3:6] * 0.01
l_delta_euler = action[6:9] * 5 # between -5 and 5 degrees
l_gripper_cmd = action[9]
l_mocap_quat = self.data.mocap_quat[self.l_gripper_mocap_id]
l_mocap_quat = rotate_quaternion(l_mocap_quat, [1, 0, 0], l_delta_euler[0])
l_mocap_quat = rotate_quaternion(l_mocap_quat, [0, 1, 0], l_delta_euler[1])
l_mocap_quat = rotate_quaternion(l_mocap_quat, [0, 0, 1], l_delta_euler[2])
mujoco_utils.reset_mocap2body_xpos(self.model, self.data)
self.data.mocap_pos[self.l_gripper_mocap_id] += l_delta_pos
self.data.mocap_quat[self.l_gripper_mocap_id] = l_mocap_quat
# Do the same for right arm
mujoco.mj_step(self.model, self.data, nstep=self.frame_skip)
if self.render_mode == "human":
self.render()
return self._get_obs() Confirmations
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi @matinmoezzi, if it helps you can check out the mobile manipulator example in the mink library. |
Beta Was this translation helpful? Give feedback.
Hi @matinmoezzi, if it helps you can check out the mobile manipulator example in the mink library.