Hello everyone. I have been working on autonomous swarms for a long time. For some of my experiments, I need to connect to the same device with different python scripts for operations such as sharing telemetry or GPS status on a vehicle. For example, while one of my py files is listening to telemetry, the other py file needs to subscribe to different topics such as GPS status. However, when I try to open different connections, I get the Service.UNAVAILABLE message and lose all my connections. I am waiting for your help, thank you.
Hi.Practically you can’t establish two connection with one physical port same time. But you can use mavlink-router two redirect mavlink connection to other ports. For example you connected your hardware serial serial0 (like raspberry or jetson) to telem2 port and mavlink stream sending telemetry data like gps,airspeed,lidar etc. After this point you can’t listen this port from two python script at the same time. Instead of this;
You should start a mavlink-router which is listenin serial0 and redirecting the stream to two port like udp 14551 and udp 14552. Now you can start two seperate python script one of them will connect 14551 and one of them to 14552.
Something like this(from mavlink router doc)
Starting mavlink router and route serial to two udp
$ mavlink-router -e 127.0.0:14551 -e 127.0.0.1:14552 /dev/ttyS1:115200
From your first .py script
ConnectionResult connection_result = mavsdk.add_any_connection("udp://:14551”);
From your second .py script
ConnectionResult connection_result = mavsdk.add_any_connection("udp://:14552");
To sum up;
You should use mavlink router.
Hello again everyone. I am doing the solution using a router as you mentioned. But my question was a little different. Actually when I create a connection with masdk, a system class freezes and there is a mavsdk_server that is started in the background. My exact question is whether it is possible to have a mavsdk_server and multiple connections or is there a workaround? When I open a connection without using a router, when I give the mavsdk server ports that will be started in the background starting from 50051, I have an alternative solution with different mavsdk_servers. But as the name suggests, multiple connection on a server and a mavsdk_server. Right now, each different server that starts puts a load on my processor and capacity at the end of the day.
Sorry for misunderstood. As far as I know mavsdk_server not supporting this. But may be it can possible with latest developments.