pyMAVLinCS package

Module contents

class pyMAVLinCS.MAVLinCS(address, baud=57600, source_system=255, source_component=190, target_system=None, dialect='ardupilotmega', mcc_class=<class 'pyMAVLinCS.mission_control_code.MCC'>, logger=<Logger pyMAVLinCS.setup_logger (INFO)>, mavlogfile='mav.tlog', relative_path_to_cwd=True, **kwargs)

Bases: object

Allows connection to one or more flight controllers on one link.

Parameters:
  • address (str) – Connection address.

  • baud (int) – Connection baudrate.

  • source_system (int) – Ground station MAVLink system ID.

  • source_component (int) – Ground station MAV_COMPONENT.

  • target_system (int|None) – MAVLink system ID of the target flight controller.

  • dialect (str) – MAVLink dialect, essential if timeout_heartbeat == 0. ‘ardupilotmega’ for ArduPilot, ‘common’ for PX4.

  • mcc_class – MCC base class used in your code (gives access to your custom MCCs).

  • logger (logging.Logger) – Logger to use.

  • mavlogfile (str|None) – Filename for MAVLink message logging.

  • relative_path_to_cwd (bool) – Whether the tlog path is relative to the current working directory.

  • **timeout_heartbeat (float) – Timeout (in seconds) while waiting for a HEARTBEAT before considering the connection impossible (raises an Exception). Default: None.

  • **pos_rate (float) – Rate at which the flight controller sends position updates to the ground station. Default: 4.

  • **send_automatic_timesync (bool) – Whether to send TIMESYNC messages at regular intervals. Default: False.

  • **timesync_delay (int) – Delay (in seconds) between two automatic TIMESYNC messages. Default: 3.

  • **send_automatic_home_request (bool) – Whether to request the HOME position at regular intervals. Default: False.

  • **home_request_delay (int) – Delay (in seconds) between two automatic HOME position requests. Default: 3.

  • **sysid_to_request_home (None|int|set|list[int]) – List of system IDs to which HOME position requests should be sent regularly. Default: None.

  • **command_ack_to_hide (None|int|set|list[int]|) – List of COMMAND_ACK (MAV_CMD) to show only in debug mode. Default: None.

Note

  • If target_system is None, the MAVLink ID of the first detected vehicle is used as target.

  • If mavlogfile is None, no .tlog file will be generated.

  • If **timeout_heartbeat is None, blocking wait until a valid HEARTBEAT is received (does not raise an Exception).

  • If **timeout_heartbeat is 0, no HEARTBEAT wait is performed. Requires the correct MAVLink dialect and assumes MAVLink 2.

  • If **sysid_to_request_home is None, HOME position requests are sent only to the target flight controller.

  • If **pos_rate<=0, doesn’t request position.

allow_actions: bool

Indicates whether flight command sending is allowed (arming, disarming, mode switching, etc.).

angles(source_system=None)

Attitude angles.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

  • roll (float) – Rotation around the longitudinal axis (front-back) ([-pi ; +pi] rad).

  • pitch (float) – Rotation around the lateral axis (left-right) ([-pi ; +pi] rad).

  • yaw (float) – Rotation around the vertical axis (up-down) ([-pi ; +pi] rad).

Return type:

mavtypes.Angles

Note

All returned values are NaN if no data has been received.

angular_rates(source_system=None)

Angular velocities.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

  • rollspeed (float) – Rotation speed around the longitudinal axis (front-back) (rad/s).

  • pitchspeed (float) – Rotation speed around the lateral axis (left-right) (rad/s).

  • yawspeed (float) – Rotation speed around the vertical axis (up-down) (rad/s).

Return type:

mavtypes.AnglesRates

Note

All returned values are NaN if no data has been received.

arm(force=False, target_system=None, **kwargs)

Arms the drone.

Parameters:
  • force (bool) – Whether to force arming or not.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout_ack (float|None) – ACK wait timeout. 0 if no wait (returns False). None if no timeout. Default: 2.

  • **timeout_arming (float|None) – Arming wait timeout. 0 if no wait after ACK (returns the ACK wait result as bool). None if no timeout. Default: 4.

Returns:

Whether the drone was armed or not.

Return type:

bool

autopilot_int(source_system=None)

Autopilot.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

MAV_AUTOPILOT | Autopilot.

Return type:

int|float

Note

Returns NaN if no data has been received.

autopilot_str(source_system=None)

Autopilot.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Autopilot (e.g.: ‘MAV_AUTOPILOT_PX4’, ‘MAV_AUTOPILOT_ARDUPILOTMEGA’).

Return type:

str

Note

Returns ‘UNKNOWN’ if no valid data has been received.

base_mode(source_system=None)

Base Mode. Partially characterizes the mode on PX4.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Base Mode.

Return type:

int|float

Note

Returns NaN if no data has been received.

battery_percentage(source_system=None)

Remaining battery (requires proper configuration of the flight controller).

Parameters:

source_system (int|None) – MAVLink source system ID. Defaults to the master’s ID.

Returns:

Remaining battery percentage.

Return type:

int|float

Note

Returns NaN if no data has been received.

battery_voltage(source_system=None)

Battery voltage.

Parameters:

source_system (int|None) – MAVLink source system ID. Defaults to the master’s ID.

Returns:

Battery voltage in V.

Return type:

float

Note

Returns NaN if no data has been received.

static cartesian_to_geographic_point(lat_origine, lon_origine, north_displacement, east_displacement)

Returns the GPS coordinates of a point from a Cartesian definition (with the drone as the origin).

Parameters:
  • lat_origine (float) – Latitude of the origin point (deg).

  • lon_origine (float) – Longitude of the origin point (deg).

  • north_displacement (float) – North displacement (m).

  • east_displacement (float) – East displacement (m).

Returns:

  • latitude (float) – Latitude of the GPS point (deg).

  • longitude (float) – Longitude of the GPS point (deg).

Return type:

mavtypes.GeographicPoint

Note

All returned values are NaN if no GPS data has been received.

check_mcc(mcc)

Check if an MCC has been received.

Parameters:

mcc (MCC) – MCC to wait for.

Returns:

True if the MCC is present, False otherwise.

Return type:

bool

