Problem with simulating multiple vehicles in ArduPilot SITL through QGroundControl

I am new to everything in ArduPilot and unmanned vehicle control in general. I am hoping someone here can shed some light on what I am struggling with.

By referring to the instructions at iq_tutorials/swarming_ardupilot.md at master · Intelligent-Quads/iq_tutorials · GitHub, I wanted to simulate multiple vehicles with ArduPilot SITL and QGroundControl, either with MAVProxy or not (I am unsure the benefits of including or excluding MAVProxy in this architecture), but I have always failing to achieve it. Importantly, I do not yet want to involve Gazebo at this time. Specifically, what I have done is as follows. I am running QGroundControl 4.2.6, MAVProxy 1.8.59 on Ubuntu 18.04.6 LTS.

(1) In the file /ardupilot/Tools/autotest/pysim/vehicleinfo.py, I added the following texts under the “Rover” section

            "swarm-rover-1": {
                "waf_target": "bin/ardurover",
                "default_params_filename": ["default_params/rover.parm",
                                            "default_params/swarm-rover-1.parm"]
            },

            "swarm-rover-2": {
                "waf_target": "bin/ardurover",
                "default_params_filename": ["default_params/rover.parm",
                                            "default_params/swarm-rover-2.parm"]
            },

            "swarm-rover-3": {
                "waf_target": "bin/ardurover",
                "default_params_filename": ["default_params/rover.parm",
                                            "default_params/swarm-rover-3.parm"]
            },

(2) In the folder /ardupilot/Tools/autotest/default_params, I added the files swarm-rover-1.parm, swarm-rover-2.parm, and swarm-rover-3.parm. Those files essentially have the same content, except that the SYSID_THISMAV is assigned to 1, 2, or 3 accordingly. Please see an example content as follows.

ARSPD_PIN 1
ARSPD_BUS 2
ATC_SPEED_P 0.1
ATC_STR_RAT_FF 0.75
BATT_MONITOR 4
CRUISE_SPEED 5
CRUISE_THROTTLE 30
INS_ACC2OFFS_X 0.001
INS_ACC2OFFS_Y 0.001
INS_ACC2OFFS_Z 0.001
INS_ACC2SCAL_X 1.001
INS_ACC2SCAL_Y 1.001
INS_ACC2SCAL_Z 1.001
INS_ACCOFFS_X 0.001
INS_ACCOFFS_Y 0.001
INS_ACCOFFS_Z 0.001
INS_ACCSCAL_X 1.001
INS_ACCSCAL_Y 1.001
INS_ACCSCAL_Z 1.001
MODE3 11
MODE4 10
MODE5 2
RC1_MAX 2000
RC1_MIN 1000
RC3_MAX 2000
RC3_MIN 1000
RELAY_PIN 1
RELAY_PIN2 2
SERVO1_MIN 1000
SERVO1_MAX 2000
SERVO3_MAX 2000
SERVO3_MIN 1000
# for brushed control
SIM_PIN_MASK 127
WP_RADIUS 3
WP_SPEED 5
INS_LOG_BAT_MASK 127
SYSID_THISMAV 1

(3) Now, in QGroundControl > Application Settings > Comm Links, I added the following links.
Screenshot from 2023-04-27 17-49-30

(4) Then, when I run the command sim_vehicle.py -v Rover -f swarm-rover-1 --console -I0 --out=tcpin:0.0.0.0:8100 --console -w in a new terminal window, I can already receive the following error, without even trying to start the second vehicle in another terminal. Even when I select the created link “drone1” in QGroundControl > Application Settings and press the Connect button, it does not help.
In addition, I found that, once the Connect button is pressed, there will be no effect of pressing the Disconnect button.

SIM_VEHICLE: “mavproxy.py” “–out” “127.0.0.1:14550” “–out” “127.0.0.1:14551” “–master” “tcp:127.0.0.1:5760” “–sitl” “127.0.0.1:5501” “–out” “tcpin:0.0.0.0:8100” “–console”
Connect tcp:127.0.0.1:5760 source_system=255
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
Failed to connect to tcp:127.0.0.1:5760 : [Errno 111] Connection refused
SIM_VEHICLE: MAVProxy exited
SIM_VEHICLE: Killing tasks

Really, with very limited knowledge about network communication, I don’t really understand the purpose of the argument --out=tcpin:0.0.0.0:8100 in this case. I know, by default, MAVProxy is set to send and receive message to and from ArduPilot SILT on 127.0.0.1:5760, and MAVProxy is set to forward message out to QGroundControl on 127.0.0.1:14551 (or 127.0.0.1:14550? I am not sure). So, here, the network address 0.0.0.0:8100 is used by QGroundControl to send feedback messages to MAVProxy, as that is a TCP IN address for MAVProxy? Following this logic, the Comm Link section in QGroundControl is only used to define the port for outgoing messages from QGroundControl? Where is the port for incoming messages defined for QGroundControl? Where are those default network addresses defined for MAVProxy?

hi @jgbjcn , were you able to solve the issue?
I was solving same issue, only for different model and with gazebo :slight_smile: I am also unable to connect to simulation when running sim_vehicle.py -v ArduCopter -f gazebo-drone1 -I0, but when i run the simulation with sim_vehicle.py -v ArduCopter -f gazebo-drone1 -I0 **--no-mavproxy** and then I run mavproxy on my own it works - mavproxy.py --master=tcp:0.0.0.0:5760 --out=udpin:0.0.0.0:14550 and in QGC only create a link with 0.0.0.0:14550 as server and choose any free port on your local.

1 Like