File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
robot_descriptions/loaders Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
7
7
### Added
8
8
9
9
- Description: UFACTORY xArm7 (MJCF) (thanks to @kevinzakka )
10
+ - Description: accept variant keyword for mujoco loader (thanks to @fabinsch )
10
11
11
12
### Changed
12
13
Original file line number Diff line number Diff line change 17
17
def load_robot_description (
18
18
description_name : str ,
19
19
commit : Optional [str ] = None ,
20
+ variant : Optional [str ] = None ,
20
21
) -> mujoco .MjModel :
21
22
"""Load a robot description in MuJoCo.
22
23
23
24
Args:
24
25
description_name: Name of the robot description.
25
26
commit: If specified, check out that commit from the cloned robot
26
27
description repository.
28
+ variant: If specified, load a specific variant of the robot model.
27
29
28
30
Returns:
29
31
Robot model for MuJoCo.
@@ -36,4 +38,19 @@ def load_robot_description(
36
38
if not hasattr (module , "MJCF_PATH" ):
37
39
raise ValueError (f"{ description_name } is not an MJCF description" )
38
40
39
- return mujoco .MjModel .from_xml_path (module .MJCF_PATH )
41
+ def load_model_from_path (path ):
42
+ try :
43
+ return mujoco .MjModel .from_xml_path (path )
44
+ except ValueError :
45
+ print (f"{ path } not found. Loading default robot model." )
46
+ return None
47
+
48
+ model_path = module .MJCF_PATH
49
+ if variant is not None :
50
+ path_parts = model_path .split (os .sep )
51
+ path_parts [- 1 ] = f"{ variant } .xml"
52
+ variant_path = os .sep .join (path_parts )
53
+ model = load_model_from_path (variant_path )
54
+ if model :
55
+ return model
56
+ return load_model_from_path (model_path )
You can’t perform that action at this time.
0 commit comments