From c2ed26919d206fadf62ddecfaafc07c59011e7e5 Mon Sep 17 00:00:00 2001 From: Nghia Date: Wed, 4 Dec 2024 15:28:11 +0700 Subject: [PATCH] Update scan_header.py Fix: E57 element path well formed but not defined (ErrorPathUndefined) when no "rotation" attribute found in StructuredNode "pose" --- src/pye57/scan_header.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pye57/scan_header.py b/src/pye57/scan_header.py index 908f44b..ecd4671 100644 --- a/src/pye57/scan_header.py +++ b/src/pye57/scan_header.py @@ -28,16 +28,18 @@ def point_count(self): @property def rotation_matrix(self) -> np.array: - q = Quaternion([e.value() for e in self.node["pose"]["rotation"]]) + if "rotation" in self.node["pose"]: + q = Quaternion([e.value() for e in self.node["pose"]["rotation"]]) + else: + q = Quaternion([1, 0, 0, 0]) return q.rotation_matrix @property def rotation(self) -> np.array: - try: - rotation = self.node["pose"]["rotation"] - q = Quaternion([e.value() for e in rotation]) - except KeyError: - q = Quaternion() + if "rotation" in self.node["pose"]: + q = Quaternion([e.value() for e in self.node["pose"]["rotation"]]) + else: + q = Quaternion([1, 0, 0, 0]) return q.elements @property