Simulate Multiple Vehicles in QGC with DroneKit



I am working on my thesis work and would like to simulate multiple vehicles, and I was just curious if anyone has stumbled on how to simulate multiple vehicles in QGC with DroneKit SITL. Multiple vehicles can be simulated in ROS, but ROS is kind of overkill for what I need to do. I just need to simulate the flights and the drone routes and not necessarily anything else.




You might also ask here
Can use Mission Planner for this




This video helped, too:
Basically just needed to start 3 different instances at different TCP and UDP ports and then connect them all with QGroundControl. Had to modify the params file too to give them all unique IDs but it seems to be working.


Would you mind sharing the detailed steps required to do this so other folks can learn this (me too)?


Yeah, definitely! My goal was to simulate 3 drones in QGC and program them all to do separate things, so I will describe the steps I took to simulate just the 3 vehicles.

  1. First step is to modify the drone parameters file used when starting the SITL instance. In the drone programming course, this is the /courseRoot/apm/ardupilot/Tools/autotest/default_params/copter.parm file.

I created 2 new parameter files and named them copter2.parm and copter3.parm. In copter.parm I added the following parameter: SYSID_THISMAV 1

Then I did the same thing for the other two files but with different ID numbers. SYSID_THISMAV 2 in copter2.parm and SYSID_THISMAV 3 in copter3.parm

This allows QGC to register them as different vehicles.

  1. Starting three SITL instances

I used three terminals to launch three sitl instances and three terminals to connect each one to mavproxy.

terminal 1 for vehicle 1 SITL: /path/to/courseRoute/apm/ardupilot/build/sitl/bin/arducopter -S -I0 --home 33.779131,-84.402921,584,353 --instance 1 --model “+” --speedup 1 --defaults /path/to/courseRoute/apm/ardupilot/Tools/autotest/default_params/copter.parm

terminal 2 for vehicle 2 SITL: /path/to/courseRoute/apm/ardupilot/build/sitl/bin/arducopter -S -I0 --home 33.774938,-84.397531,584,353 --instance 2 --model “+” --speedup 1 --defaults /path/to/courseRoute/apm/ardupilot/Tools/autotest/default_params/copter2.parm

terminal 3 for vehicle 3 SITL: /path/to/courseRoute/apm/ardupilot/build/sitl/bin/arducopter -S -I0 --home 33.781380,-84.402856,584,353 --instance 3 --model “+” --speedup 1 --defaults /path/to/courseRoute/apm/ardupilot/Tools/autotest/default_params/copter3.parm

These commands start three instances where a vehicle 1 uses tcp 5770, vehicle 2 uses tcp 5780, and vehicle 3 uses tcp 5790. The home location coordinates can be changed as well.

  1. Connecting to mavproxy
    Three terminals were used for connecting to the SITL instances. This is where something like tmux comes in handy.
    Connecting to vehicle 1 in terminal 4: --master tcp: --out --out

Connecting to vehicle 2 in terminal 5: --master tcp: --out udp: --out

Connecting to vehicle 3 in terminal 6: --master tcp: --out udp: --out

  1. Connecting to QGC
    Now each SITL vehicle instance should be connected to mavproxy, and just needs to be connected to QGC. Inside the “Application Settings” of QGC, there is a “Comms Link” tab. You can add connections there to connect to the multiple vehicles. When adding a comm link, select UDP as the type. For vehicle 1 this port is 14550. This process can be repeated to add vehicle 2 and vehicle 3. The port for vehicle 2 is 14551 and the port for vehicle 3 is 14552. It may not connect automatically, so you can click each connection you added and press “Connect” at the bottom. This should connect each vehicle and there should be 3 vehicles in the QGC map. Two will be faded but you can switch between the vehicles with the drop down option at the top.

  2. Programming each drone
    Now the programming is pretty much the same as it is described in the programming course. The only difference is in adding vehicles in the script, you are going to use “” as the connection string for vehicle 1. Vehicle 2 connection string = “” and vehicle 3 connection string = “”. With these, you can create 3 instances of vehicles in a python script and program them each individually. After that, the sky’s the limit!

I hope this was clear.


This is great. Thanks for sharing.