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 messageslat
: Latitude of the coordinate (unit depends onis_int
)lon
: Longitude of the coordinate (unit depends onis_int
)alt
: Altitude of the coordinate. Always in float meters
Methods:
dms_to_dd
: Convert lat or lon from degrees, minutes, seconds to decimal degreesoffset_coordinate
: Find a new coordinate a specified distance away along a specified headingnormalize
: Converts another coordinate object to utilize the sameis_int
statusdistance_to
: Distance fromself
to another coordinate objectbearing_to
: Compass bearing fromself
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 missionframe
: The MAV_FRAMEcommand
: The MAV_CMD for this waypointcurrent
: Boolean indicator whether this is the current waypointauto_continue
: Boolean indicator whether the mission should automatically proceedx
: Integer latitude of the coordinatey
: Integer longitude of the coordinatez
: Altitude of the coordinateparam1
-param4
: Mission parameters 1 through 4type
: 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 communicationtype
: The MAV_MISSION_TYPE of this missionmission_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 formatsend_mission
: Sends the mission to ArduPilot usingself.controller
clear_mission
: Clears the currently loaded mission in ArduPilot usingself.controller
Controller¶
Responsible for direct communication with ArduPilot via atomic messages
Attributes:
logger
: An object for logging activity. Optionalmaster
: The master MAVLink connection to ArduPilot
Methods (sending):
send_message
send_mission_count
: Sends MISSION_COUNTsend_clear_mission
: Sends MISSION_CLEAR_ALLset_mode
: Sets vehicle mode via MAV_COMMAND_DO_SET_MODEarm
/disarm
: Arms/disarms with MAV_CMD_COMPONENT_ARM_DISARMenable_geofence
/disable_geofence
: Use MAV_CMD_DO_FENCE_ENABLEset_home
: Set home with MAV_CMD_DO_SET_HOMEset_servo
: Set servo PWM via MAV_CMD_DO_SET_SERVOset_message_interval
/disable_message_interval
: Use MAV_COMMAND_SET_MESSAGE_INTERVALawait_current_mission_index
: Wait for MISSION_CURRENTset_current_mission_index
: Set waypoint index using MAV_COMMAND_DO_SET_MISSION_CURRENTstart_mission
: Start mission using MAV_COMMAND_MISSION_START
Methods (receiving):
await_mission_request
: Waits for MISSION_REQUESTawait_mission_ack
: Waits for MISSION_ACKawait_mission_item_reached
: Waits for MISSION_ITEM_REACHEDrecieve_channel_input
: Receives RC_CHANNELSrecieve_gps
: Receives GLOBAL_POSITION_INTrecieve_landing_status
: Receives EXTENDED_SYS_STATE
Flight Controller¶
Responsible for managing the flight of the vehicle. Extends the controller class.
Attributes:
logger
: An object for logging activity. Optionalmaster
: The master MAVLink connection to ArduPilottakeoff_mission
-airdrop_mission
: Mission objects for various phasesgeofence
: Mission object to store the geofence boundarymission_list
: List to maintain mission queuepreflight_check_done
: Boolean tracker for completion of preflight checks
Methods:
takeoff
: Handles takeoff procedureappend_mission
: Appends a mission file to mission queuewait_for_waypoint_reached
: Blocks until waypoint is reachedwait_and_send_next_mission
: Blocks until mission end, then sends nextwait_for_landed
: Blocks until vehicle is landedpreflight_check
: Prepares vehicle for flight, sets geofence, marks preflight donewait_for_channel_input
: Waits for RC channel input. Blockingget_altitude
: Gets the current altitude of the vehicle
Error Codes¶
Code Distribution:
100-199
: Controller errors200-299
: Mission errors300-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 |