-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocation.py
More file actions
59 lines (47 loc) · 1.44 KB
/
location.py
File metadata and controls
59 lines (47 loc) · 1.44 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from pymavlink import mavutil
from math import sqrt
'''
Classes adapted from here:
https://github.com/dronekit/dronekit-python/blob/master/dronekit/__init__.py
'''
class LocationGlobal(object):
def __init__(self, lat, lon, alt=None):
self.lat = lat
self.lon = lon
self.alt = alt
class LocationGlobalRelative(object):
def __init__(self, lat, lon, alt=None):
self.lat = lat
self.lon = lon
self.alt = alt
class LocationLocal(object):
def __init__(self, north, east, down):
self.north = north
self.east = east
self.down = down
class Altitude(object):
def __init__(self, mono, amsl, local, relative, terrain, clearance):
self.mono = mono
self.amsl = amsl
self.local = local
self.relative = relative
self.terrain = terrain
self.clearance = clearance
class Battery(object):
def __init__(self, voltage, current, level):
self.voltage = voltage / 1000.0
if current == -1:
self.current = None
else:
self.current = current / 100.0
if level == -1:
self.level = None
else:
self.level = level
class Velocity(object):
def __init__(self, north, east, down):
self.north = north
self.east = east
self.down = down
def magnitude(self):
return sqrt(self.north ** 2 + self.east ** 2 + self.down ** 2)