From ca1d7666b35bc96f008155eebc64bc1168490903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Chirico=20Indreb=C3=B8?= Date: Wed, 21 Feb 2024 07:45:30 +0100 Subject: [PATCH] Overwrite str function for pose models --- src/alitra/models/orientation.py | 6 ++++++ src/alitra/models/pose.py | 6 ++++++ src/alitra/models/position.py | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/alitra/models/orientation.py b/src/alitra/models/orientation.py index d449385..8d34596 100644 --- a/src/alitra/models/orientation.py +++ b/src/alitra/models/orientation.py @@ -91,3 +91,9 @@ 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) + "]" diff --git a/src/alitra/models/pose.py b/src/alitra/models/pose.py index 095a662..96e3b68 100644 --- a/src/alitra/models/pose.py +++ b/src/alitra/models/pose.py @@ -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) diff --git a/src/alitra/models/position.py b/src/alitra/models/position.py index 4616d85..5861989 100644 --- a/src/alitra/models/position.py +++ b/src/alitra/models/position.py @@ -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) + ")"