Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue when rotation is not provided in pose #43

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/pye57/scan_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from pye57.utils import get_fields, get_node

class ScanHeader:
"""Provides summary statistics for an individual lidar scan in an E57 file.

Including the number of points, bounds and pose of the scan.
"""
def __init__(self, scan_node):
self.node = scan_node
points = self.node["points"]
Expand All @@ -29,7 +33,11 @@ def rotation_matrix(self) -> np.array:

@property
def rotation(self) -> np.array:
q = Quaternion([e.value() for e in self.node["pose"]["rotation"]])
try:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: it would be better to use
try rotation = self.node["pose"]["rotation"} ... except KeyError ...
This avoids squashing other E57Exceptions, e.g. if there is malformed data in the rotation.

rotation = self.node["pose"]["rotation"]
q = Quaternion([e.value() for e in rotation])
except KeyError:
q = Quaternion()
return q.elements

@property
Expand Down
Loading