Sending custom values via python from on board computer to Cockpit

As mentioned in a previous thread,

I am trying a similar thing, where I want to send x,y,z values from a custom IMU sensor(connected to BlueOS-Raspberrypi via USB) to a custom widget made on the Cockpit.
I cannot just use Bridges to forward the sensor data, as sensor uses RS485 ModBus, hence I need a script to read it.
The python script to read the values from the sensor is ready, I am stuck at a point where I do not know the right URL, and the right method to send the NAMED_VALUE_FLOAT to cockpit.

I have tried sending dummy STATUSTEXT messages to QGroundControl via pymavlink, and it has worked. But as I want a custom widget, I need to use Cockpit, and from what I know, Cockpit does not communicate like QGC does(via Bare UDP).
Please help!
Thanks in advance.

Hi @VShiva1 -
You can see an example of how to do this in this extension, here.

The correct target address, when executing from within a docker container, is ‘http://host.docker.internal:6040/v1/mavlink’,

Packaging your script in an extension is a great way to make it easier to setup in the future!

Also, regardless of the protocol, you can use USBIP or VirtualHere to connect any USB device plugged into your vehicle’s Pi to your topside computer - in this way any vendor software can be “tricked” into thinking the hardware it is intended to connect to is attached, locally.

Is there a reason you’re not connecting the external IMU to the vehicle’s autopilot, so that it can be used to improve navigation performance?

Hi, I appreciate the fast reply!

The External IMU is for a completely different reason(an underwater manipulator feedback).

Also, regardless of the protocol, you can use USBIP or VirtualHere to connect any USB device plugged into your vehicle’s Pi to your topside computer - in this way any vendor software can be “tricked” into thinking the hardware it is intended to connect to is attached, locally.

Yes, actually I have been using VirtualHere for testing purposes, and it has been great. Now I want to integrate my IMU with the BlueOS system instead of having multiple Software.

I understand that extension is the way to go, and I will, in the future. But currently I don’t want to deal with docker.

Please check if the following idea works:
After the last post, I came to know that I can use iframe widget in cockpit, and that seems like an ideal choice for me. But instead of making a webserver as an extension, can I just deploy a small Flask-Socketio server on the Pi itself, and connect the iFrame to this URL? Wouldn’t this work? Am I missing anything? No need to make an extension, just a python script, and an html page.

Thankyou and Regards.

Update

As I mentioned in my previous reply,

I tried this, and it worked. So, for testing purposes I could send data to iframe through local python script. Once all the parts of my system are up and running, and we are decided on the correct process, I will switch over to extensions.

Thankyou very much for all you help.

1 Like

Hi @VShiva1 -
Checkout this new example, based on functionality available in Cockpit 's latest beta releases.

1 Like