clear_waypoints(target_system=None, **kwargs)

Delete all waypoints.

Parameters:
  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout (float|None) – Timeout while waiting for the ack. Default: 2.

Returns:

Result of the request.

Return type:

bool

close()

Closes the connection with the flight controller and stops all related threads.

current_waypoint_seq(source_system=None)

Current waypoint seq.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Waypoint sequence number.

Return type:

int|float

Note

Returns NaN if no data has been received.

custom_main_mode(source_system=None)

Custom Main Mode (PX4). Partially characterizes the mode on PX4.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Flight controller Custom Main Mode.

Return type:

int|float

Note

Returns NaN if no data has been received.

custom_mode(source_system=None)

Flight mode as an integer (ArduPilot). On PX4, allows retrieving the Custom Main Mode and Custom Sub Mode.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Flight controller mode.

Return type:

int|float

Note

Returns NaN if no data has been received.

custom_sub_mode(source_system=None)

Custom Sub Mode (PX4). Partially characterizes the mode on PX4.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Flight controller Custom Sub Mode.

Return type:

int|float

Note

Returns NaN if no data has been received.

data_init: DataInit

Initialization data.

delete_mcc(mcc)

Delete the MCC.

Parameters:

mcc (MCC) – MCC to delete.

property dialect: str | None

Returns the MAVLink dialect in use.

Returns:

MAVLink dialect (e.g., ‘ardupilotmega’).

Return type:

str|None

Note

The case dialect = None is not supposed to occur.

disarm(force=False, target_system=None, **kwargs)

Disarms the drone.

Parameters:
  • force (bool) – Whether to force disarming or not.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout_ack (float|None) – ACK wait timeout. 0 if no wait (returns False). None if no timeout. Default: 2.

  • **timeout_disarming (float|None) – Disarming wait timeout. 0 if no wait after ACK (returns the ACK wait result as bool). None if no timeout. Default: 4.

Returns:

Whether the drone was disarmed or not.

Return type:

bool

static distance_between_two_gps_points(lat_i, lat_f, lon_i, lon_f, relative_alt_i=None, relative_alt_f=None, alt_i=None, alt_f=None)

Distance between two GPS points.

Parameters:
  • lat_i (float) – Latitude of the initial GPS point (in degrees).

  • lat_f (float) – Latitude of the final GPS point (in degrees).

  • lon_i (float) – Longitude of the initial GPS point (in degrees).

  • lon_f (float) – Longitude of the final GPS point (in degrees).

  • relative_alt_i (float) – Relative altitude of the initial GPS point (in meters).

  • relative_alt_f (float) – Relative altitude of the final GPS point (in meters).

  • alt_i (float) – Absolute altitude (MSL) of the initial GPS point (in meters).

  • alt_f (float) – Absolute altitude (MSL) of the final GPS point (in meters).

Returns:

Distance in meters.

Return type:

float

Note

  • If relative_alt_(i or f) is None or NaN, the relative altitude difference will not be considered.

  • If alt_(i or f) is None or NaN, the altitude difference will not be considered.

  • If both relative_alt and alt fields are provided, the alt field takes priority.

static distance_between_two_local_points(x_i, x_f, y_i, y_f, z_i=None, z_f=None)

Distance between two points in local coordinates.

Parameters:
  • x_i (float) – North coordinate of the initial point (m).

  • x_f (float) – North coordinate of the final point (m).

  • y_i (float) – East coordinate of the initial point (m).

  • y_f (float) – East coordinate of the final point (m).

  • z_i (float|None) – Down coordinate of the initial point (m).

  • z_f (float|None) – Down coordinate of the final point (m).

Returns:

Distance in meters.

Return type:

float

Note

If z_(i or f) is None or NaN, the Down distance will not be considered.

do_follow(target_system)

Follow a moving vehicle. Works only on ArduPilot.

Parameters:

target_system (int) – MAVLink ID of the vehicle to follow.

do_follow_with_takeoff(target_system)

Follow a moving vehicle (+ takeoff). Works only on ArduPilot.

Parameters:

target_system (int) – MAVLink ID of the vehicle to follow.

ekf_origin(source_system=None)

EKF origin.

Parameters:

source_system (int|None) – MAVLink source system of the EKF origin. Defaults to the master’s ID.

Returns:

  • latitude (float) – EKF origin latitude.

  • longitude (float) – EKF origin longitude.

  • altitude (float) – EKF origin altitude (MSL).

Return type:

mavtypes.EkfOrigin

Note

All returned values are NaN if no data has been received.

static geographic_to_cartesian_point(lat_i, lon_i, lat_f, lon_f)

Computes the north and east displacements in meters to go from point i to point f.

Parameters:
  • lat_i (float) – Latitude of the initial point (deg).

  • lon_i (float) – Longitude of the initial point (deg).

  • lat_f (float) – Latitude of the final point (deg).

  • lon_f (float) – Longitude of the final point (deg).

Returns:

  • delta_north (float): North displacement (m).

  • delta_east (float): East displacement (m).

Return type:

tuple

get_distance_with_gps_pos(lat, lon, relative_alt=None, alt=None)

Distance between the flight controller and a GPS point.

Parameters:
  • lat (float) – Latitude of the GPS point (in degrees).

  • lon (float) – Longitude of the GPS point (in degrees).

  • relative_alt (float) – Relative altitude of the GPS point (in meters).

  • alt (float) – Absolute altitude (MSL) of the GPS point (in meters).

Returns:

Distance in meters.

Return type:

float

Note

  • If relative_alt is None or NaN, relative altitude distance will not be considered.

  • If alt is None or NaN, altitude distance will not be considered.

  • If both relative_alt and alt are provided, alt takes priority.

  • Returns NaN if no data has been received.

get_distance_with_local_pos(x, y, z=None)

Distance between the flight controller and a point in local coordinates.

Parameters:
  • x (float) – North (m).

  • y (float) – East (m).

  • z (float|None) – Down (m).

Returns:

Distance in meters.

Return type:

float

Note

  • If z is None or NaN, the Z distance will not be considered.

  • Returns NaN if no data has been received.

get_latence_ms_with_sysidcompid(key)

Returns the estimated one-way latency between our system and (sysid, compid) in ms.

