Learn how to integrate GRID with PX4
MavLinkClient
MavLinkClient
class.
This client handles low-level communication via MavLink, the lightweight messaging protocol at the heart of PX4.
Features of the MavLinkClient
include:
MavLinkClient
is typically used as part of a higher level class to ease the deployment from the AirGen simulation environment while including any formfactor-specific functionality.An example of this is the ModalAIDrone
which uses the MavLinkClient
to replicates the functionality of AirGenDrone
for a ModalAI Starling 2 Max.MavLinkClient
, you need to provide the following connection parameters to match your drone’s setup:
ground_control_station_ip
: IP address of the GRID-connected computer from which commands are to be sent to the drone, referred to as the ground control station (GCS) in MavLink terminologymavlink_port
: port number for mavlink connectioncommunication_protocol
: communication protocol to use, i.e. ‘udp’, ‘tcp’vehicle_ip
: IP address of the drone where the RTSP video streams can be foundcamera_streams
: dictionary of camera streams to be used, where the key is the stream name and the value is a dictionary containing the port and path for the RTSP streamarm_enable
: whether to enable arming the droneknown_messages
: list of known MavLink messages which should be expected by the client. This is used to filter out unknown messages and can be useful for debugging.MavLinkClient
provides several utility functions to simplify common tasks and ensure robust drone operations:
attempt_command
method sends arbitrary MavLink commands with built-in retry logic, ensuring that critical commands (such as arming, setting offboard control, or custom message rates) are reliably executed.
HEARTBEAT
, LOCAL_POSITION_NED
, and COMMAND_ACK
) and to flag any unexpected communications, aiding in debugging and system monitoring.
VideoStreamManager
, the client supports RTSP video streaming. The get_single_frame
method, for example, captures a single image from a specified camera stream and converts it to a usable RGB format.
update_setpoint
utility further enables dynamic adjustment of key flight parameters on the fly.
MavLinkClient
can not only handle low-level communication tasks but also provide higher-level operational robustness and flexibility for real-world drone integration with GRID.
MavLinkClient
class, please refer to the MavLinkClient
API documentation.