File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
python/ext_examples/mujoco Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ from pathlib import Path
2+ from robot_descriptions .robotiq_2f85_mj_description import PACKAGE_PATH
3+ from mujoco_xml_editor import MujocoXmlEditor
4+ import mujoco
5+
6+ hand_xml_path = Path (PACKAGE_PATH ) / "2f85.xml"
7+ editor = MujocoXmlEditor .load (hand_xml_path )
8+ xmlstr = editor .to_string ()
9+ model = mujoco .MjModel .from_xml_string (xmlstr )
10+
11+ # The goal is finding a right follower geom index
12+ # The right follower geom is included in "right_follower" body
13+
14+ body_id = mujoco .mj_name2id (model , mujoco .mjtObj .mjOBJ_BODY , "right_follower" )
15+ assert body_id != - 1
16+ assert mujoco .mj_id2name (model , mujoco .mjtObj .mjOBJ_BODY , body_id ) == "right_follower"
17+
18+ start_geom_addr = model .body_geomadr [body_id ]
19+ assert start_geom_addr != - 1
20+ geom_count = model .body_geomnum [body_id ]
21+
22+ collision_geom_idx = None
23+ for i in range (geom_count ):
24+ geom_id = start_geom_addr + i
25+ group = model .geom_group [geom_id ]
26+ # group == 2 for visual, 3 for collision
27+ if group == 3 :
28+ collision_geom_id = geom_id
29+ break
30+ print (f"Collision geom id: { collision_geom_id } " )
31+
You can’t perform that action at this time.
0 commit comments