Parameters:

key (tuple[int, int]) – (sysid, compid)

Returns:

Latency in ms.

Return type:

int

Note

Returns NaN if no data has been received.

get_msg(msg_type, source_system=None, max_age=None)

Return the last received message of a certain type from a given source_system.

Parameters:
  • msg_type (str) – MAVLink message type.

  • source_system (int|None) – MAVLink source ID of the message. Defaults to master’s target_system.

  • max_age (float|None) – Maximum age (in s) of the last message to be considered valid.

Returns:

The MAVLink message if received, else None.

Return type:

msg|None

Note

Returns None if the message hasn’t been received yet.

get_parameter(parameter, use_cache=False, target_system=None, **kwargs)

Requests and returns the value of a flight controller parameter.

Parameters:
  • parameter (str) – Parameter name (1 to 16 ASCII characters, e.g., ‘PILOT_THR_FILT’ or ‘WPNAV_SPEED’).

  • use_cache (bool) – If True and the parameter has already been received, returns the cached value immediately without sending a network request. Default: False.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout (float|None) – Overall timeout in seconds while waiting for PARAM_VALUE. 0 means no wait (returns cached value if use_cache=True, else NaN). None means no overall timeout. Default: 2.0.

  • **retry_timeout (float) – Timeout in seconds before re-sending PARAM_REQUEST_READ if no response is received. Default: 0.5.

  • **max_retries (int) – Maximum consecutive retries on timeout. Default: 3.

Returns:

Parameter value, or NaN if unavailable or timed out.

Return type:

float

gimbal_angles()

Gimbal angles in degrees.

Returns:

  • roll (float) – Roll in degrees.

  • pitch (float) – Pitch in degrees.

  • yaw (float) – Yaw in degrees.

Return type:

mavtypes.GimbalAngles

Note

All returned values are NaN if no data has been received.

gps_3d_fix(source_system=None)

3D GPS fix status.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Whether there is a 3D GPS fix.

Return type:

bool|None

Note

Returns None if no data has been received.

home_position(source_system=None)

HOME position.

Parameters:

source_system (int|None) – MAVLink source system of the HOME position. Defaults to the master’s ID.

Returns:

  • latitude_home (float) – HOME latitude.

  • longitude_home (float) – HOME longitude.

  • altitude_home (float) – HOME altitude (MSL).

Return type:

mavtypes.HomePosition

Note

All returned values are NaN if no data has been received.

is_waypoint_mission_completed(source_system=None)

Checks whether the waypoint mission is completed or not.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

True if the mission is completed, False otherwise.

Return type:

bool|None

Note

Returns None if no data has been received.

land(target_system=None, **kwargs)

Perform a simple landing. Currently implemented only for ArduPilot.

Parameters:
  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout_ack (float|None) – Timeout while waiting for the ack. Default: 2.

  • **timeout_set_mode (float|None) – Timeout while waiting for the mode change. Default: 3.

  • **timeout_land (float|None) – Timeout while waiting for the landing to complete. Default: None.

Returns:

Result of the operation.

Return type:

bool

last_statustext_from_sysidcompid(key)

Returns the last complete statustext received from (sysid, compid).

Parameters:

key (tuple[int, int]) – (sysid, compid)

Returns:

Last complete STATUSTEXT received.

Return type:

MAVLink_message|None

Note

Returns None if no complete STATUSTEXT has been received.

logger: Logger

Logger in use.

master: mavfile | None

Master object used to communicate via MAVLink.

mavthread: MavThread

Thread management object.

mcc: set

Set containing received and sent MCCs.

mcc_class

MCC base class used in your code (gives access to your custom MCCs).

mission_ended: bool

Indicates whether the code should stop (prevents further actions and stops blocking functions).

mode(source_system=None)

Flight mode.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Flight controller mode.

Return type:

str

Note

Returns ‘UNKNOWN’ if no valid data has been received.

mode_mapping(source_system=None)

Returns a dictionary mapping flight mode names to their IDs, or None if unknown.

Parameters:

source_system (int|None) – MAVLink ID of the vehicle. Defaults to master’s target_system.

Returns:

Dictionary mapping mode names (str) to IDs (int for ArduPilot, tuple[int,int,int] for PX4), or None if no valid data.

Return type:

dict|None

Note

Returns None if no valid HEARTBEAT message is received.

motors_armed(source_system=None)

Arming status.

Parameters:

source_system (int|None) – MAVLink system ID to check. Defaults to the master’s ID.

Returns:

True if the drone is armed, False otherwise.

Return type:

bool|None

Note

Returns None if no data has been received.

motors_disarmed(source_system=None)

Disarming status.

Parameters:

source_system (int|None) – MAVLink system ID to check. Defaults to the master’s ID.

Returns:

True if the drone is disarmed, False otherwise.

Return type:

bool|None

Note

Returns None if no data has been received.

open(address, baud=57600, source_system=255, source_component=190, target_system=None, dialect='ardupilotmega', **kwargs)

Opens a MAVLink connection. Ensure any previous connection is closed.

Parameters:
  • address (str) – Connection address (e.g., serial port or UDP endpoint).

  • baud (int) – Baud rate for serial connection.

  • source_system (int) – MAVLink system ID for the ground station.

  • source_component (int) – MAVLink component ID for the ground station.

  • target_system (int|None) – MAVLink system ID of the flight controller. If None, first detected vehicle is used.

  • dialect (str) – MAVLink 2 dialect. Example: “ardupilotmega” for ArduPilot, “common” for PX4.

  • **timeout_heartbeat (float|None) – Time to wait for a HEARTBEAT before considering connection impossible. None = wait indefinitely, 0 = skip waiting. Default: None.

  • **pos_rate (float) – Frequency (Hz) at which the flight controller sends position messages to the ground station. Default: 4.

Note

  • Initializes MAVLink version and dialect.

  • Sets up callbacks for sending and receiving MAVLink messages.

  • Starts background MAV thread for message handling.

  • If **pos_rate<=0, doesn’t request position.

static polar_to_geographic_point(lat_origine, lon_origine, distance_m, bearing)

Returns the GPS coordinates of a point from a polar definition (with the drone as the origin).

