Receiving custom mavlink message in QGC

I’m looking for some guidance on viewing a custom mavlink message in the Analyze widget of QGC. The background is:

  1. Custom uORB message defined in PX4 (Dev: uORB Messaging)
  2. Create custom MAVLink message and streamed in PX4 (Dev: MAVLink Messaging)
  3. Receiving custom MAVLink message in QGC

Steps 1 and 2 I feel pretty good about. If anyone has guidance on Step 3 I’d appreciate it. It looks like this requires recompiling QGC. So far I’ve:

  1. Used same custom MAVLink message definition XML to generate parsing C code and copied that to:
    qgroundcontrol/libs/mavlink/include/mavlink/v1.0
  2. what next?

It looks like some changes need to happen in qgroundcontrol/src/Vehicle, but other discussions on this topic somehow indicate that the above is all that is needed to see the custom message in the QGC Analyze widget.

Does anyone have experience or guidance on the QGC step?

Related Posts:

4 Likes

If all you want to do is view (mavlink inspector) or plot (analyze) the message in QGC you simply need to make sure mavlink is updated and recompile.

@dagar Thanks for the confirmation, but I’m still not seeing the message.
The reason I suspect there is more to it is a note in the QGCExternalLibs.pri file, as part of the QGC source code. It says:

[REQUIRED] Add support for the MAVLink communications protocol.
# Mavlink dialect is hardwired to arudpilotmega for now. The reason being
# the current codebase supports both PX4 and APM flight stack. PX4 flight stack
# only usese common mavlink specifications, wherease APM flight stack uses custom
# mavlink specifications which add to common. So by using the adupilotmega dialect
# QGC can support both in the same codebase.
#
# Once the mavlink helper routines include support for multiple dialects within
# a single compiled codebase this hardwiring of dialect can go away. But until then
# this "workaround" is needed.

MAVLINKPATH_REL = libs/mavlink/include/mavlink/v1.0
MAVLINKPATH = $$BASEDIR/$$MAVLINKPATH_REL
MAVLINK_CONF = adupilotmega

But my custom mavlink message comes from another .xml and is another folder, not the ardupilotmega folder. If I change the above MAVLINK_CONF to point to my custom folder it failed to compile because I believe other QGC code is looking for the commonly used MAVLINK messages.

I’m thinking this may be a question for the QGC folks. But I thought to ask here because creating a custom message in PX4 and sending it to QGC seems like something many developers would do.

Okay, that makes sense. I assumed you had thrown it in common. QGC requires the ardupilotmega mavlink messages which are a superset of what PX4 uses (common).

I can think of some hacks to make it work right now (eg including ardupilotmega.xml instead of common.xml in your message definition), but if you want to figure out the better solution you should open a github issue and ask @DonLakeFlyer.

In order to add custom messages to QGC you need to base your mavlink off of the ardupilot dialect. If that’s the case, you can then change MAVLINK_CONF to be you own directory.

Could you tell me how to update the mavlink command? I want to do the same thing. Thanks
EDIT: I am debugging PX4flow, and there is no uorb thing in the code.

I want to do the same, but the Analyze widget of QGC doesn’t show my custom message. I used the upper instructions and answers to receive custom MAVLink messages.

Here is my custom MAVLink message definition XML I used to generate the C Code:

<?xml version="1.0"?>
    <mavlink>
        <include>ardupilotmega.xml</include>
    <messages>
	    <message id="198" name="CA_TRAJECTORY">
		    <description></description>
		    <field type="uint64_t" name="timestamp"></field>
		    <field type="uint16_t" name="time_start_usec"></field>
		    <field type="uint16_t" name="time_stop_usec"></field>
		    <field type="uint8_t[28]" name="coefficients"></field>
		    <field type="uint16_t" name="seq_id"></field>
	    </message>
    </messages>
</mavlink>

I also copied that to: qgroundcontrol/libs/mavlink/include/mavlink/v1.0

Here is my QGCExternalLibs.pri file:

