Hello,
I am trying to fly multiple quadrotors each led by its own ArduCopter SITL instance in AirSim simulation and also aim to control them through MAVROS topics and services with a couple ROS nodes. I do not start any kind of GCS.
I examined how ArduCopter SITL runs through terminal environment and came up with the following (I slightly modified the libraries/SITL/examples/AirSim/follow-copter.sh so that each instance would be controlled by its own SITL, instead of following the quad with SYSID - 1):
for i in $(seq $NCOPTER); do
SYSID=$(expr $i - 1)
echo "Starting copter $SYSID"
mkdir -p copter$SYSID
port=$((14550 + $SYSID * 10))
cat <<EOF > copter$SYSID/identity.parm
SYSID_THISMAV $SYSID
EOF
pushd copter$SYSID
$COPTER --model airsim-copter --uartA udpclient:$GCS_IP:$port --uartC mcast:$MCAST_IP:$port --instance $SYSID --defaults $BASE_DEFAULTS,identity.parm &
popd
done
wait
- MCAST_IP is default multicast IP
- GCS_IP is just 127.0.0.1
- NCOPTER is the argument for how many quads I want to fly/simulate in AirSim
I have managed to run multiple SITLs with distinct UDP ports and connections. However, I have a problem with connecting MAVROS and properly using ROS mechanism. For example,
I have 2 quads with the following distinct arguments:
- –uartA udpclient:127.0.0.1:14550 --instance 0
- –uartA udpclient:127.0.0.1:14560 --instance 1
I launch first MAVROS with the following:
roslaunch mavros apm.launch fcu_url:=“udp://127.0.0.1:14550@14550”
which does not connect to the SITL at all, it just runs the default mavros and waits for an SITL to connect, I guess.
The second one is similar:
roslaunch mavros apm.launch fcu_url:=“udp://127.0.0.1:14560@14560”
which connects to the correct quad, but there is no topic update that one can echo in terminal (e.g. /mavros/global_position/local topic) and after a short while I get the following ROS warning:
[ WARN] [1574759517.528657495]: TM : RTT too high for timesync: 1574759367495.41 ms.
The strange thing is that when I try to arm, change mode of the (second) quad or send position/velocity setpoints via MAVROS, it responds normally, but I can’t see the expected changes in the topics that I wanted to echo in the terminal (can’t echo anything at all).
When I use MAVProxy GCS, it offers 2 UDP output ports for each instance and I can connect MAVROS in that situation, but I do not want to do that because I want to decrease computational overhead.
My questions are:
- SITLs are distinctly running, but how can I connect MAVROS to each?
- What could be the reason behind the huge RTT time? AirSim utilizes GPU resources (it has its own weird problems as well, but that’s a discussion for another post), so I do not think it would cause such problem and with a GCS the RTT drops to normal levels.
- Is there an easier way to achieve what I’m trying to do?
Hope I’ll be understood, sorry for the long post and thanks in advance,
Burak