Parameters:
  • lat_origine (float) – Latitude of the origin point (deg).

  • lon_origine (float) – Longitude of the origin point (deg).

  • distance_m (float) – Distance (m).

  • bearing (float) – Bearing (deg).

Returns:

  • latitude (float) – Latitude of the GPS point (deg).

  • longitude (float) – Longitude of the GPS point (deg).

Return type:

mavtypes.GeographicPoint

Note

All returned values are NaN if no GPS data has been received.

position_gps(source_system=None)

GPS position.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

  • lat (float) – latitude in degrees.

  • lon (float) – longitude in degrees.

  • relative_alt (float) – relative altitude in meters.

  • alt (float) – absolute altitude (MSL) in meters.

Return type:

mavtypes.GPSPosition

Note

All returned values are NaN if no data has been received.

position_local(source_system=None)

Local position.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

  • x (float) – North (m).

  • y (float) – East (m).

  • z (float) – Down (m).

Return type:

mavtypes.LocalPosition

Note

All returned values are NaN if no data has been received.

static quaternion_to_euler(q)

Conversion from Quaternion to Euler.

Parameters:

q (list) – Quaternions.

Returns:

Euler angles.

Return type:

mavtypes.Angles

reboot(force=False, target_system=None, **kwargs)

Reboot the autopilot.

Parameters:
  • force (bool) – Whether to perform a forced reboot (not recommended; for reference only).

  • target_system (int|None) – Target MAVLink system ID.

  • **timeout_ack (float|None) – ACK waiting timeout. Default: 2.

Returns:

Result of the operation.

Return type:

bool

recv_match(condition=None, type=None, blocking=False, timeout=None, source_system=None, source_component=None)

receive the next MAVLink message that matches the given condition type can be a string or a list of strings (almost same logic as the pymavlink one)

request_all_parameters(target_system=None)

Requests the flight controller to stream all its parameters so they are cached.

Parameters:

target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

Returns:

True if the request was sent, False otherwise.

Return type:

bool

request_home_position(target_system=None, **kwargs)

Requests and waits to receive the HOME position.

Parameters:
  • target_system (int|None) – Target MAVLink system ID for the request. Defaults to the master’s ID.

  • **timeout_ack (float|None) – ACK wait timeout. 0 if no wait (returns NaN, NaN, NaN). None if no timeout. Default: 2.

  • **timeout_home_reception (float|None) – Timeout for receiving the HOME position after ACK. 0 if no wait (returns NaN, NaN, NaN). None if no timeout. Default: 2.

Returns:

  • latitude_home (float) – HOME latitude.

  • longitude_home (float) – HOME longitude.

  • altitude_home (float) – HOME altitude (MSL).

Return type:

mavtypes.HomePosition

Note

All returned values are NaN if no data has been received.

return_to_launch(target_system=None, **kwargs)

Send a Return-To-Launch (RTL) request.

Parameters:
  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout_ack (float|None) – ACK waiting timeout. Default: 2.

Returns:

Result of the request.

Return type:

bool

send_landing_target(x, y, z)

Send a landing target request. Movements are in the drone’s BODY frame.

Parameters:
  • x (float) – Front (+) / Back (-) (m)

  • y (float) – Right (+) / Left (-) (m)

  • z (float) – Down (+) / Up (-) (m)

send_mcc(mcc)

Send an MCC message.

Parameters:

mcc (MCC) – MCC object.

Returns:

True if the MCC was sent, False otherwise.

Return type:

bool

send_named_value_int(value, name='')

Send a NAMED_VALUE_INT message.

Parameters:
  • value (int) – Value.

  • name (str) – Name.

Returns:

True if the NAMED_VALUE_INT was sent, False otherwise.

Return type:

bool

send_statustext(text, severity=7, msg_id=0)

Send a STATUSTEXT message.

Parameters:
  • text (str) – Text to send.

  • severity (int) – Severity level.

  • msg_id (int) – STATUSTEXT ID.

Returns:

True if the STATUSTEXT was sent, False otherwise.

Return type:

bool

send_timesync()

Sends a TIMESYNC in broadcast to obtain connection latencies.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

send_waypoint(waypoint_index, frame=3, command=16, param1=0.0, param2=0.0, param3=0.0, param4=0.0, x=0.0, y=0.0, z=0.0, target_system=None)

Send a waypoint.

Parameters:
  • waypoint_index (int) – Waypoint ID (sequence number). Starts at zero. Must increment for each waypoint with no gaps (0,1,2,3,4).

  • frame (int) – MAV_FRAME | Coordinate system of the waypoint.

  • command (int) – MAV_CMD | Waypoint action.

  • param1 (float) – param1 (depending on the command).

  • param2 (float) – param2 (depending on the command).

  • param3 (float) – param3 (depending on the command).

  • param4 (float) – param4 (depending on the command).

  • x (float) – Local: x position in meters, Global: latitude in degrees.

  • y (float) – Local: y position in meters, Global: longitude in degrees.

  • z (float) – Global: altitude in meters (relative or absolute, depending on the frame).

  • target_system (int) – Target MAVLink system ID. Defaults to the master’s ID.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

send_waypoint_count(number_waypoints, target_system=None)

Inform the flight controller of the number of waypoints that will be sent. Must be sent before each mission.

Parameters:
  • number_waypoints (int) – Number of waypoints.

  • target_system (int) – Target MAVLink system ID.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

servo_pwm(servo_channel, source_system=None)

Servo PWM.

Parameters:
  • servo_channel (int) – Servo channel (1-16 or 1-8 for MAVLink < 2).

  • source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

PWM value (between 1000 and 2000).

Return type:

float

Note

Returns NaN if no data has been received.

set_additional_recv_msg_callback(callback)

Defines an additional callback to execute.

Parameters:

callback (Callable|None) – Callback with 1 function argument: the MAVLink message.

Note

Blocks actual message reception during this time (do not use a highly blocking function).

set_additional_send_callback(callback)

Defines an additional callback to execute.

Parameters:

callback (Callable|None) – Callback with 1 function argument: the MAVLink message.

set_ekf_origin(latitude, longitude, altitude, target_system=None)

Sets the drone’s EKF origin.

