Custom MAVLink Message Not Read

#1

Hello,

I followed the instructions here on the PX4 website to create a custom message, generating the headers and adding the new class MavlinkStreamMyMessage to the mavlink_messages.cpp file in src/modules/mavlink. Everything compiles as expected and I get no issues. I also added the mavlink stream line to my startup script.

However, I am unable to receive the message in pymavlink. I did make sure to copy the message definitions and regenerate the python files and ensured that my message shows up in the common.py file.

Is there something else that I have to do in order to send and receive a custom MAVLink message from a Pixhawk to a computer? Alternatively, is there any way that I can verify that the Pixhawk is indeed sending MY_MESSAGE?

Thanks,
Jon

1 Like
#2

Hi, I found the same problem, Have you solved this problem yet ?

Thank you

#3

Yes,

I totally forgot I posted this. Thanks for the reminder.

So what I did that got it working was to edit the mavlink_main.cpp in src/modules/mavlink and add your topic to list of streamed topics. You will see a bunch of configure_stream("TOPIC",0.5f); statements. Add yours to that list for each of the scenarios that you plan on streaming your topic. You might have to include your mavlink topic’s header too. I can’t remember whether that was required or not.

Jon

#4

Thank you, how did you know that your mavlink message has been already published? I tried to add something you mention but i dont know it is ok or not

#5

I had my Pixhawk sending the message over telemetry to a ground station computer that was listening for the message by running some pymavlink code. One thing to note is that you will need to also recompile the MAVLink headers on the ground station computer as well. This was a bit more complicated as you have to replace the .py file for whatever dialect you modified in the pymavlink module which I believe is somewhere in the /usr folder (on Linux). There are good instructions for how to find this elsewhere (quick google of "where are python modules stored on ").

I don’t use QGroundControl, but I believe there is a way to see what messages are being streamed from there.

#6

Do you connect pixhawk to computer by serial port or UDP?
Thank you

#7

Neither actually. It was connected over a wireless telemetry module, although you can also connect over USB.