Skip to content

Commit

Permalink
Address suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Ferigo <[email protected]>
  • Loading branch information
flferretti and diegoferigo committed Sep 25, 2024
1 parent b92813f commit 24e91a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/jaxsim/mujoco/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ def convert(
# Get the ROD model.
rod_model = load_rod_model(
model_description=urdf,
is_urdf=True,
model_name=model_name,
)

Expand Down Expand Up @@ -604,6 +605,7 @@ def convert(
# Get the ROD model.
rod_model = load_rod_model(
model_description=sdf,
is_urdf=False,
model_name=model_name,
)

Expand Down
16 changes: 8 additions & 8 deletions src/jaxsim/parsers/rod/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SDFData(NamedTuple):


def extract_model_data(
model_description: pathlib.Path | str | rod.Model,
model_description: pathlib.Path | str | rod.Model | rod.Sdf,
model_name: str | None = None,
is_urdf: bool | None = None,
) -> SDFData:
Expand All @@ -56,13 +56,13 @@ def extract_model_data(
match model_description:
case rod.Model():
sdf_model = model_description
case rod.Sdf(None):
sdf_model = model_description.model
case str() | pathlib.Path():
# Parse the SDF resource.
sdf_element = rod.Sdf.load(sdf=model_description, is_urdf=is_urdf)

if len(sdf_element.models()) == 0:
case rod.Sdf() | str() | pathlib.Path():
sdf_element = (
model_description
if isinstance(model_description, rod.Sdf)
else rod.Sdf.load(sdf=model_description, is_urdf=is_urdf)
)
if not sdf_element.models():
raise RuntimeError("Failed to find any model in SDF resource")

# Assume the SDF resource has only one model, or the desired model name is given.
Expand Down

0 comments on commit 24e91a7

Please sign in to comment.