Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SohamD1 authored Sep 25, 2024
1 parent baa426f commit 1c8a9a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
41 changes: 19 additions & 22 deletions decision_waypoint_landing_pads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion detect_landing_pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ↑
# ============
# ============

0 comments on commit 1c8a9a4

Please sign in to comment.