Skip to content

Commit 0238a68

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

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

MAVProxy/modules/mavproxy_soar.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
21+
def mavlink_packet(self, m):
22+
'''handle mavlink packets'''
23+
24+
if m.get_type() == 'NAMED_VALUE_FLOAT' and m.name.startswith("SOAR"):
25+
if m.name == "SOAREKFX0":
26+
self._strength = m.value
27+
elif m.name == "SOAREKFX1":
28+
self._radius = m.value
29+
elif m.name == "SOAREKFX2":
30+
self._x = m.value
31+
elif m.name == "SOAREKFX3":
32+
self._y = m.value
33+
else:
34+
raise NotImplementedError(m.name)
35+
36+
self.draw_thermal_estimate()
37+
38+
def draw_thermal_estimate(self):
39+
40+
if self._radius is None:
41+
print("No radius")
42+
return
43+
if self._x is None:
44+
print("No x")
45+
return
46+
if self._y is None:
47+
print("No y")
48+
return
49+
50+
home = self.module('wp').get_home()
51+
if home is None:
52+
print("No home")
53+
return
54+
home_lat = home.x
55+
home_lng = home.y
56+
57+
(thermal_lat, thermal_lon) = mp_util.gps_offset(home_lat, home_lng, self._y, self._x)
58+
59+
slipcircle = mp_slipmap.SlipCircle(
60+
"soar-thermal", # key
61+
"thermals", # layer
62+
(thermal_lat, thermal_lon), # latlon
63+
self._radius, # radius
64+
(0, 255, 255),
65+
linewidth=2)
66+
for mp in self.module_matching('map*'):
67+
mp.map.add_object(slipcircle)
68+
69+
70+
def init(mpstate):
71+
'''initialise module'''
72+
return soar(mpstate)

0 commit comments

Comments
 (0)