-
Notifications
You must be signed in to change notification settings - Fork 2
/
alt-virtual-anchoring-behaviour
executable file
·37 lines (29 loc) · 1.22 KB
/
alt-virtual-anchoring-behaviour
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
import boatdclient
from navigate import Navigator
points = boatdclient.get_current_waypoints()
class VirtualAnchoringBehaviour(Navigator):
def __init__(self):
super(VirtualAnchoringBehaviour, self).__init__(enable_tacking=True,
enable_cross_track_minimization=False)
self.current_point = 0
self.anchoring_triangle = [points[0],
points[1],
points[2]]
self.set_target(self.anchoring_triangle[0])
self.waypoint_checkoff_distance = 3
def check_new_target(self):
distance = self.boat.position.distance_to(self.target)
if distance <= self.waypoint_checkoff_distance:
print ('distance from point:', distance)
if self.current_point >= 2:
self.current_point = 0
else:
self.current_point += 1
return self.anchoring_triangle[self.current_point]
else:
print ('distance to point', distance)
return None
if __name__ == '__main__':
behaviour = VirtualAnchoringBehaviour()
behaviour.run()