Creating and sending a Custom MAVLink Message packet (.xml format) on Raspberry Pi 4B board running a (Linux Ubuntu Desktop OS image) to PX4 CubePilot CubeOrange FC using the MAVLink protocol on a python script

Hi everyone,

I have a Raspberry Pi 4B board which is acting as a companion computer for offboard UAV control. I have established hardware connection successfully between the (RasPi 4B board) and the (PX4 CubePilot CubeOrange FC) through the serial (UART ports) present on both the devices ("TELEM2 port’s (TX,RX, GND pins on CubePilot CubeOrange FC) and the (TXD,RXD,GND pins on the GPIO board of RasPi 4B).

I have written a python script where I try to establish a serial connection between the two devices by defining the “SERIAL PORT” and “BAUDRATE” which match for both devices to initialize and establish a connection. Moreover, I use the “mavlink_connection” function to establish connection through the mavlink communication protocol which imports the pymavlink and pyserial libraries needed in my script.

Furthermore, I request to receive “ATTITUDE” and “airspeed & throttle from VFR_HUD” topics from the common message definitions mavlink set by requesting their respective “IDs” using the dialect ([MAVLink2: v20.all] and the "MAVLink_command_long_message).

Then, I am sending the requested messages using the “vehicle.mav.send” command to the vehicle & receiving them from the vehicle(px4 cubeorange fc) using the “vehicle.recv_match(type=‘’, blocking=True)”.

I am able to establish serial connection, connect to the vehicle, receive a heartbeat as well as receive the “attitude” and “VFR_HUD” topics from the px4 fc to RasPi 4B on my linux terminal when running my python script.

In my same script when I try to send a message (define “system_time_send()”) from RasPi 4B to PX4, I am not able to understand whether the message is sent or not. When I run my python script, it just connects to the vehicle and establishes a “heartbeat” connection.

From my RasPi’s side I have also defined a custom message definition on the common.xml file and repeated the same process on the (PX4’s side from the source code-modules-mavlink-common.xml) separately.

After, doing the above I am not able to send the custom message. I have also written the required lines of python code in my script that needs to be there to send the custom message after defining the (custom message definition on the common.xml files on both sides).

If someone has encountered a similar issue while sending a message as described above , help will be appreciated on how to solve the issue of sending a “Custom message definition” through the MAVLink protocol from the RasPi 4b board to the PX4 CubePilot CubeOrange FC".

I am using the pymavlink library present in python to achieve the above.

Best Regards

Aditya Karnam