From 59dcd907c9b8f6188bdb8ed56376dfbf831eb352 Mon Sep 17 00:00:00 2001 From: Andrew Shum <84476051+ashum68@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:03:57 -0400 Subject: [PATCH] removed LidarDetection from detection_and_odometry (#11) --- modules/detection_and_odometry.py | 51 ++++--------------------------- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/modules/detection_and_odometry.py b/modules/detection_and_odometry.py index fe685cc..29c6af8 100644 --- a/modules/detection_and_odometry.py +++ b/modules/detection_and_odometry.py @@ -3,46 +3,7 @@ """ from . import drone_odometry_local - - -class LidarDetection: - """ - Lidar scan - """ - - __create_key = object() - - __DISTANCE_LIMIT = 50 - __ANGLE_LIMIT = 160 - - @classmethod - def create(cls, distance: float, angle: float) -> "tuple[bool, LidarDetection | None]": - """ - Distance is in meters. - Angle is in degrees. - """ - if distance < 0 or distance > cls.__DISTANCE_LIMIT: - return False, None - - if abs(angle) > cls.__ANGLE_LIMIT: - return False, None - - return True, LidarDetection(cls.__create_key, distance, angle) - - def __init__(self, create_key: object, distance: float, angle: float) -> None: - """ - Private constructor, use create() method. - """ - assert create_key is LidarDetection.__create_key, "Use create() method" - - self.distance = distance - self.angle = angle - - def __str__(self) -> str: - """ - String representation - """ - return f"Distance: {self.distance}, Angle: {self.angle}. " +from . import lidar_detection class DetectionAndOdometry: @@ -55,25 +16,25 @@ class DetectionAndOdometry: @classmethod def create( cls, - lidar_detection: LidarDetection, + detection: lidar_detection.LidarDetection, local_odometry: drone_odometry_local.DroneOdometryLocal, ) -> "tuple[bool, DetectionAndOdometry | None]": """ Combines lidar reading with local odometry """ - if lidar_detection is None: + if detection is None: return False, None if local_odometry is None: return False, None - return True, DetectionAndOdometry(cls.__create_key, lidar_detection, local_odometry) + return True, DetectionAndOdometry(cls.__create_key, detection, local_odometry) def __init__( self, create_key: object, - lidar_detection: LidarDetection, + detection: lidar_detection.LidarDetection, local_odometry: drone_odometry_local.DroneOdometryLocal, ) -> None: """ @@ -81,7 +42,7 @@ def __init__( """ assert create_key is DetectionAndOdometry.__create_key, "Use create() method" - self.detection = lidar_detection + self.detection = detection self.odometry = local_odometry def __str__(self) -> str: