State

drone.state

Copyright MIT GNU General Public License v3.0

MIT BWSI Autonomous Drone Racing Course - UAV Neo

File Name: state.py File Description: Defines the interface of the State module of the drone_core library.

class state.State

Provides read-only access to the vehicle’s current flight state.

class LandedState(*values)

The vehicle’s landed state.

abstractmethod get_landed_state() LandedState

Returns the vehicle’s landed state.

Returns:

UNDEFINED, ON_GROUND, IN_AIR, TAKEOFF, or LANDING.

Return type:

A LandedState enum value

Example:

if uav.state.get_landed_state() == uav.state.LandedState.IN_AIR:
    print("Drone is airborne")
abstractmethod get_mode() str

Returns the current flight mode as a string.

Common modes: “MANUAL”, “STABILIZED”, “ALTCTL”, “POSCTL”, “OFFBOARD”, “AUTO.LAND”, “AUTO.RTL”

Example:

mode = uav.state.get_mode()
if mode == "OFFBOARD":
    print("Pi has control")
abstractmethod is_armed() bool

Returns whether the motors are armed.

Example:

if uav.state.is_armed():
    print("Motors armed — stay clear of propellers")
abstractmethod is_connected() bool

Returns whether the flight controller is connected.

Example:

if uav.state.is_connected():
    print("Flight controller online")
abstractmethod is_offboard() bool

Returns whether the vehicle is in OFFBOARD mode (Pi has control).

Example:

if uav.state.is_offboard():
    print("Autonomous control active")