Forwarding Vehicle Data to Another Vehicle for FOLLOW

Hi,

I am new to ArduPilot and am having some issues setting up a follow scenario in a SITL configuration. I am running two ArduCopters in a Docker container and controlling them via MAVProxy and QGroundControl. Here’s how I launch my simulation to successfully simulate two drones:

Drone 1 Setup

For Drone 1 SITL:

cd ardupilot
sudo docker run --network host -it --rm -v $PWD:/ardupilot ardupilot-dev bash -c "cd ArduCopter && sim_vehicle.py -v ArduCopter -I0 --sysid 1 --console --map --out=udp:127.0.0.1:14550 -w"

For Drone 1 MAVProxy:

cd ardupilot
mavproxy.py --master=udp:127.0.0.1:14550
output add 127.0.0.1:14560

Drone 2 Setup

For Drone 2 SITL:

cd ardupilot
sudo docker run --network host -it --rm -v $PWD:/ardupilot ardupilot-dev bash -c "cd ArduCopter && sim_vehicle.py -v ArduCopter -I1 --sysid 2 --console --map --out=udp:127.0.0.1:14551 -w"

For Drone 2 MAVProxy:

cd ardupilot
mavproxy.py --master=udp:127.0.0.1:14551
output add 127.0.0.1:14560

To set up for Drone 2 following Drone 1, I created ardupilot/ArduCopter/scripts/modules/MAVLink and pulled Lua from the ArduPilot repo

On Drone 1, I run param set SCR_ENABLE 1, then a reboot, and after rebooting, I see it successfully load follow-target-send.lua. I can also watch FOLLOW_TARGET and see data moving. I then run param set FOLT_ENABLE 1, set mode to guided, takeoff, and move to some other position. On Drone 2, I run param set FOLL_ENABLE 1 and param set FOLL_SYSID 1.

The issue I have not been able to solve is how I set up the networking, such that the follow target data is transferred to Drone 2. I have tried adding an additional output to Drone 1’s MAVProxy and an additional master to Drone 2’s MAVProxy (or adding an additional output to Drone 1’s SITL launcher). However, I am never able to get Drone 2 to follow Drone 1.

If anyone could provide some information on this topic, it would be greatly appreciated.

You should connect both drones to one MavProxy instance then it should route the messages as required.

Tried that and could never get it to work. I ended up getting it working like this:

Follow Example

This section describes how to set up Vehicle 2 following Vehicle 1. This requires 3 terminals (plus 1 for launching QGroundControl).

QGroundControl Setup

First, open QGroundControl


cd QGroundControl

./QGroundControl-x86_64.AppImage

Note: With the following multicast settings, QGroundControl should automatically connect to both vehicles as they come up

MAVProxy Setup

In the first terminal, run


cd ardupilot

mavproxy.py --master=mcast:

Drone 1 Setup

In the second terminal, run the following


cd ardupilot

sudo docker run --network host -it --rm -v $PWD:/ardupilot ardupilot-dev bash -c "cd ArduCopter/UAS_Leader && sim_vehicle.py -v ArduCopter -I0 --sysid 1 --console --map --out=udp:127.0.0.1:14550 -w --mcast"

Drone 2 Setup

In the last terminal, run the following


cd ardupilot

sudo docker run --network host -it --rm -v $PWD:/ardupilot ardupilot-dev bash -c "cd ArduCopter/UAS_Follower && sim_vehicle.py -v ArduCopter -I1 --sysid 2 --console --map --out=udp:127.0.0.1:14551 -w --mcast"

MAVProxy should now be connected to both vehicles via the same link (look for Detected vehicle 1:1 on link 0 and Detected vehicle 2:1 on link 0). We will first configure Drone 1 (leader) via the open MAVProxy terminal.


# Enable scripting to start Lua scripts for outputting leader position data. Then reboot

vehicle 1

param set SCR_ENABLE 1

reboot

# Wait for reboot to complete, then run continue

param set FOLT_ENABLE 1

# Set to guided so we can takeoff

mode guided

Now configure Drone 2 in MAVProxy


vehicle 2

param set FOLL_ENABLE 1

param fetch

param set FOLL_SYSID 1

param set FOLL_DIST_MAX 0

# Set to guided temporarily so we can takeoff

mode guided

Now that both drones are configured, use QGroundControl to make both vehicles takeoff. Once each vehicle is in the air, run the following on Drone 2 in MAVProxy


mode follow

This should trigger an output like AP: N-E-D follow offset loaded. Now, use QGroundControl to move Drone 1 somewhere. Drone 2 should follow.

Note: If any param set ... commands fail, try running param fetch, and then try again