Skip to content

Commit 72e0c10

Browse files
Teighan MillerTeighan Miller
authored andcommitted
fixed decision_simple_waypoint.py: removed redundancies and used acceptance radius
1 parent 7384396 commit 72e0c10

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

modules/bootcamp/decision_simple_waypoint.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,17 @@ def run(
6767
# ============
6868

6969
# If the drone is halted and not at the destination, move the drone to destination
70-
if report.status == drone_status.DroneStatus.HALTED and report.destination != self.waypoint:
71-
command = commands.Command.create_set_relative_destination_command(
72-
self.waypoint.location_x, self.waypoint.location_y
73-
)
74-
# if the drone is at the destination and halted land the drone
75-
elif (
76-
report.status == drone_status.DroneStatus.HALTED and report.destination == self.waypoint
77-
):
78-
command = commands.Command.create_land_command()
79-
80-
# Case handling to ensure that the drone tries to land again if it lands outside of the acceptance radius
81-
if (
82-
report.status == drone_status.DroneStatus.LANDED
83-
and (report.position - report.destination) > self.acceptance_radius
84-
):
85-
command = commands.Command.create_set_relative_destination_command(
86-
self.waypoint.location_x, self.waypoint.location_y
87-
)
70+
if report.status == drone_status.DroneStatus.HALTED:
71+
if (report.destination - self.waypoint) < self.acceptance_radius:
72+
command = commands.Command.create_set_relative_destination_command(
73+
abs(self.waypoint.location_x), abs(self.waypoint.location_y)
74+
)
75+
# if the drone is at the destination and halted land the drone
76+
elif (
77+
(report.destination - self.waypoint) < self.acceptance_radius
78+
):
79+
command = commands.Command.create_land_command()
80+
8881
# Do something based on the report and the state of this class...
8982

9083
# ============

0 commit comments

Comments
 (0)