Unable to connect to an offboard API on multi vehicle simulation

Hi, I’m trying to simulate to vehicles on gazebo and control them using a MAVSDK script. At the moment the vehicles appear on gazebo and I can control them on QGC but when I started the script it can connect to any vehicle.

I was looking into configuration files for iris quadrotor and I think that maybe there is a problem on this line:

mavlink start -x -u 14557 -r 4000000 -m onboard -o 14540

I tried to start the mavsdk server manually and it gives me an error because the port is already in use so I suppose Mavlink is routing correctly messages to them. Any idea about the problem?

Also, running multisim on gazebo show me this error:

ERROR [mavlink] Local frame 18 not supported. Unable to publish pose and velocity

Maybe it’s related to the above problem.

Can you share how you connect with MAVSDK?

By default, QGC connects on UDP 14550 and MAVSDK on 14540.

I don’t think the “Local frame …” error is related.

I get some better results. If I simulate using gazebo without ROS all works perfectly. The problem is when I try to use ROS. I started Gazebo-Ros simulation as described on PX4 dev guide and then I try to start mavsdk_server (one for each drone) but it gives an error saying that port is already in use:

For example, for the 2nd server:

./mavsdk_server -p 50041 udp://:14541

[02:55:38|Info ] MAVSDK version: 0.23.0 (mavsdk_impl.cpp:25)
[02:55:38|Debug] New: System ID: 0 Comp ID: 0 (mavsdk_impl.cpp:401)
[02:55:38|Info ] Server started (grpc_server.cpp:38)
[02:55:38|Info ] Server set to listen on (grpc_server.cpp:39)
[02:55:38|Info ] Waiting to discover system on udp://:14541… (connection_initiator.h:22)
[02:55:38|Error] bind error: Address already in use (udp_connection.cpp:85)
[02:55:38|Error] Connection failed: Bind error (connection_initiator.h:48)

Usually ROS orMAVSDK connect on port 14540. So when there is a bind error it means that the port is already occupied.

If you want to use ROS and MAVSDK at the same time one has to use the QGC port on 14550 with one of them or alternatively you have to add a third mavlink instance in the startup script here:

And I think there is a limitation on 3 instances, so you might have to disable the instance communicating to the camera.