Parameters:
  • latitude (float) – EKF origin latitude in degrees.

  • longitude (float) – EKF origin longitude in degrees.

  • altitude (float) – EKF origin altitude (MSL) in meters.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

set_gimbal_angles(pitch, yaw, pitch_rate=0.0, yaw_rate=0.0, lock_pitch=True, lock_yaw=True, yaw_in_earth_frame=True, **kwargs)

Orients the gimbal.

Parameters:
  • pitch (float) – Pitch angle (deg).

  • yaw (float) – Yaw angle (deg).

  • pitch_rate (float) – Pitch rotation speed (deg/s).

  • yaw_rate (float) – Yaw rotation speed (deg/s).

  • lock_pitch (bool) – True = lock pitch relative to the horizon.

  • lock_yaw (bool) – True = lock yaw relative to North (earth frame).

  • yaw_in_earth_frame (bool) – True = yaw expressed in Earth frame, otherwise vehicle frame.

  • **timeout_ack (float) – Maximum wait time for ACK (seconds). Default: 3.

Returns:

True if ACK received (command accepted), False otherwise.

Return type:

bool

set_gimbal_neutral(**kwargs)

Sets the gimbal to neutral position (roll=pitch=yaw=0).

Parameters:

**timeout_ack (float) – Maximum wait time for ACK (seconds). Default: 3.

Returns:

True if ACK received (command accepted), False otherwise.

Return type:

bool

set_gimbal_retract(**kwargs)

Sets the gimbal to retract position (no stabilization).

Parameters:

**timeout_ack (float) – Maximum wait time for ACK (seconds). Default: 3.

Returns:

True if ACK received (command accepted), False otherwise.

Return type:

bool

set_gimbal_target(latitude, longitude, altitude, gimbal_device_id=0, **kwargs)

Sends a target GPS position.

Parameters:
  • latitude (float) – Latitude in degrees.

  • longitude (float) – Longitude in degrees.

  • altitude (float) – Absolute altitude (MSL) in meters.

  • gimbal_device_id (int) – Component ID of gimbal device to address (or 1-6 for non-MAVLink gimbal), 0 for all gimbal device components.

  • **timeout_ack (float) – ACK wait timeout in seconds. Default: 3.

Returns:

Result of the operation.

Return type:

bool

set_gps_pos_target(latitude, longitude, relative_altitude, yaw=nan, target_system=None)

Sets the GPS target position.

Parameters:
  • latitude (float) – Latitude (deg).

  • longitude (float) – Longitude (deg).

  • relative_altitude (float) – Relative altitude (m).

  • yaw (float) – Target position yaw (rad).

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

Note

Set yaw to NaN if no yaw is specified.

set_home(latitude, longitude, altitude, roll=None, pitch=None, yaw=None, target_system=None)

Sets the HOME position.

Parameters:
  • latitude (float) – HOME latitude in degrees.

  • longitude (float) – HOME longitude in degrees.

  • altitude (float) – HOME altitude (MSL) in meters.

  • roll (float|None) – Roll (of the surface) in degrees [-180°; +180°].

  • pitch (float|None) – Pitch (of the surface) in degrees [-90°; +90°].

  • yaw (float|None) – Yaw in degrees [-180°; +180°].

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

Note

  • Set latitude/longitude/altitude to None if you do not want to specify a certain characteristic of the HOME position (uses the current drone value).

  • Set roll/pitch/yaw to None if you do not want to specify a certain angle (uses the current drone value).

set_home_current_pos(target_system=None)

Sets the HOME position to the current position.

Parameters:

target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

set_local_pos_target(x, y, z, yaw=nan, target_system=None)

Sets the local target position.

Parameters:
  • x (float) – North (m).

  • y (float) – East (m).

  • z (float) – Down (m).

  • yaw (float) – Target position yaw (rad).

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

Note

Set yaw to NaN if no yaw is specified.

set_mcc_callback(callback)

Defines a callback to execute when an MCC is received.

Parameters:

callback (Callable|None) – Callback with 1 function argument: the received MCC (MCC class).

Note

Blocks actual message reception during this time (do not use a highly blocking function).

set_mode(mode, target_system=None, **kwargs)

Changes the flight mode.

Parameters:
  • mode (str|int|tuple[int, int, int]) – Flight mode. str: mode name. int: mode ID on ArduPilot. tuple[int, int, int]: (MAV_MODE_FLAG, Custom Main Mode, Custom Sub Mode) on PX4.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout_ack (float|None) – ACK wait timeout. 0 if no wait (returns False). None if no timeout. Default: 2.

  • **timeout_set_mode (float|None) – Mode change wait timeout. 0 if no wait (returns the ACK wait result as bool). None if no timeout. Default: 4.

Returns:

Whether the mode was changed or not.

Return type:

bool

set_msg_rate(msg_type, rate, target_system=None, **kwargs)

Changes the sending frequency of a specific flight controller message.

Parameters:
  • msg_type (str|int) – Message type (name or ID).

  • rate (float) – Transmission frequency in Hz.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout_ack (float|None) – ACK wait timeout. 0 if no wait (returns False). None if no timeout. Default: 2.

Returns:

True if the request was accepted by the flight controller, False otherwise.

Return type:

bool

set_servo(servo_channel, pwm, target_system=None, **kwargs)

Sets the position of a servo.

Parameters:
  • servo_channel (int) – Servo channel.

  • pwm (int) – PWM value (between 1000 and 2000. 1000=closed, 2000=open).

  • target_system (int|None) – Target MAVLink system ID for the command. Defaults to the master’s ID.

  • **timeout_ack (float|None) – Acknowledgment wait time. Default: 2.

Returns:

Result of the operation.

Return type:

bool

set_speed(vx, vy, vz, yaw=nan, target_system=None)

Sets the drone’s velocity.

Parameters:
  • vx (float) – Velocity towards North in m/s.

  • vy (float) – Velocity towards East in m/s.

  • vz (float) – Velocity downwards in m/s.

  • yaw (float) – Target position yaw (rad).

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

set_statustext_callback(callback)

Defines a callback to execute when a complete STATUSTEXT is received.

Parameters:

callback (Callable|None) – Callback with 1 function argument: the complete received STATUSTEXT message.

