Skip to content

Commit

Permalink
Allow passing a rod.Model instead of rod.Sdf when exporting to URDF
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Feb 19, 2024
1 parent 469cdeb commit 0ce60b2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rod/urdf/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ class UrdfExporter(abc.ABC):

@staticmethod
def sdf_to_urdf_string(
sdf: rod.Sdf,
sdf: rod.Sdf | rod.Model,
pretty: bool = False,
indent: str = " ",
gazebo_preserve_fixed_joints: Union[bool, List[str]] = False,
) -> str:
# Operate on a copy of the sdf object
sdf = copy.deepcopy(sdf)

if len(sdf.models()) > 1:
if isinstance(sdf, rod.Sdf) and len(sdf.models()) > 1:
raise RuntimeError("URDF only supports one robot element")

# Get the model
model = sdf.models()[0]
model = sdf if isinstance(sdf, rod.Model) else sdf.models()[0]

# Remove all poses that could be assumed being implicit
model.resolve_frames(is_top_level=True, explicit_frames=False)
Expand Down

0 comments on commit 0ce60b2

Please sign in to comment.