MAVLINKPATH_REL = libs/mavlink/include/mavlink/v1.0
MAVLINKPATH = $$BASEDIR/$$MAVLINKPATH_REL
MAVLINK_CONF = ardupilotmega
DEFINES += MAVLINK_NO_DATA

Because it’s a new message definition I changed MAVLINK_CONF = ardupilotmega to MAVLINK_CONF = ca_trajectory, but Qt creator wasn’t able to build the code. There are a lot of issues regarding redefined messages.

As a new approach I generate the code again to use v2.0.
I also copied that to: qgroundcontrol/libs/mavlink/include/mavlink/v2.0 and changed MAVLINKPATH_REL to MAVLINKPATH_REL = libs/mavlink/include/mavlink/v2.0

But there are a lot of issues regarding not declared items.

Can anyone explain how to setup QGC?

QGC uses mavlink 2 headers. If the headers are still under the ardupilotmega directory they you need to leave MAVLINK_CONF alone. That sets the directory they will be pulled form. I would leave everything alone in the build system And just overwrite the ardupilotmega v2 directory with your files.

I have added a new mavlink message in common.xml within Ardupilot. After the Ardupilot build the new set of headers are made available to QGroundControl.
When Ardupilot is executed on SITL, I could debug and confirm that the
message is sent out from Ardupilot, through the function
=E2=80=9Cmavlink_helper.h/_mav_finalize_message_chan_send()=E2=80=9D, howev=
er I could not
detect the new mavlink message at QGroundControl.

I copies the mavlink headers that were generated during Ardupilot build,
into QGroundControl. Mavgen utility helps to open one xml file and
generate the headers. we are using at least two xml files (
ardupilotmega.xml, and common.xml ). Hence I used the headers generated
during ardupilot build process. Is this the correct way?

Should I add the new custom message into ardupilotmega.xml (instead of common.xml)??

Just found that I could send this particular custom mavlink message from QGCU to Ardupilot.!.

I had inserted debug prints in QGCS to confirm the new message did not arrive. Also checked in QGCS/MavlinkProtocol.cc if the message received with any error [seeing the return values of mavlink_parse_char()]

Resolved the issue!
Thanks to Michael and Francis for the post on
http://diydrones.com/forum/topics/best-practice-for-adding-custom-mavlink-command.
This link talks about rebuilding mavproxy when new custom message is added. After rebuilding, I am able to receive custom message on QGC.

I am working of Qgroundcontrol and i want to receive distance sensor message at custom command widget with the help of QML file.
So, If anyone have distance sensor receive message QML code file please share with me and guide me.

Hi everybody,

Im sending a mavlink_msg_named_value_int message, i receive it properly but i dont know in wich parameters the data is stored. I want to know the name of the parameters to put the info on a custom widget.
Can someone help me with this?

Thanks

how do you send the data of the distance sensor?
Probably, your are in the same point that me, see the data on the Qgc UI

Qml does not have access to all mavlink messages. Only the values which are plumbed through vehicle.

yes, I am also trying to receive distance sensor data in custom widget.

I am able to receive Lidar distance sensor data at analyze widget plot in Qgroundcontrol but I want to receive this data at custom widget in Qgroundcontrol.

I downloaded Qgroundcontrol source code and I was searching the analyze plot widget code in source code but i didnt get.

And you know where is code of analyze plot widget in source code of Qgroundcontrol.

Please help me.

How can i use mavlink telemetry with dragon link Version 3?

@Bean Set it up according to DragonLink’s instructions on how to connect the Rx to a Pixhawk. PeteFliesDrones might be a good start. You can also check out the RCGroups forum.

Good luck.

Hi, I send the data on a custom message and i can see it in analyze window without changing the code. But, for now, i really dont know how to create in the code a new widget.

Exists the option of the custom widget thats provides QGC but, there you can only show the same parameters that QGC shows in Settings.

when you want to find something on a code, de best way to find it, for me, its to use the CTRL+F command, in this case, in Github you can use the option Find File. If you write Analyze ther you can probably find all you need to start, but dont forget to try to understand the code cause prbably there are more files involucred that those that Find File shows you.

Sorry for my English, i really dont know more about it, Im learning too