Custom messages sent by RPi not received by PX4

I am having difficulties sending messages from a Raspberry Pi 3B to a PX4 using mavlink.
I’ve added a custom message called ‘potmeters’ according to this guide and generated the required libraries using this guide:

After connecting to the Pixhawk, I’m trying to send custom messages from the Pi using pymavlink’s [message_name]_send(). However, I am not able to receive the messages.

I know that the connection between the two is working by sending an already defined mavlink message (vehicle_attitude). I altered mavlink_receiver.cpp such that after receiving a ‘vehicle_attitude’ message it calls my custom-made function and that publishes the message’s content to my custom-made uorb topic correctly.

For debugging, I added a call to a function in the beginning of MavlinkReceiver::handle_message() that publishes the received message’s ID to an uorb topic. It publishes the ID of the ‘vehicle_attitude’ message correctly, but the ID for my new ‘potmeters’ message is nowhere to be seen. This could be caused by the Raspberry Pi not sending the message, however I was not sure if any preprocessinng before MavlinkReceiver::handle_message() takes place that could also cause the custom-made message to be lost.

I don’t have any equipment to read the actual signals and check whether my custom message is sent by the RPi. I’ve generated the pymavlink libraries according the previously mentioned url, and using [message_name]_send() for my custom message doesn’t give any exceptions or errors. The python code that I use for sending the message is exactly the same as for sending the ‘vehicle_attitude’ message (except for the _send() function obviously), and that works fine.

I have a feeling that it must be the Raspberry Pi not sending the message is the actual problem here, but I don’t know where to look for a cause. The other option is that something on the Pixhawk is wrong, but that must be before the MavlinkReceiver::handle_message() is reached.

Have you also replaced the mavlink 2 headers ( so that they contain your custom message?

Yes, I have. I added the generated folder with my custom dialect to mavlink/include/mavlink/v2.0/.

Ok, and you chose that include everywhere, e.g. here:

1 Like

No I haven’t, I only changed the header in mavlink_receiver.h according to the px4 guide (

I will try changing the header in the file you mentioned later when I have access to the hardware again. Are there more files in which the include needs to be adjusted that are not mentioned in the guide? Also, is it necessary to add my custom message to mavlink_messages.cpp when I only want to receive a message?

No, that’s not necessary.

I’v tried changing the #include <v2.0/standard/mavlink.h> to #include <v2.0/custom_messages/mavlink.h> in mavlink_bridge_header.h, and it seems to work now! Thanks!

1 Like