File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
robot_descriptions/loaders Expand file tree Collapse file tree 2 files changed +18
-2
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.
77### Added
88
99- Description: UFACTORY xArm7 (MJCF) (thanks to @kevinzakka )
10+ - Description: accept variant keyword for mujoco loader (thanks to @fabinsch )
1011
1112### Changed
1213
Original file line number Diff line number Diff line change 1717def load_robot_description (
1818 description_name : str ,
1919 commit : Optional [str ] = None ,
20+ variant : Optional [str ] = "scene" ,
2021) -> mujoco .MjModel :
2122 """Load a robot description in MuJoCo.
2223
@@ -35,5 +36,19 @@ def load_robot_description(
3536 os .environ .pop ("ROBOT_DESCRIPTION_COMMIT" , None )
3637 if not hasattr (module , "MJCF_PATH" ):
3738 raise ValueError (f"{ description_name } is not an MJCF description" )
38-
39- return mujoco .MjModel .from_xml_path (module .MJCF_PATH )
39+
40+ def load_model_from_path (path ):
41+ try :
42+ return mujoco .MjModel .from_xml_path (path )
43+ except ValueError :
44+ print (f"{ path } not found. Loading default robot model." )
45+ return None
46+ model_path = module .MJCF_PATH
47+ if variant is not None :
48+ path_parts = model_path .split (os .sep )
49+ path_parts [- 1 ] = f"{ variant } .xml"
50+ variant_path = os .sep .join (path_parts )
51+ model = load_model_from_path (variant_path )
52+ if model :
53+ return model
54+ return load_model_from_path (model_path )
You can’t perform that action at this time.
0 commit comments