Skip to content

Commit

Permalink
Update scan_header.py
Browse files Browse the repository at this point in the history
Fix: E57 element path well formed but not defined (ErrorPathUndefined) when no "rotation" attribute found in StructuredNode "pose"
  • Loading branch information
nghiadt22 authored Dec 4, 2024
1 parent 9c86a01 commit c2ed269
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pye57/scan_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2ed269

Please sign in to comment.