Skip to content

Commit

Permalink
reformatted DetectionsAndOdometry to contain a list of detections
Browse files Browse the repository at this point in the history
  • Loading branch information
ashum68 committed Jun 12, 2024
1 parent f9efc53 commit 86fe92d
Showing 1 changed file with 8 additions and 9 deletions.
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}"

0 comments on commit 86fe92d

Please sign in to comment.