Skip to content

Commit 235ca8a

Browse files
committed
mavproxy_soar: Add initial soaring display
Signed-off-by: Ryan Friedman <[email protected]>
1 parent 7aecc5a commit 235ca8a

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

MAVProxy/modules/mavproxy_soar.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env python3
2+
'''
3+
Soaring Module
4+
Ryan Friedman
5+
6+
This module displays the estimated soaring thermals on the map.
7+
A circle is drawn with the estimated radius from ArduSoar's estimated thermal location.
8+
9+
AP_FLAKE8_CLEAN
10+
'''
11+
12+
from MAVProxy.modules.lib import mp_module, mp_util
13+
from MAVProxy.modules.mavproxy_map import mp_slipmap
14+
15+
16+
class soar(mp_module.MPModule):
17+
def __init__(self, mpstate):
18+
"""Initialise module"""
19+
super(soar, self).__init__(mpstate, "soar", "")
20+
self._strength = None
21+
self._radius = None
22+
self._x = None
23+
self._y = None
24+
25+
def mavlink_packet(self, m):
26+
'''handle mavlink packets'''
27+
28+
if m.get_type() == 'NAMED_VALUE_FLOAT' and m.name.startswith("SOAR"):
29+
if m.name == "SOAREKFX0":
30+
self._strength = m.value
31+
elif m.name == "SOAREKFX1":
32+
self._radius = m.value
33+
elif m.name == "SOAREKFX2":
34+
self._x = m.value
35+
elif m.name == "SOAREKFX3":
36+
self._y = m.value
37+
else:
38+
raise NotImplementedError(m.name)
39+
40+
self.draw_thermal_estimate()
41+
42+
def draw_thermal_estimate(self):
43+
44+
if self._radius is None:
45+
print("No radius")
46+
return
47+
if self._x is None:
48+
print("No x")
49+
return
50+
if self._y is None:
51+
print("No y")
52+
return
53+
54+
home = self.module('wp').get_home()
55+
if home is None:
56+
print("No home")
57+
return
58+
home_lat = home.x
59+
home_lng = home.y
60+
61+
(thermal_lat, thermal_lon) = mp_util.gps_offset(home_lat, home_lng, self._y, self._x)
62+
63+
slipcircle = mp_slipmap.SlipCircle(
64+
"soar-thermal", # key
65+
"thermals", # layer
66+
(thermal_lat, thermal_lon), # latlon
67+
self._radius, # radius
68+
(0, 255, 255),
69+
linewidth=2)
70+
for mp in self.module_matching('map*'):
71+
mp.map.add_object(slipcircle)
72+
73+
74+
def init(mpstate):
75+
'''initialise module'''
76+
return soar(mpstate)

0 commit comments

Comments
 (0)