From 1c8a9a4d8dd420be1b08842d9a87d13db01318da Mon Sep 17 00:00:00 2001 From: Soham Dave Date: Tue, 24 Sep 2024 20:17:38 -0400 Subject: [PATCH] Add files via upload --- decision_waypoint_landing_pads.py | 41 ++++++++++++++----------------- detect_landing_pad.py | 3 ++- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/decision_waypoint_landing_pads.py b/decision_waypoint_landing_pads.py index 15e3c6c8..172ad801 100644 --- a/decision_waypoint_landing_pads.py +++ b/decision_waypoint_landing_pads.py @@ -27,6 +27,10 @@ class DecisionWaypointLandingPads(base_decision.BaseDecision): def __init__(self, waypoint: location.Location, acceptance_radius: float) -> None: """ Initialize all persistent variables here with self. + + Args: + waypoint (location.Location): The waypoint location to travel to. + acceptance_radius (float): The radius within which the waypoint is considered reached. """ self.waypoint = waypoint print(f"Waypoint: {waypoint}") @@ -37,49 +41,42 @@ def __init__(self, waypoint: location.Location, acceptance_radius: float) -> Non # ↓ BOOTCAMPERS MODIFY BELOW THIS COMMENT ↓ # ============ - print(str(waypoint.location_x)+str(waypoint.location_y)) + print(str(waypoint.location_x) + str(waypoint.location_y)) self.has_sent_landing_command = False - self.find_nearest_landing_pad = False - self.reached_waypoint = False - self.moving_to_landing_pad = False - self.counter = 0 - def at_point(self, current_x: float, current_y: float): + def at_point(self, current_x: float, current_y: float) -> bool: + """ + Check if the current position is within the acceptance radius of the waypoint. + Args: + current_x (float): The current x-coordinate of the drone. + current_y (float): The current y-coordinate of the drone. + Returns: + bool: True if the drone is within the acceptance radius, False otherwise. + """ distance_squared = (self.waypoint.location_x - current_x) ** 2 + ( self.waypoint.location_y - current_y ) ** 2 return distance_squared <= self.acceptance_radius ** 2 - - - # ============ - # ↑ BOOTCAMPERS MODIFY ABOVE THIS COMMENT ↑ - # ============ - def run( self, report: drone_report.DroneReport, landing_pad_locations: "list[location.Location]" ) -> commands.Command: """ Make the drone fly to the waypoint and then land at the nearest landing pad. - You are allowed to create as many helper methods as you want, - as long as you do not change the __init__() and run() signatures. - - This method will be called in an infinite loop, something like this: + Args: + report (drone_report.DroneReport): Current status report of the drone. + landing_pad_locations (list[location.Location]): List of available landing pad locations. - ```py - while True: - report, landing_pad_locations = get_input() - command = Decision.run(report, landing_pad_locations) - put_output(command) - ``` + Returns: + commands.Command: The command for the drone to execute. """ # Default command command = commands.Command.create_null_command() diff --git a/detect_landing_pad.py b/detect_landing_pad.py index f8c6e597..2b495054 100644 --- a/detect_landing_pad.py +++ b/detect_landing_pad.py @@ -129,9 +129,10 @@ def run(self, image: np.ndarray) -> "tuple[list[bounding_box.BoundingBox], np.nd if not success: continue + return [], image_annotated # ============ # ↑ BOOTCAMPERS MODIFY ABOVE THIS COMMENT ↑ - # ============ \ No newline at end of file + # ============