Skip to content

Commit

Permalink
removed LidarDetection from detection_and_odometry (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashum68 authored Jun 12, 2024
1 parent 5854b02 commit 59dcd90
Showing 1 changed file with 6 additions and 45 deletions.
51 changes: 6 additions & 45 deletions modules/detection_and_odometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -55,33 +16,33 @@ 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:
"""
Private constructor, use create() method.
"""
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:
Expand Down

0 comments on commit 59dcd90

Please sign in to comment.