Missions¶
Mission¶
An ardupilot mission.
- class MAVez.mission.Mission(controller, type=0)¶
Bases:
objectRepresents a mission for ardupilot.
- Parameters:
controller (
Controller) – The controller instance to send the mission through.type (
int) – The type of the mission, default is 0 (waypoint mission).
- Returns:
An instance of the Mission class.
- Return type:
- MISSION_SEND_TIMEOUT = 20¶
- TIMEOUT_ERROR = 101¶
- add_mission_item(mission_item)¶
Add a mission item to the mission.
- Parameters:
mission_item (
MissionItem) – The mission item to add.- Returns:
0 if the mission item was added successfully.
- Return type:
int
- async clear_mission()¶
Clear the mission from the vehicle.
- Returns:
0 if the mission was cleared successfully, or an error code if there was an error.
- Return type:
int
- decode_error(error_code)¶
Decode an error code into a human-readable string.
- Parameters:
error_code (
int) – The error code to decode.- Returns:
A human-readable string describing the error.
- Return type:
str
- classmethod from_file(controller, filepath, type=0)¶
Create a Mission object directly from a QGC WPL 110 file.
- Returns:
The created mission object or None if file loading failed
- Return type:
Optional[Mission]
- load_mission_from_file(filename, start=0, end=-1, first_seq=-1, overwrite=True)¶
Load a QGC WPL 110 mission from a file. For details on the file format, see: https://mavlink.io/en/file_formats/
- Parameters:
filename (
Path) – The path to the file containing the mission.start (
int) – The line number to start loading from, default is 0.end (
int) – The line number to stop loading at, default is -1 (load to the end).first_seq (
int) – The sequence number to start from, default is -1 (use the sequence number from the file).overwrite (
bool) – Whether to overwrite the existing mission items, default is True.
- Returns:
0 if the mission was loaded successfully, or an error code if there was an error.
- Return type:
int
- save_mission_to_file(filename)¶
Save the mission to a file in QGC WPL 110 format. For details on the file format, see: https://mavlink.io/en/file_formats/
- Parameters:
filename (
str) – The path to the file to save the mission to.- Returns:
0 if the mission was saved successfully.
- Return type:
int
- async send_mission(reset=True)¶
Send the mission to ardupilot.
- Parameters:
reset (
bool) – Whether to reset the mission index to 0 after sending the mission, default is True.- Returns:
0 if the mission was sent successfully, or an error code if there was an error.
- Return type:
int
- MAVez.mission.get_mission_length(filepath, logger=None)¶
Utility function to get the number of mission items in a mission file.
- Parameters:
filepath (
str) – Path to mission filelogger (
Logger|None) – logging. Defaults to None
- Returns:
Number of items in the mission, or -1 if file was not found
- Return type:
int
- async MAVez.mission.is_mission_completed(msg, mission_length, logger=None)¶
Wait for the mission to complete by monitoring the current mission index.
- Parameters:
msg (
Message) – The UAS Messenger message containing the mission item reachedmission_length (
int) – Total number of mission items.logger (
Logger|None) – logging. Defaults to None
- Returns:
True if mission is completed, false otherwise
- Return type:
bool
Mission Item¶
An ardupilot mission item.
- class MAVez.mission_item.MissionItem(seq, frame, command, current, auto_continue, coordinate, type=0, param1=0, param2=0, param3=0, param4=0)¶
Bases:
objectRepresents a mission item for ardupilot.
- Parameters:
seq (
int) – Sequence number of the mission item.frame (
int) – Frame of reference for the mission item.command (
int) – Command to be executed.current (
int) – Whether this is the current mission item.auto_continue (
int) – Whether to automatically continue to the next item.coordinate (
Coordinate) – The coordinate for the mission item.type (
int) – Type of the mission item, default is 0.param1 (
float) – Parameter 1 for the command, default is 0.param2 (
float) – Parameter 2 for the command, default is 0.param3 (
float) – Parameter 3 for the command, default is 0.param4 (
float) – Parameter 4 for the command, default is 0.
- Returns:
An instance of the Mission_Item class.
- Return type:
Mission_Item
- property message¶
The MAVLink message for the mission item.
- Returns:
The MAVLink message for the mission item.
- Return type:
mavutil.mavlink.MAVLink_mission_item_int_message