Skip to content

Commit bff5195

Browse files
committed
Linter update
1 parent 2991996 commit bff5195

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

modules/bootcamp/decision_waypoint_landing_pads.py

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
from ..private.decision import base_decision
1515

1616

17-
18-
1917
class DecisionWaypointLandingPads(base_decision.BaseDecision):
2018
"""
2119
Travel to the designed waypoint and then land at the nearest landing pad.
@@ -47,21 +45,21 @@ def __init__(self, waypoint: location.Location, acceptance_radius: float) -> Non
4745
def location_in_bounds(self, loc: location.Location) -> bool:
4846
"""
4947
Check to see if the waypoint is within flight bounds
50-
48+
5149
"""
52-
return (loc.location_x <= self.upper_flight_bound
53-
and loc.location_x >= self.lower_flight_bound
54-
and loc.location_y <= self.upper_flight_bound
55-
and loc.location_y >= self.lower_flight_bound)
50+
return (
51+
loc.location_x <= self.upper_flight_bound
52+
and loc.location_x >= self.lower_flight_bound
53+
and loc.location_y <= self.upper_flight_bound
54+
and loc.location_y >= self.lower_flight_bound
55+
)
5656

5757
def dist_sqr(self, drone: location.Location, obj: location.Location) -> float:
5858
"""
5959
Find the square of the distance between drone and another object
60-
61-
"""
62-
return ((drone.location_x - obj.location_x) ** 2
63-
+ (drone.location_y - obj.location_y) ** 2)
6460
61+
"""
62+
return (drone.location_x - obj.location_x) ** 2 + (drone.location_y - obj.location_y) ** 2
6563

6664
def run(
6765
self, report: drone_report.DroneReport, landing_pad_locations: "list[location.Location]"
@@ -96,13 +94,15 @@ def run(
9694
y_dist_to_waypoint = self.waypoint.location_y - report.position.location_y
9795

9896
# Distance between drone and waypoint squared (square root is costly)
99-
dist_to_waypoint_sqr = x_dist_to_waypoint ** 2 + y_dist_to_waypoint ** 2
97+
dist_to_waypoint_sqr = x_dist_to_waypoint**2 + y_dist_to_waypoint**2
10098

10199
if report.status == drone_status.DroneStatus.HALTED:
102100

103101
# Case for when drone is halted but not at the waypoint (eg. start of simulation)
104-
if dist_to_waypoint_sqr > self.acceptance_radius ** 2:
105-
command = commands.Command.create_set_relative_destination_command(x_dist_to_waypoint, y_dist_to_waypoint)
102+
if dist_to_waypoint_sqr > self.acceptance_radius**2:
103+
command = commands.Command.create_set_relative_destination_command(
104+
x_dist_to_waypoint, y_dist_to_waypoint
105+
)
106106

107107
# When drone reaches the waypoint
108108
else:
@@ -111,7 +111,7 @@ def run(
111111
else:
112112
# When closest landing pad hasn't been found yet
113113
if self.landing_location is None:
114-
shortest_distance = float('inf')
114+
shortest_distance = float("inf")
115115

116116
# Finding the closest landing pad
117117
for landing_pad in landing_pad_locations:
@@ -123,7 +123,10 @@ def run(
123123
self.landing_location = landing_pad
124124

125125
# If landing pad is on the waypoint
126-
if self.dist_sqr(report.position, self.landing_location) < self.acceptance_radius ** 2 and report.status != drone_status.DroneStatus.HALTED:
126+
if (
127+
self.dist_sqr(report.position, self.landing_location) < self.acceptance_radius**2
128+
and report.status != drone_status.DroneStatus.HALTED
129+
):
127130

128131
return commands.Command.create_halt_command()
129132

@@ -132,17 +135,25 @@ def run(
132135

133136
if report.status == drone_status.DroneStatus.HALTED:
134137

135-
if self.dist_sqr(report.position, self.landing_location) > self.acceptance_radius ** 2:
138+
if (
139+
self.dist_sqr(report.position, self.landing_location)
140+
> self.acceptance_radius**2
141+
):
136142

137-
x_dist_to_landing = self.landing_location.location_x - report.position.location_x
138-
y_dist_to_landing = self.landing_location.location_y - report.position.location_y
143+
x_dist_to_landing = (
144+
self.landing_location.location_x - report.position.location_x
145+
)
146+
y_dist_to_landing = (
147+
self.landing_location.location_y - report.position.location_y
148+
)
139149

140-
command = commands.Command.create_set_relative_destination_command(x_dist_to_landing, y_dist_to_landing)
150+
command = commands.Command.create_set_relative_destination_command(
151+
x_dist_to_landing, y_dist_to_landing
152+
)
141153

142154
else:
143155
command = commands.Command.create_land_command()
144156

145-
146157
# ============
147158
# ↑ BOOTCAMPERS MODIFY ABOVE THIS COMMENT ↑
148159
# ============

0 commit comments

Comments
 (0)