MCPcopy
hub / github.com/dronekit/dronekit-python / VehicleMode

Class VehicleMode

dronekit/__init__.py:455–511  ·  view source on GitHub ↗

This object is used to get and set the current "flight mode". The flight mode determines the behaviour of the vehicle and what commands it can obey. The recommended flight modes for *DroneKit-Python* apps depend on the vehicle type: * Copter apps should use ``AUTO`` mode for "norm

Source from the content-addressed store, hash-verified

453
454
455class VehicleMode(object):
456 """
457 This object is used to get and set the current "flight mode".
458
459 The flight mode determines the behaviour of the vehicle and what commands it can obey.
460 The recommended flight modes for *DroneKit-Python* apps depend on the vehicle type:
461
462 * Copter apps should use ``AUTO`` mode for "normal" waypoint missions and ``GUIDED`` mode otherwise.
463 * Plane and Rover apps should use the ``AUTO`` mode in all cases, re-writing the mission commands if "dynamic"
464 behaviour is required (they support only a limited subset of commands in ``GUIDED`` mode).
465 * Some modes like ``RETURN_TO_LAUNCH`` can be used on all platforms. Care should be taken
466 when using manual modes as these may require remote control input from the user.
467
468 The available set of supported flight modes is vehicle-specific (see
469 `Copter Modes <http://copter.ardupilot.com/wiki/flying-arducopter/flight-modes/>`_,
470 `Plane Modes <http://plane.ardupilot.com/wiki/flying/flight-modes/>`_,
471 `Rover Modes <http://rover.ardupilot.com/wiki/configuration-2/#mode_meanings>`_). If an unsupported mode is set the script
472 will raise a ``KeyError`` exception.
473
474 The :py:attr:`Vehicle.mode` attribute can be queried for the current mode.
475 The code snippet below shows how to observe changes to the mode and then read the value:
476
477 .. code:: python
478
479 #Callback definition for mode observer
480 def mode_callback(self, attr_name):
481 print "Vehicle Mode", self.mode
482
483 #Add observer callback for attribute `mode`
484 vehicle.add_attribute_listener('mode', mode_callback)
485
486 The code snippet below shows how to change the vehicle mode to AUTO:
487
488 .. code:: python
489
490 # Set the vehicle into auto mode
491 vehicle.mode = VehicleMode("AUTO")
492
493 For more information on getting/setting/observing the :py:attr:`Vehicle.mode`
494 (and other attributes) see the :ref:`attributes guide <vehicle_state_attributes>`.
495
496 .. py:attribute:: name
497
498 The mode name, as a ``string``.
499 """
500
501 def __init__(self, name):
502 self.name = name
503
504 def __str__(self):
505 return "VehicleMode:%s" % self.name
506
507 def __eq__(self, other):
508 return self.name == other
509
510 def __ne__(self, other):
511 return self.name != other
512

Callers 15

test_vehicle_mode_eqFunction · 0.90
test_vehicle_mode_neqFunction · 0.90
test_110Function · 0.90
arm_and_takeoffFunction · 0.90
test_gotoFunction · 0.90
arm_and_takeoffFunction · 0.90
test_115Function · 0.90
vehicle_state.pyFile · 0.90
arm_and_takeoffFunction · 0.90
flight_replay.pyFile · 0.90
arm_and_takeoffFunction · 0.90

Calls

no outgoing calls

Tested by 7

test_vehicle_mode_eqFunction · 0.72
test_vehicle_mode_neqFunction · 0.72
test_110Function · 0.72
arm_and_takeoffFunction · 0.72
test_gotoFunction · 0.72
arm_and_takeoffFunction · 0.72
test_115Function · 0.72