Skip to content

Commit

Permalink
Make sure the link names and frame names are unique
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed May 21, 2024
1 parent 9f6c0ba commit 41beaac
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/jaxsim/parsers/kinematic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ def __post_init__(self) -> None:
for index, link in enumerate(self):
link.mutable(validate=False).index = index

# Get the names of the links and frames.
link_names = [l.name for l in self]
frame_names = [f.name for f in self.frames]

# Make sure that they are unique.
assert len(link_names) == len(set(link_names))
assert len(frame_names) == len(set(frame_names))
assert set(link_names).isdisjoint(set(frame_names))

# Order frames with their name.
super().__setattr__("frames", sorted(self.frames, key=lambda f: f.name))

Expand Down

0 comments on commit 41beaac

Please sign in to comment.