ArduPilot / MissionPlanner

Mission Planner Ground Control Station for ArduPilot (c# .net)
http://ardupilot.org/planner/
GNU General Public License v3.0
1.81k stars 2.42k forks source link

Add MAVLink forwarding via WebSocket server #3423

Closed IamPete1 closed 1 month ago

IamPete1 commented 1 month ago

This adds forwarding to WebSockets. I have only tested sending from MissionPlanner to the WebSocket not the other way (my application does not support send). So far I have been using pymavlink with https://github.com/ArduPilot/pymavlink/pull/967.

This very hacky currently. It doesn't work if you open the same connection more than once for example. I'm not cleaning up correctly I guess, but this is right on the edge of my c# knowledge.

This does add Fleck as a new dependency, it makes the server stuff easier. https://github.com/statianzo/Fleck

This is more or less a Fleck example and code copied from the existing client WebServer stuff.

meee1 commented 1 month ago

https://github.com/ArduPilot/MissionPlanner/blob/693c6e3445af310d90fe90daa29f40df6bd64fc6/Utilities/httpserver.cs#L180

This is the internal server I mentioned.

Looks like your code is a client though, vs the existing is serverside

meee1 commented 1 month ago

My use case was a browser connecting to MP as the data source

Yours is to push data to somewhere?

meee1 commented 1 month ago

https://github.com/ArduPilot/MissionPlanner/blob/693c6e3445af310d90fe90daa29f40df6bd64fc6/ExtLibs/Comms/CommsWebSocket.cs#L16

This one is for connecting to a socketio ws service as a client

IamPete1 commented 1 month ago

My use case was a browser connecting to MP as the data source

Yours is to push data to somewhere?

Right, mission planner connects directly to the vehicle then it forwards onto a web based dashboard.

meee1 commented 1 month ago

I assume you have something working? As I would have thought the dashboard makes the connection to the backend vs the backend connecting to the frontend

Ws://127.0.0.1:56781/websocket/server

Ws://127.0.0.1:56781/websocket/raw

Http://127.0.0.1:56781/hud.html

Example

     https://yar.oborne.me/
IamPete1 commented 1 month ago

I assume you have something working?

https://github.com/IamPete1/WebTools/tree/MAVLink_Dashboard

As with all the WebTools it is 100% client side, so the only option we have is WebSocket client (we could do direct COM ports too but I haven't implemented).

IamPete1 commented 1 month ago

Turns out MissionPlanner already forwards on ws://127.0.0.1:56781. So we don't need this PR. https://github.com/ArduPilot/WebTools/pull/196 adds auto connection.