diff --git a/modules/bootcamp/decision_simple_waypoint.py b/modules/bootcamp/decision_simple_waypoint.py index bdb8d5d9..bf794bc0 100644 --- a/modules/bootcamp/decision_simple_waypoint.py +++ b/modules/bootcamp/decision_simple_waypoint.py @@ -37,7 +37,13 @@ def __init__(self, waypoint: location.Location, acceptance_radius: float): # ↓ BOOTCAMPERS MODIFY BELOW THIS COMMENT ↓ # ============ - # Add your own + self.command_index = 0 + self.commands = [ + commands.Command.create_set_relative_destination_command( 4, 1), + commands.Command.create_set_relative_destination_command( 0.0, -2), + commands.Command.create_set_relative_destination_command(-4, 1), + ] + self.has_sent_landing_command = False # ============ # ↑ BOOTCAMPERS MODIFY ABOVE THIS COMMENT ↑ @@ -68,10 +74,14 @@ def run(self, # ↓ BOOTCAMPERS MODIFY BELOW THIS COMMENT ↓ # ============ - # Do something based on the report and the state of this class... + if report.status == drone_report.drone_status.DroneStatus.HALTED and self.command_index int: + return (l2.location_x - l1.location_x) * (l2.location_x - l1.location_x) + (l2.location_y - l1.location_y) * (l2.location_y - l1.location_y) + def run(self, report: drone_report.DroneReport, landing_pad_locations: "list[location.Location]") -> commands.Command: @@ -68,10 +77,30 @@ def run(self, # ↓ BOOTCAMPERS MODIFY BELOW THIS COMMENT ↓ # ============ - # Do something based on the report and the state of this class... - - # Remove this when done - raise NotImplementedError + if report.status == drone_report.drone_status.DroneStatus.HALTED and self.command_index "tuple[list[bounding_box.BoundingBox], np.nd # * conf # * device # * verbose - predictions = ... + predictions = self.__model.predict(source=image, conf=0.7, show_conf=True) # Get the Result object - prediction = ... + prediction = predictions[0] # Plot the annotated image from the Result object # Include the confidence value - image_annotated = ... + image_annotated = prediction.orig_img # Get the xyxy boxes list from the Boxes object in the Result object - boxes_xyxy = ... + boxes_xyxy = prediction.boxes.xyxy # Detach the xyxy boxes to make a copy, # move the copy into CPU space, # and convert to a numpy array - boxes_cpu = ... + boxes_cpu = boxes_xyxy.detach().cpu().numpy() # Loop over the boxes list and create a list of bounding boxes bounding_boxes = [] # Hint: .shape gets the dimensions of the numpy array - # for i in range(0, ...): + for i in range(0, boxes_cpu.shape[0]): # Create BoundingBox object and append to list - # result, box = ... - - # Remove this when done - raise NotImplementedError + result, box = bounding_box.BoundingBox.create(boxes_cpu[i]) + + if not result: + return ([], image_annotated) + + bounding_boxes.append(box) + return bounding_boxes, image_annotated # ============ # ↑ BOOTCAMPERS MODIFY ABOVE THIS COMMENT ↑