Skip to content

Commit

Permalink
Fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Nov 22, 2023
1 parent 8a97c97 commit 0d1069f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/jaxsim/parsers/kinematic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,40 @@ class KinematicGraph:
joints_dict (Dict[str, descriptions.JointDescription]): A dictionary mapping joint names to joint descriptions.
joints_connection_dict (Dict[Tuple[str, str], descriptions.JointDescription]): A dictionary mapping pairs of parent and child link names to joint descriptions.
"""

root: descriptions.LinkDescription
frames: List[descriptions.LinkDescription] = dataclasses.field(default_factory=list)
joints: List[descriptions.JointDescription] = dataclasses.field(
default_factory=list
)

root_pose: RootPose = dataclasses.field(default_factory=RootPose)

transform_cache: Dict[str, npt.NDArray] = dataclasses.field(
repr=False, init=False, compare=False, default_factory=dict
)

extra_info: Dict[str, Any] = dataclasses.field(
repr=False, compare=False, default_factory=dict
)

@functools.cached_property
def links_dict(self) -> Dict[str, descriptions.LinkDescription]:
return {l.name: l for l in iter(self)}

@functools.cached_property
def frames_dict(self) -> Dict[str, descriptions.LinkDescription]:
return {f.name: f for f in self.frames}

@functools.cached_property
def joints_dict(self) -> Dict[str, descriptions.JointDescription]:
return {j.name: j for j in self.joints}

@functools.cached_property
def joints_connection_dict(
self,
) -> Dict[Tuple[str, str], descriptions.JointDescription]:
return {(j.parent.name, j.child.name): j for j in self.joints}

def __post_init__(self):
"""
Expand Down Expand Up @@ -147,6 +181,7 @@ def create_graph(
Tuple[descriptions.LinkDescription, List[descriptions.JointDescription], List[descriptions.LinkDescription]]:
A tuple containing the root link, list of joints, and list of frames in the graph.
"""

# Create a dict that maps link name to the link, for easy retrieval
links_dict: Dict[str, descriptions.LinkDescription] = {
l.name: l.mutable(validate=False) for l in links
Expand Down

0 comments on commit 0d1069f

Please sign in to comment.