Skip to content

Commit 40b438c

Browse files
committed
updated code with revisions
1 parent 81a075f commit 40b438c

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

modules/bootcamp/decision_simple_waypoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def run(
9292
# when the drone is at the destination and is halted
9393
if (
9494
report.status == drone_status.DroneStatus.HALTED
95-
and proximity < self.acceptance_radius
95+
and proximity < self.acceptance_radius**2
9696
):
9797
command = commands.Command.create_land_command()
9898
self.has_sent_landing_command = True

modules/bootcamp/decision_waypoint_landing_pads.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(self, waypoint: location.Location, acceptance_radius: float) -> Non
3737
# Add your own
3838
self.has_sent_landing_command = False
3939
self.send_landing_command = False
40+
self.has_reached_waypoint = False
4041
self.min_bounds = -60
4142
self.max_bounds = 60
4243

@@ -83,9 +84,13 @@ def run(
8384
and self.waypoint.location_y >= self.min_bounds
8485
and self.waypoint.location_y <= self.max_bounds
8586
):
86-
proximity = (self.waypoint.location_x - report.position.location_x) ** 2 + (
87-
self.waypoint.location_y - report.position.location_y
88-
) ** 2
87+
if not self.has_reached_waypoint:
88+
proximity = (self.waypoint.location_x - report.position.location_x) ** 2 + (
89+
self.waypoint.location_y - report.position.location_y
90+
) ** 2
91+
if proximity < self.acceptance_radius**2:
92+
self.has_reached_waypoint = True
93+
8994
new_pad = location.Location(0, 0)
9095
# checking if the drone is halted
9196
if report.status == drone_status.DroneStatus.HALTED:
@@ -104,11 +109,19 @@ def run(
104109
smallest_dist = new_dist
105110
new_pad = landing_pads
106111

107-
command = commands.Command.create_set_relative_destination_command(
108-
new_pad.location_x - self.waypoint.location_x,
109-
new_pad.location_y - self.waypoint.location_y,
110-
)
111-
self.send_landing_command = True
112+
# if the landing pad is at the waypoint
113+
if new_pad == self.waypoint:
114+
command = commands.Command.create_set_relative_destination_command(
115+
self.waypoint.location_x - report.position.location_x,
116+
self.waypoint.location_y - report.position.location_y,
117+
)
118+
self.send_landing_command = True
119+
else:
120+
command = commands.Command.create_set_relative_destination_command(
121+
new_pad.location_x - report.position.location_x,
122+
new_pad.location_y - report.position.location_y,
123+
)
124+
self.send_landing_command = True
112125

113126
# setting relative destination to designated waypoint
114127
elif proximity > self.acceptance_radius**2 and not self.has_sent_landing_command:

modules/bootcamp/detect_landing_pad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def run(self, image: np.ndarray) -> "tuple[list[bounding_box.BoundingBox], np.nd
103103

104104
# Plot the annotated image from the Result object
105105
# Include the confidence value
106-
image_annotated = prediction.plot(conf=0.7)
106+
image_annotated = prediction.plot(conf=1)
107107

108108
# Get the xyxy boxes list from the Boxes object in the Result object
109109
boxes_xyxy = prediction.boxes.xyxy

0 commit comments

Comments
 (0)