Simulate Multiple Vehicles in QGC with DroneKit


#1

Hey,

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.

Thanks,

Jeff


#2

You might also ask here
https://discuss.ardupilot.org/c/arducopter/copter-simulation/42
Can use Mission Planner for this
https://discuss.ardupilot.org/t/how-to-create-multiple-drone-for-sitl/45007


#3

Thanks!


#4

This video helped, too: https://www.youtube.com/watch?v=UWsya46ZG4M
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.


#5

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


#6

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: mavproxy.py --master tcp:127.0.0.1:5770 --out 127.0.0.1:14550 --out 127.0.0.1:14553

Connecting to vehicle 2 in terminal 5: mavproxy.py --master tcp:127.0.0.1:5780 --out udp:127.0.0.1:14551 --out 127.0.0.1:14554

Connecting to vehicle 3 in terminal 6: mavproxy.py --master tcp:127.0.0.1:5790 --out udp:127.0.0.1:14552 --out 127.0.0.1:14555

  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 “127.0.0.1:14553” as the connection string for vehicle 1. Vehicle 2 connection string = “127.0.0.1:14554” and vehicle 3 connection string = “127.0.0.1:14555”. 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.


#7

This is great. Thanks for sharing.