Note

Blocks actual message reception during this time (do not use a highly blocking function).

speed(source_system=None)

Velocities.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

  • vx (float) – Velocity in m/s towards North.

  • vy (float) – Velocity in m/s towards East.

  • vz (float) – Velocity in m/s downwards.

Return type:

mavtypes.Speed

Note

All returned values are NaN if no data has been received.

speed_module(source_system=None)

Absolute speed.

Parameters:

source_system (int|None) – MAVLink system ID of the device. Defaults to the master’s ID.

Returns:

Speed in m/s.

Return type:

float

Note

Returns NaN if no data has been received.

start_mission(first_wp_tkoff=None, target_system=None, **kwargs)

Start the mission. Currently implemented only for ArduPilot.

Parameters:
  • first_wp_tkoff (bool) – Deprecated (will be removed soon, so do not use it). Still here for questions regarding backward compatibility.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout (float|None) – Waiting timeout (used in several places). Default: 3.

Returns:

Whether the mission has started.

Return type:

bool

statustext_receiver: StatustextReceiver

STATUSTEXT management object.

takeoff(altitude, pitch=0, target_system=None, **kwargs)

Perform a takeoff. Make sure to arm the drone beforehand.

Parameters:
  • altitude (float) – Takeoff altitude.

  • pitch (float) – Enforced pitch.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **precision (float) – Required altitude precision in meters to consider the takeoff successful. Default: 1.

  • **timeout_ack (float|None) – Timeout while waiting for the ack. 0 means no waiting (returns False). None means no timeout. Default: 2.

  • **timeout_takeoff (float|None) – Timeout while waiting for the takeoff to complete. 0 means no waiting (returns the ack result as bool). None means no timeout. Default: None.

Returns:

Takeoff result.

Return type:

bool

property time_boot: int

Time since startup in seconds.

property time_boot_ms: int

Time since startup in milliseconds.

property time_usec: int

Unix timestamp in microseconds.

timesync_handler: TimesyncHandler

TIMESYNC management object.

upload_mission(waypoints, clear_existing=True, target_system=None, **kwargs)

Uploads a complete waypoint mission using the MAVLink Mission Protocol handshake.

Sends MISSION_COUNT and responds sequentially to each MISSION_REQUEST_INT (or MISSION_REQUEST) from the flight controller with MISSION_ITEM_INT, retrying automatically on packet loss until MISSION_ACK is received.

Parameters:
  • waypoints (list[mavtypes.MissionItem|dict|tuple]) –

    Ordered list of mission items (starting at sequence 0, which is reserved for HOME on ArduPilot). Each element can be: - a mavtypes.MissionItem instance, - a dict with keys command, x (or lat/latitude),

    y (or lon/longitude), z (or alt/altitude/relative_alt), and optional frame, param1, param2, param3, param4,

    • a 4-tuple (command, x, y, z), 5-tuple (command, x, y, z, frame), or 9-tuple (command, x, y, z, frame, param1, param2, param3, param4).

  • clear_existing (bool) – Whether to clear existing waypoints on the flight controller before uploading. Default: True.

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout (float|None) – Overall timeout in seconds for the upload handshake. 0 means no wait (returns False). None means no overall timeout. Default: 15.0.

  • **retry_timeout (float) – Timeout in seconds before re-sending the last packet if no request/ack is received. Default: 1.5.

  • **max_retries (int) – Maximum consecutive retries per step on timeout. Default: 5.

Returns:

True if the mission was uploaded and accepted by the flight controller, False otherwise.

Return type:

bool

wait_command_ack(command, source_system=None, timeout=2)

Wait to receive a specific COMMAND_ACK and check if it was accepted.

Parameters:
  • command (int) – MAV_CMD | Command to wait for.

  • source_system (int|None) – MAVLink source ID of the COMMAND_ACK. Defaults to master’s target_system.

  • timeout (float|None) – Timeout for receiving COMMAND_ACK. 0 means no wait (returns None). None means no timeout.

Returns:

True if COMMAND_ACK accepted, False if refused, None if mission ended or timeout.

Return type:

bool|None

Note

Returns None if mission ended or no data received (after timeout).

wait_for_home(source_system=None, timeout=None)

Wait to receive the HOME position.

Parameters:
  • source_system (int|None) – MAVLink source ID to wait for. Defaults to the master’s ID.

  • timeout (float|None) – Reception waiting timeout. 0 means no wait (returns NaN, NaN, NaN). None means no timeout.

Returns:

  • latitude_home (float) – HOME latitude (deg).

  • longitude_home (float) – HOME longitude (deg).

  • altitude_home (float) – HOME altitude (MSL, m).

Return type:

mavtypes.HomePosition

Note

All returned values are NaN if the mission ended or no data received (after timeout).

wait_gps_3d_fix(source_system=None, timeout=None)

Wait for a GPS 3D fix.

Parameters:
  • source_system (int|None) – MAVLink source ID to wait for. Defaults to the master’s ID.

  • timeout (float|None) – GPS fix waiting timeout. 0 means no wait (returns None). None means no timeout.

Returns:

True if GPS 3D fix is achieved, False otherwise.

Return type:

bool|None

Note

Returns None if the mission ended or no data received (after timeout).

wait_mission_ack(mission_type=None, source_system=None, timeout=2)

Wait to receive a specific MISSION_ACK and check if it was accepted.

Parameters:
  • mission_type (int|None) – MAV_MISSION_TYPE | Type of mission. None means any type.

  • source_system (int|None) – MAVLink source ID of the MISSION_ACK. Defaults to master’s target_system.

  • timeout (float|None) – Timeout for receiving MISSION_ACK. 0 means no wait (returns None). None means no timeout.

Returns:

True if MISSION_ACK accepted, False if refused, None if mission ended or timeout.

Return type:

bool|None

Note

Returns None if mission ended or no data received (after timeout).

wait_mode_changed(mode, source_system=None, timeout=4)

Wait for a flight mode change.

