-
Notifications
You must be signed in to change notification settings - Fork 678
Description
Problem
Currently, pymavlink only supports traditional transports (serial, UDP, TCP) but lacks support for modern web technologies like Socket.IO. This limits integration with web-based ground control stations and systems that operate behind firewalls where Socket.IO's WebSocket fallback mechanisms would be beneficial.
Proposed Solution
Implement a new connection type in pymavlink that supports MAVLink communication over Socket.IO. This would allow users to:
Pass a Socket.IO client object directly to pymavlink
Use a connection URL like socketio://server:port/room/sid for simple setup
Maintain the existing pymavlink API for sending/receiving MAVLink messages
Web-based GCS systems that need to communicate with vehicles via MAVLink
Integrations where MAVLink messages need to traverse firewalls or proxies
Applications using room-based communication models with multiple drones/vehicles
Implementation Details
The implementation would require:
A new MAVLinkSocketIO class extending mavutil.mavfile
A factory function mavlink_connection_socketio()
Enhancement to mavlink_connection() to recognize Socket.IO URLs
Supporting documentation and example scripts
from flask import Flask
from flask_socketio import SocketIO
from pymavlink import mavutil
app = Flask(name)
socketio = SocketIO(app, cors_allowed_origins="*", async_mode='threading')
Create MAVLink connection using the SocketIO server
mav_conn = mavutil.mavlink_connection(socketio)
Now you can use the connection like this
mav_conn.mav.request_data_stream_send(
1, # target_system
1, # target_component
mavutil.mavlink.MAV_DATA_STREAM_ALL,
4, # 4 Hz
1 # Start
)