Skip to content

Commit

Permalink
Overwrite str function for pose models
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Feb 21, 2024
1 parent 3067890 commit b2b4cf7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/alitra/models/orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,19 @@ def from_rotation(rotation: Rotation, frame: Frame) -> Orientation:
:return: Orientation object
"""
return Orientation(*rotation.as_quat(), frame=frame) # type: ignore

def __str__(self):
"""
:return: Unique string representation of the orientation, ignoring the frame
"""
return (
"["
+ str(self.x)
+ ","
+ str(self.y)
+ ","
+ str(self.z)
+ ","
+ str(self.w)
+ "]"
)
6 changes: 6 additions & 0 deletions src/alitra/models/pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ def from_array(pos_array: np.ndarray, quat_array: np.ndarray, frame: Frame) -> P
Orientation.from_quat_array(quat_array, frame),
frame,
)

def __str__(self):
"""
:return: Unique string representation of the pose
"""
return "pos:" + str(self.position) + ", ori: " + str(self.orientation)
6 changes: 6 additions & 0 deletions src/alitra/models/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ def from_array(position_array: np.ndarray, frame: Frame) -> Positions:
Position(x=position[0], y=position[1], z=position[2], frame=frame)
)
return Positions(positions=positions, frame=frame)

def __str__(self):
"""
:return: Unique string representation of the position, ignoring the frame
"""
return "(" + str(self.x) + "," + str(self.y) + "," + str(self.z) + ")"

0 comments on commit b2b4cf7

Please sign in to comment.