Parameters:
  • mode (str|int|tuple[int, int, int]) – Flight mode. str: mode name. int: mode ID on ArduPilot. tuple[int, int, int]: (MAV_MODE_FLAG, Custom Main Mode, Custom Sub Mode) on PX4.

  • source_system (int|None) – MAVLink source ID to wait for. Defaults to the master’s ID.

  • timeout (float|None) – Mode change waiting timeout. 0 means no wait (returns None). None means no timeout.

Returns:

True if mode changed, False otherwise.

Return type:

bool|None

Note

Returns None if mission ended or no data received (after timeout).

wait_motors_armed(source_system=None, timeout=4)

Wait for the motors to be armed.

Parameters:
  • source_system (int|None) – MAVLink source ID to wait for. Defaults to the master’s ID.

  • timeout (float|None) – Armament waiting timeout. 0 means no wait (returns None). None means no timeout.

Returns:

Whether the motors are armed or not.

Return type:

bool|None

Note

Returns None if the mission ended or no data received (after timeout).

wait_motors_disarmed(source_system=None, timeout=4)

Wait for the motors to be disarmed.

Parameters:
  • source_system (int|None) – MAVLink source ID to wait for. Defaults to the master’s ID.

  • timeout (float|None) – Disarm waiting timeout. 0 means no wait (returns None). None means no timeout.

Returns:

Whether the motors are disarmed or not.

Return type:

bool|None

Note

Returns None if the mission ended or no data received (after timeout).

wait_proximity_with_gps_pos(lat, lon, relative_alt=None, alt=None, radius_acceptance=1, timeout=None)

Wait to reach a certain distance between the flight controller and a GPS point.

Parameters:
  • lat (float) – Latitude of the GPS point (degrees).

  • lon (float) – Longitude of the GPS point (degrees).

  • relative_alt (float|None) – Relative altitude of the GPS point (meters).

  • alt (float|None) – Absolute altitude (MSL) of the GPS point (meters).

  • radius_acceptance (float) – Distance threshold to consider reached.

  • timeout (float|None) – Proximity waiting timeout. 0 means no wait (returns None). None means no timeout.

Returns:

True if within proximity, False otherwise.

Return type:

bool|None

Note

Returns None if the mission ended or no data received (after timeout).

wait_proximity_with_local_pos(x, y, z=None, radius_acceptance=1, timeout=None)

Wait to reach a certain distance between the flight controller and local coordinates.

Parameters:
  • x (float) – North (m).

  • y (float) – East (m).

  • z (float|None) – Down (m).

  • radius_acceptance (float) – Distance threshold to consider reached.

  • timeout (float|None) – Proximity waiting timeout. 0 means no wait (returns None). None means no timeout.

Returns:

True if within proximity, False otherwise.

Return type:

bool|None

Note

Returns None if the mission ended or no data received (after timeout).

write_parameter(parameter, value, param_type=9, target_system=None, **kwargs)

Modifies a flight controller parameter and waits for PARAM_VALUE confirmation.

Parameters:
  • parameter (str) – Parameter name (1 to 16 ASCII characters).

  • value (float|int) – Desired parameter value.

  • param_type (int) – MAV_PARAM_TYPE | Parameter type (default: MAV_PARAM_TYPE_REAL32).

  • target_system (int|None) – Target MAVLink system ID. Defaults to the master’s ID.

  • **timeout_ack (float|None) – Timeout in seconds while waiting for the confirming PARAM_VALUE. 0 means no wait after sending (returns True immediately). None means no overall timeout. Default: 2.0.

  • **retry_timeout (float) – Timeout in seconds before re-sending PARAM_SET if no PARAM_VALUE is received. Default: 0.5.

  • **max_retries (int) – Maximum consecutive retries on timeout. Default: 3.

  • **tolerance (float) – Relative/absolute tolerance when verifying the confirmed parameter value. Default: 1e-4.

Returns:

True if the parameter was set and confirmed (or sent when timeout_ack=0), False otherwise.

Return type:

bool

Submodules

pyMAVLinCS.mavecstra module

class pyMAVLinCS.mavecstra.MavLogger(file, relative_path_to_cwd=True)

Bases: object

Handles logging to a file

Parameters:
  • file (str | None) – Name of the tlog file.

  • relative_path_to_cwd (bool) – Path relative to current working directory or not.

close()

Safely closes the binary log file.

log(m)

Logs a MAVLink message.

Parameters:

m (MAVLink_message) – MAVLink message.

class pyMAVLinCS.mavecstra.MavThread(mavlincs, queue_maxsize=100, msg_timeout=1.0)

Bases: object

Manages Threads.

Parameters:
  • mavlincs (MAVLinCS) – MAVLinCS object linked.

  • queue_maxsize (int) – Maximum size of the message queue.

  • msg_timeout (float) – Timeout in seconds to consider a received message as too old.

is_thread_active()

Indicates whether the thread is active.

Returns:

True if the thread is active, False otherwise.

Return type:

bool

recv_msg()

Message receive routine (same logic as the pymavlink one)

Traverses the queue from oldest to newest: - if a message is too old (t - timestamp > last_msg_timeout) -> remove it and continue - if a valid message is found -> return it (newer messages remain in the queue) - if no valid message -> queue becomes empty and return None

select(timeout)

Wait for up to timeout seconds for more data (same logic as the pymavlink one)

set_master()

Sets the new master.

start_thread()

Starts the Thread.

stop_thread()

Stops the Thread.

class pyMAVLinCS.mavecstra.StatustextReceiver

Bases: object

Manages the reception of statustext messages split into chunks

last_statustext_from_sysidcompid(key)

Returns the last complete statustext received from (sysid, compid).

Parameters:

key (tuple[int, int]) – (sysid, compid)

Returns:

Last complete STATUSTEXT received. None if no message exists.

Return type:

MAVLink_message | None

parse(m)

Adds a STATUSTEXT message to the receiver

Parameters:

m (MAVLink_message) – Latest STATUSTEXT received.

Returns:

Complete STATUSTEXT or None if incomplete.

Return type:

MAVLink_message | None

class pyMAVLinCS.mavecstra.TimesyncHandler(master, send_automatic_timesync, timesync_delay, logger)

Bases: object

Manages the TIMESYNC protocol

Parameters:
  • master (mavutil.mavfile) – Master connection.

  • send_automatic_timesync (bool) – Whether to send TIMESYNC automatically.

  • timesync_delay (int) – Waiting time between two TIMESYNC messages.

  • logger (logging.Logger) – Logger to use.

