Sending Node Red Data to Mavlink for use in Cockpit

I have been trying to find a way to do some simple math and send the data to cockpit. The simple math is adding the water depth plus the rangefinder distance to get the total water depth I used node red to grab the information and then send it to mavlink to open it into cockpit as a data display.

What I have managed to do is send the data to mavlink but Cockpit doesn’t seem to be able to access it. I have tried enabling pirate mode and Data lake but it still wont show up.

see the Node-red program I made below. Does anyone know what I am missing?

flows (1).json (7.0 KB)

Eventually what i would also like to do is display a chart showing the total water depth and the ROV depth simultaneously.

This also would bee a nice feature if it was built in cockpit to allow using multiple data streams for simple math and data charts with multiple sources displaying various custom data.

Going further updating ping viewer to account for the ROV depth when displaying signal beam depth could be a neat feature.

Hi @CUIS,

Cockpit already has access to the MAVLink data - why not just add the values together with a compound data lake variable, after which you can display the value in an indicator, and/or a plotter?

I’m not sure what value Node-RED provides here, and I suspect it adds some non-negligible complexity and extra configuration.

I suggested something like that a few years ago, but we unfortunately haven’t got around to implementing it yet.

That’s already possible, just not yet on a single plotter widget. That said, in the upcoming Cockpit 1.18 it will be possible to set fixed axis bounds, in which case you could stack multiple plotters with transparent backgrounds (and the stats hidden) to have multiple plots compared with each other.

Cool idea - I’ve raised an Issue for it :slight_smile:

Thanks, I will see if I can figure this out.

That solution could work, but it might be a little clunky. It would be much better if we could add multiple data sources to the y-axis, and have options for the x-axis so you could use the x-axis as either distance travelled from, say, the DVL, distance from home, time or any other variable, with the ability to set rules for min or max chart limits and of course some style/colour options

Sure - I was mentioning it as a potential workaround that is already available in existing beta releases.

Agreed, so I’ve raised an Issue for it.

I just have no sense of when that’s likely to be implemented, so the workaround approach might be the most convenient option for a while.

I believe we could do a fairly quick initial implementation.

It’s something a lot of other people would probably benefit from as well. I’ve found myself in the need for that a couple of times already as well.

I’ve added some more details to the Issue, about how I think that could be reasonably achieved.

I’m very focused on docs at the moment, but if someone doesn’t get to this in the next couple of weeks I can likely take a crack at it.

@CUIS I’ve prepared a chat here with some instructions on how to setup a generic websocket connection. I understand it’s not needed in your case since you already have the data in the MAVLink stream, but you can have it as a reference if you want to dig into other approaches in the future.

Keep in mind the Generic WebSocket Connections are a 1.18 feature, so they can only be found on Beta releases for now.

Thank Eliot, I got it working.

{{/mavlink/1/1/RANGEFINDER/distance}} - {{/mavlink/1/1/AHRS2/altitude}}