Home        Store        Learn        Blog

Add new message BlueRov2

I want to attach an additional sensor to pixhawk, so I added a new local sensor message. I also modified the QGroundControl side, and if I connect pixhawk to a PC via USB, it will be displayed in QGroundControl.
However, when I go through Raspberry Pi, it seems to be masked and no new message is displayed.
I tried to modify mavlink and pymavlink in the companion/submodules/mavlink folder, but no new message was displayed. Can you give me some advice on what else to check?

Hi @ike, welcome to the forum! :slight_smile:

What kind of sensor is it? Generally it’s best to use an existing message where possible, so if you haven’t already I’d suggest checking the mavlink common message set to see if there’s a message that could do what you’re after. If none of the existing sensor-related messages are appropriate, you might want to consider using named_value_float, as discussed in this post.

Sounds like you’ve already made some decent progress - nice work! :slight_smile:

If you’re set on using a new mavlink message you’ll need to follow the ArduPilot documentation. Note in particular that

Since mavlink is made to be generated from a message set, you generally can’t just modify the files and run the result.

In case it’s relevant, the companion setup script installs pymavlink on line 32 with a ‘build’ command, so you might be able to/need to use that to do your rebuild once you’ve uninstalled the existing pymavlink and modified the files as desired.

See how you go, and let us know if you get stuck, and/or have any further questions :slight_smile:

hello @ike @EliotBR .

I’m facing the same problem as ike. I had a success in adding and receiving custom mavlink message, while pixhawk and qgc are connected directly with usb. But when i’m using a connection: qgc - raspberry companion - pixhawk - my added message isn’t seen in QGC, but lost packets are generated instead.

Is it necessary to modify xml files (ardupilotmega, common, etc) and regenerate sourcefiles for mavlink on companion to bypass my custom message?

And should i generate python files from xml using mavgen.py/mavgenerate.py script for companion?

Thanks in advance.

Hi Alex, welcome to the forum :slight_smile:

As I mentioned to ike, the companion computer runs mavproxy, which uses pymavlink to define the mavlink messages, so if you’re trying to use a custom message that pymavlink doesn’t know exists then it won’t be able to pass it on because it will just think it’s not valid.

Assuming you do actually need to use custom messages, you’ll need to follow the ArduPilot documentation I linked to in my previous comment. That will involve modifying or creating an xml file, and regenerating the mavlink source files and also building pymavlink from that modified source.

Hi Eliot, thank you for your advice.
I was able to solve the problem.

Based on the image of Companion 0.0.26, I modified the xml of /home/pi/companion/submodules/mavlink/message_definitions and issued the command of the companion setup script that I was taught.
After rebooting, I was able to confirm that the messages masked by Companion passed through Companion and reached from Pixhawk to the PC.

Please note that Pixhawk’s xml cannot be installed properly as it is, so I had to add only the points I wanted to change to the existing xml file.

Also, since I was taught the setup script, I tried to create the environment with the setup script, but I could not create it well due to bad timing. Therefore, try to prepare the environment based on 0.0.26.

1 Like