Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isflying added #743

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .vscode/settings.json
Empty file.
23 changes: 23 additions & 0 deletions dronekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,16 @@ class Vehicle(HasObservers):
to the project!
"""

MAV_STATE_UNINIT = 0
MAV_STATE_BOOT = 1
MAV_STATE_CALIBRATING = 2
MAV_STATE_STANDBY = 3
MAV_STATE_ACTIVE = 4
MAV_STATE_CRITICAL = 5
MAV_STATE_EMERGENCY = 6
MAV_STATE_HILSIM = 7
MAV_STATE_POWEROFF = 8

def __init__(self, handler):
super(Vehicle, self).__init__()

Expand Down Expand Up @@ -1067,6 +1077,7 @@ def listener(self, name, m):
self._heading = None
self._airspeed = None
self._groundspeed = None
self._isflying = False

@self.on_message('VFR_HUD')
def listener(self, name, m):
Expand Down Expand Up @@ -1790,6 +1801,18 @@ def system_status(self):
7: SystemStatus('POWEROFF'),
}.get(self._system_status, None)


@property
def isflying (self):
isFlying = ((self._system_status == Vehicle.MAV_STATE_ACTIVE) or
((self._isflying == True) and (self._system_status == Vehicle.MAV_STATE_CRITICAL or Vehicle._system_status == self.MAV_STATE_EMERGENCY)))

self._isflying = isFlying

return self._isflying



@property
def heading(self):
"""
Expand Down
1 change: 1 addition & 0 deletions examples/vehicle_state/vehicle_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
print " Rangefinder voltage: %s" % vehicle.rangefinder.voltage
print " Heading: %s" % vehicle.heading
print " Is Armable?: %s" % vehicle.is_armable
print " Is Flying: %s" % vehicle.isflying
print " System status: %s" % vehicle.system_status.state
print " Groundspeed: %s" % vehicle.groundspeed # settable
print " Airspeed: %s" % vehicle.airspeed # settable
Expand Down