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

reformatted DetectionsAndOdometry to contain a list of detections #13

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Changes from 1 commit
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
17 changes: 8 additions & 9 deletions modules/detection_and_odometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,44 @@

class DetectionAndOdometry:
"""
Contains LiDAR reading and current local odometry.
Contains LiDAR readings and current local odometry.
"""

__create_key = object()

@classmethod
def create(
cls,
detection: lidar_detection.LidarDetection,
detections: "list[lidar_detection.LidarDetection]",
local_odometry: drone_odometry_local.DroneOdometryLocal,
) -> "tuple[bool, DetectionAndOdometry | None]":
"""
Combines lidar reading with local odometry
Combines lidar readings with local odometry
"""

if detection is None:
if len(detections) == 0:
return False, None

if local_odometry is None:
return False, None

return True, DetectionAndOdometry(cls.__create_key, detection, local_odometry)
return True, DetectionAndOdometry(cls.__create_key, detections, local_odometry)

def __init__(
self,
create_key: object,
detection: lidar_detection.LidarDetection,
detections: "list[lidar_detection.LidarDetection]",
local_odometry: drone_odometry_local.DroneOdometryLocal,
) -> None:
"""
Private constructor, use create() method.
"""
assert create_key is DetectionAndOdometry.__create_key, "Use create() method"

self.detection = detection
self.detections = detections
self.odometry = local_odometry

def __str__(self) -> str:
"""
String representation.
"""
return f"{self.__class__.__name__}, {self.detection}, str{self.odometry}"
return f"{self.__class__.__name__}, Detections ({len(self.detections)}): {self.detections}, str{self.odometry}"
Copy link
Contributor

Choose a reason for hiding this comment

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

printout out the string representation of each detection instead of the list

Loading