get_latence_ms_with_sysidcompid(key)

Returns the estimated one-way latency between our system and (sysid, compid) in ms.

Parameters:

key (tuple[int, int]) – (sysid, compid)

Returns:

Latency in ms. NaN if no data received.

Return type:

int

parse(m)

Call upon reception of a TIMESYNC message.

Parameters:

MAVLink_message – TIMESYNC message received.

Returns:

True if it is a response to one of our TIMESYNC messages, False otherwise.

Return type:

bool

send_timesync()

Sends a TIMESYNC broadcast to obtain connection latencies.

Returns:

True if the command was sent, False otherwise.

Return type:

bool

set_master(master)

Sets the master to use.

Parameters:

master (mavutil.mavfile) – Master connection.

timesync_sent_callback(m)

Call on each TIMESYNC sent.

Parameters:

m (MAVLink_message) – TIMESYNC message sent.

pyMAVLinCS.mavtypes module

class pyMAVLinCS.mavtypes.Angles(roll, pitch, yaw)

Bases: NamedTuple

pitch: float

Rotation around the lateral axis (left-right) ([-pi ; +pi] rad).

roll: float

Rotation around the longitudinal axis (front-back) ([-pi ; +pi] rad).

yaw: float

Rotation around the vertical axis (up-down) ([-pi ; +pi] rad).

class pyMAVLinCS.mavtypes.AnglesRates(rollspeed, pitchspeed, yawspeed)

Bases: NamedTuple

pitchspeed: float

Rotation speed around the lateral axis (left-right) (rad/s).

rollspeed: float

Rotation speed around the longitudinal axis (front-back) (rad/s).

yawspeed: float

Rotation speed around the vertical axis (up-down) (rad/s).

class pyMAVLinCS.mavtypes.DataInit

Bases: TypedDict

address: str
baud: int
command_ack_to_hide: None | int | list[int] | tuple[int]
dialect: str
pos_rate: float
source_component: int
source_system: int
sysid_to_request_home: None | int | list[int] | tuple[int]
target_system: int | None
class pyMAVLinCS.mavtypes.EkfOrigin(latitude, longitude, altitude)

Bases: NamedTuple

altitude: float

EKF origin altitude (MSL).

latitude: float

EKF origin latitude.

longitude: float

EKF origin longitude.

class pyMAVLinCS.mavtypes.GPSPosition(lat, lon, relative_alt, alt)

Bases: NamedTuple

alt: float

absolute altitude (MSL) in meters.

lat: float

latitude in degrees.

lon: float

longitude in degrees.

relative_alt: float

relative altitude in meters.

class pyMAVLinCS.mavtypes.GeographicPoint(latitude, longitude)

Bases: NamedTuple

latitude: float

Latitude of the GPS point (deg).

longitude: float

Longitude of the GPS point (deg).

class pyMAVLinCS.mavtypes.GimbalAngles(roll, pitch, yaw)

Bases: NamedTuple

pitch: float

Pitch in degrees.

roll: float

Roll in degrees.

yaw: float

Yaw in degrees.

class pyMAVLinCS.mavtypes.HomePosition(latitude_home, longitude_home, altitude_home)

Bases: NamedTuple

altitude_home: float

HOME altitude (MSL).

latitude_home: float

HOME latitude.

longitude_home: float

HOME longitude.

class pyMAVLinCS.mavtypes.LocalPosition(x, y, z)

Bases: NamedTuple

x: float

North (m).

y: float

East (m).

z: float

Down (m).

class pyMAVLinCS.mavtypes.MissionItem(command, x, y, z, frame, param1, param2, param3, param4)

Bases: NamedTuple

command: int

MAV_CMD | Waypoint action (e.g., mavutil.mavlink.MAV_CMD_NAV_WAYPOINT).

frame: int

3 = MAV_FRAME_GLOBAL_RELATIVE_ALT).

Type:

MAV_FRAME | Coordinate system of the waypoint (default

param1: float

param1 (depending on the command).

param2: float

param2 (depending on the command).

param3: float

param3 (depending on the command).

param4: float

param4 (depending on the command).

x: float

x position in meters.

Type:

Global

Type:

latitude in degrees, Local

y: float

y position in meters.

Type:

Global

Type:

longitude in degrees, Local

z: float

Altitude in meters (relative or absolute, depending on the frame).

class pyMAVLinCS.mavtypes.Speed(vx, vy, vz)

Bases: NamedTuple

vx: float

Velocity in m/s towards North.

vy: float

Velocity in m/s towards East.

vz: float

Velocity in m/s downwards.

pyMAVLinCS.mission_control_code module

class pyMAVLinCS.mission_control_code.MCC(value, name, level, description)

Bases: object

Class representing an MCC (Mission Control Code) with various properties, levels, and descriptions. Allows categorization of MCCs based on their value and associates descriptions with them.

Args: value (int): The unique numeric value associated with the MCC. name (str): The name of the MCC. level (str): Type of MCC (e.g., SUCCESS). description (str): A short description of the MCC.

classmethod get(value)

Retrieves an MCC object by its numeric value. Returns EMPTY if no MCC exists with this value.

Return type:

MCC

classmethod get_name(name)

Retrieves an MCC object by its name. Returns EMPTY if no MCC exists with this name.

Return type:

MCC

pyMAVLinCS.setup_logger module

pyMAVLinCS.setup_logger.setup_logger(logger, log_file=None, relative_path_to_cwd=True, clear_existing_logs=True, debug_mode=False, add_timestamp_to_console=False, add_timestamp_to_file=False)

Set up the logger.

Parameters:
  • logger (logging.Logger) – Logger to set up.

  • log_file (str|None) – Log file. None if no file logging is needed.

  • relative_path_to_cwd (bool) – Path relative to current working directory or absolute.

  • clear_existing_logs (bool) – Whether to clear existing logs or not.

  • debug_mode (bool) – Indicates if debug mode is enabled.

  • add_timestamp_to_console (bool) – Add time to console logs.

  • add_timestamp_to_file (bool) – Add time to log file entries.

Return type:

None