Modifying MP to graph extra data in real-time

Hi all.

I am working on a project that integrates an airborne sensor (optical particle sensor) with the pixhawk. The desire is to send the ash data down to the ground station and graph this in real time in order to correlate the various properties of an ash cloud with the flight data (altitude/pressure/temperature etc…)

For now, I have changed arduplane to send some arbitrary hard-coded bytes in a MAVLink packet from the pixhawk to the GCS. This has been implemented by extending STREAM_EXTRA3. I have confirmed the packets are arriving by looking through the .rlog file and searching for the message ID and hard-coded message byte values.

I have sinced changed the message definitions file in the MP source and recompiled. The data is now featured in the .tlog which will be useful for parsing and graphing time-domain signals post-flight with a python script. However, I still want to implement real-time graphing with MP.

I only have experience with C so my best guesses have been by searching through the CS source and mirroring the code used to graph other flight data.

So far I have been through the GCSviews designer files, and found the code that brings up the checkbox options for graphing after double-clicking the graph that is featured after checking the CB_tuning checkbox. I can see that the code iterates through the variables in the current state object(class?). I have been through that file and can see the variables match the order in the check box window. I (perhaps naively) added variables for my ash bytes at the bottom:

public byte ash_test_1 { get; set; }

public byte ash_test_2 { get; set; }

public byte ash_test_3 { get; set; }

I then added to the function that extracts the MAVLink data from the message the following code:

        mavLinkMessage = MAV.getPacket((uint)MAVLink.MAVLINK_MSG_ID.ASH_DATA);
        if (mavLinkMessage != null)
        {
            var ash = mavLinkMessage.ToStructure<MAVLink.mavlink_ash_data_t>();
            ash_test_1 = ash.ash_test_byte_1;
            ash_test_2 = ash.ash_test_byte_2;
            ash_test_3 = ash.ash_test_byte_3;
        }

I was hoping that this would be okay given that the above functions/defines are implemented in the mavlink.cs file generated from the XML definition.

I re-compiled, executed MP and attempted to view the “live” data from a previous .tlog file but no change to the checkbox GUI.

I understand that this may be only one piece of the puzzle but had hoped it would at least create another 3 check boxes.

I am going to use the debugger and also track through the usage of other real-time graph MAVLink messages to see what else needs to be done. In the meantime I thought I would post here to see if I can get any advice.

Can anyone provide advice on what (else) needs to be changed/added to enable real-time graphing of an extra MAVLink message?

Please let me know if you need more information about my progress to date.

Thanks very much.

Mike Shanaher

1 Like

everything you have done is correct, the issue will be with the data format use in currentstate ie byte, change it to float, and it will show up in the MP tunning screen in flightdata. you can leave the new message as byte, just currentstate needs to change

Thanks very much. You’ve potentially saved me a lot of time and your fast response is much appreciated.

For all interested; it now works.

Mike Shanaher

1 Like

Hi Michael
I’ve working on something similar can you share with me your code or advise me whats part of code may be change to do this?
thanks for helping