Skip to content

Commit

Permalink
format correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
fabinsch committed Apr 22, 2024
1 parent f3cdb4d commit 029218c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions robot_descriptions/loaders/mujoco.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,20 @@ def load_robot_description(
os.environ.pop("ROBOT_DESCRIPTION_COMMIT", None)
if not hasattr(module, "MJCF_PATH"):
raise ValueError(f"{description_name} is not an MJCF description")

def load_model_from_path(path):
try:
return mujoco.MjModel.from_xml_path(path)
except ValueError:
print(f"{path} not found. Loading default robot model.")
return None

model_path = module.MJCF_PATH
if variant is not None:
path_parts = model_path.split(os.sep)
path_parts[-1] = f"{variant}.xml"
variant_path = os.sep.join(path_parts)
model = load_model_from_path(variant_path)
if model:
if model:
return model
return load_model_from_path(model_path)
return load_model_from_path(model_path)

0 comments on commit 029218c

Please sign in to comment.