From be28c0a371d0acd7b534d9763a3cb79aa1559405 Mon Sep 17 00:00:00 2001 From: yooni1231 Date: Thu, 13 Aug 2026 15:15:07 +0900 Subject: [PATCH] Fix incorrect unit-vector check and quaternion/matrix unit label - AxisAngle.__init__ validated the axis by checking norm != 0 instead of norm != 1, so passing an explicit angle with a valid unit axis always raised ValueError. - BasePoseWidget._rotation_label_text compared the RotationFormat dataclass instance against plain strings ("Quaternion", "Rotation Matrix"), which is never True, so the (deg)/(rad) suffix was incorrectly appended to unitless formats like Quaternion. --- modules/zividsamples/gui/widgets/pose_widget.py | 17 ++++++++--------- .../hand_eye_calibration/pose_conversions.py | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/zividsamples/gui/widgets/pose_widget.py b/modules/zividsamples/gui/widgets/pose_widget.py index 9132511d..721f390d 100644 --- a/modules/zividsamples/gui/widgets/pose_widget.py +++ b/modules/zividsamples/gui/widgets/pose_widget.py @@ -180,15 +180,14 @@ def zivid_transformation_matrix(self) -> zivid.Matrix4x4: return zivid.Matrix4x4(self.transformation_matrix.as_matrix()) def _rotation_label_text(self) -> str: - degrees = ( - " (°)" - if self.rotation_information.use_degrees - and self.rotation_information.rotation_format not in ["Quaternion", "Rotation Matrix"] - else ( - " (rad)" if self.rotation_information.rotation_format not in ["Quaternion", "Rotation Matrix"] else "" - ) - ) - return f"Rotation as {self.rotation_information.rotation_format.name}{degrees}" + rotation_format = self.rotation_information.rotation_format + if rotation_format in [RotationFormats.quaternion, RotationFormats.rotation_matrix]: + degrees = "" + elif self.rotation_information.use_degrees: + degrees = " (°)" + else: + degrees = " (rad)" + return f"Rotation as {rotation_format.name}{degrees}" def _rotation_column_label_texts(self) -> List[str]: fmt = self.rotation_information.rotation_format diff --git a/source/applications/advanced/hand_eye_calibration/pose_conversions.py b/source/applications/advanced/hand_eye_calibration/pose_conversions.py index 257bd161..7b08074d 100644 --- a/source/applications/advanced/hand_eye_calibration/pose_conversions.py +++ b/source/applications/advanced/hand_eye_calibration/pose_conversions.py @@ -59,7 +59,7 @@ def __init__(self, axis: np.ndarray = np.array([0, 0, 1]), angle: Optional[float if angle is None: self.angle = np.linalg.norm(axis) self.axis = axis / self.angle - elif np.linalg.norm(axis) != 0: + elif not np.isclose(np.linalg.norm(axis), 1.0): raise ValueError("Angle provided, but vector is not unit vector") else: self.angle: np.floating = np.floating(angle)