Skip to content

Commit c247142

Browse files
committed
fix(sim): tcp offset in robot mjcf
1 parent 58cd587 commit c247142

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

assets/fr3/mjcf/fr3_0.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<mujoco>
2+
<!-- custom tcp offset -->
3+
<custom>
4+
<numeric name="tcp_offset_translation" data="0.0 0.0 0.1034"/>
5+
<!-- rotation matrix is row major -->
6+
<numeric name="tcp_offset_rotation_matrix" data="0.707 0.707 0 -0.707 0.707 0 0 0 1"/>
7+
</custom>
28
<default>
39
<default class="fr3">
410
<joint armature="0.1" damping="1"/>

assets/fr3/mjcf/fr3_unnamed.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<mujoco>
2+
<!-- custom tcp offset -->
3+
<custom>
4+
<numeric name="tcp_offset_translation" data="0.0 0.0 0.1034"/>
5+
<!-- rotation matrix is row major -->
6+
<numeric name="tcp_offset_rotation_matrix" data="0.707 0.707 0 -0.707 0.707 0 0 0 1"/>
7+
</custom>
28
<default>
39
<default class="fr3">
410
<joint armature="0.1" damping="1"/>

python/rcs/envs/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ def get_tcp_offset(mjcf: str | Path) -> rcs.common.Pose:
8888
elif mjcf.suffix == ".mjb":
8989
model = mj.MjModel.from_binary_path(str(mjcf))
9090
else:
91-
msg = f"Expected .mjb, .mjcf or.xml, got {mjcf.suffix}"
91+
msg = f"Expected .mjb, .mjcf or.xml, got {mjcf.suffix} and {mjcf}"
9292
raise AssertionError(msg)
9393
try:
94-
tcp_offset = np.array(model.numeric("tcp_offset").data)
95-
pose_offset = rcs.common.Pose(translation=tcp_offset)
96-
return pose_offset
94+
tcp_offset_translation = np.array(model.numeric("tcp_offset_translation").data)
95+
tcp_offset_rotation_matrix = np.array(model.numeric("tcp_offset_rotation_matrix").data)
96+
return rcs.common.Pose(
97+
translation=tcp_offset_translation, rotation=tcp_offset_rotation_matrix.reshape((3, 3))
98+
) # type: ignore
9799
except KeyError:
98100
msg = "No tcp offset found in the model. Using the default tcp offset."
99101
logging.info(msg)

0 commit comments

Comments
 (0)