Package Overview

  • coordinate.py - Representation of a GPS coordinate, functionality for comparing between coordinates

  • mission_item.py - Representation of a singular MAVLink MISSION_ITEM_INT

  • mission.py - Representation of a complete ArduPilot mission

  • controller.py - Lowest level of abstraction for communicating with Ardupilot via pymavlink, atomic methods

  • flight_controller.py - Extension of the controller class, with multiple operations combined into singular methods

Coordinate

A GPS coordinate compatible with MAVLink

Attributes:

  • is_int: Boolean flag indicating whether latitude/longitude are represented in degrees or integer microdegrees (x10^7). Integer coordinates are required for many MAVlink messages

  • lat: Latitude of the coordinate (unit depends on is_int)

  • lon: Longitude of the coordinate (unit depends on is_int)

  • alt: Altitude of the coordinate. Always in float meters

Methods:

  • dms_to_dd: Convert lat or lon from degrees, minutes, seconds to decimal degrees

  • offset_coordinate: Find a new coordinate a specified distance away along a specified heading

  • normalize: Converts another coordinate object to utilize the same is_int status

  • distance_to: Distance from self to another coordinate object

  • bearing_to: Compass bearing from self to another coordinate object

Mission Item

A waypoint; a singular `MISSION_ITEM_INT <https://mavlink.io/en/messages/common.html#MISSION_ITEM_INT>`__

Attributes:

  • seq: Index/position of this waypoint in the mission

  • frame: The MAV_FRAME

  • command: The MAV_CMD for this waypoint

  • current: Boolean indicator whether this is the current waypoint

  • auto_continue: Boolean indicator whether the mission should automatically proceed

  • x: Integer latitude of the coordinate

  • y: Integer longitude of the coordinate

  • z: Altitude of the coordinate

  • param1 - param4: Mission parameters 1 through 4

  • type: The MAV_MISSION_TYPE of this mission

Properties:

  • Message: Returns the MAVLink message for this mission item

Mission

A list of Mission Items making up a waypoint mission or geofence

Attributes:

  • controller: A Controller or Flight object for ArduPilot communication

  • type: The MAV_MISSION_TYPE of this mission

  • mission_items: A list of mission item objects

Methods:

  • load_mission_from_file: Loads a mission from a file in the QGC WPL 110 format (reference)

  • save_mission_to_file: Saves the mission to a file in the QGC WPL 110 format

  • send_mission: Sends the mission to ArduPilot using self.controller

  • clear_mission: Clears the currently loaded mission in ArduPilot using self.controller

Controller

Responsible for direct communication with ArduPilot via atomic messages

Attributes:

  • logger: An object for logging activity. Optional

  • master: The master MAVLink connection to ArduPilot

Methods (sending):

Methods (receiving):

Flight Controller

Responsible for managing the flight of the vehicle. Extends the controller class.

Attributes:

  • logger: An object for logging activity. Optional

  • master: The master MAVLink connection to ArduPilot

  • takeoff_mission - airdrop_mission: Mission objects for various phases

  • geofence: Mission object to store the geofence boundary

  • mission_list: List to maintain mission queue

  • preflight_check_done: Boolean tracker for completion of preflight checks

Methods:

  • takeoff: Handles takeoff procedure

  • append_mission: Appends a mission file to mission queue

  • wait_for_waypoint_reached: Blocks until waypoint is reached

  • wait_and_send_next_mission: Blocks until mission end, then sends next

  • wait_for_landed: Blocks until vehicle is landed

  • preflight_check: Prepares vehicle for flight, sets geofence, marks preflight done

  • wait_for_channel_input: Waits for RC channel input. Blocking

  • get_altitude: Gets the current altitude of the vehicle

Error Codes

Code Distribution:

  • 100-199: Controller errors

  • 200-299: Mission errors

  • 300-399: Flight errors

Code

Name

Description

101 111

TIMEOUT ERROR UNKNOWN MODE

Timed out waiting for a response from the drone The requested mode does not exist

201 202 203 204

FILE NOT FOUND FILE EMPTY START OUT OF RANGE END OUT OF RANGE

No file found with given filename/filepath The given mission file is empty Start index is out of mission file range End index is out of mission file range

301

PREFLIGHT CHECK ERROR

Takeoff attempted before preflight check was completed