File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change 6
6
7
7
from .. import commands
8
8
from .. import drone_report
9
- import math
10
9
11
10
# Disable for bootcamp use
12
11
# pylint: disable-next=unused-import
@@ -101,20 +100,20 @@ def run(
101
100
102
101
# stuff when landed @ waypoint
103
102
closest_location = None
104
- min_distance = float ("inf" )
103
+ min_distance_sq = float ("inf" )
105
104
106
- for location in landing_pad_locations :
105
+ for pad_location in landing_pad_locations :
107
106
print ("report position: " + str (report .position ))
108
- print (str (location ))
107
+ print (str (pad_location ))
109
108
110
- distance = math . sqrt (
111
- (report .position .location_x - location .location_x ) ** 2
112
- + ( report .position .location_y - location .location_y ) ** 2
113
- )
109
+ # no square root!
110
+ distance_sq = (report .position .location_x - pad_location .location_x ) ** 2 + (
111
+ report .position .location_y - pad_location .location_y
112
+ ) ** 2
114
113
115
- if distance < min_distance :
116
- min_distance = distance
117
- closest_location = location
114
+ if distance_sq < min_distance_sq :
115
+ min_distance_sq = distance_sq
116
+ closest_location = pad_location
118
117
119
118
if closest_location is not None :
120
119
command = commands .Command .create_set_relative_destination_command (
You can’t perform that action at this time.
0 commit comments