-
Notifications
You must be signed in to change notification settings - Fork 2
/
start_sitl_fleet.sh
107 lines (88 loc) · 2.33 KB
/
start_sitl_fleet.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/sh
HELP_MSG="
Usage:
-h, --help Help message
--loc=/path/to/ardupilot Set the location of your ArduPilot directory
--ip=x.x.x.x Set the CloudStation IP
--udp=xxxxx Set the first open UDP port
For more details see README"
# Configurables
ARDUPILOT_LOC="/path/to/ardupilot" # Location of ardupilot, either absolute path or relative to where this script is being executed from
CLOUDSTATION_IP="54.219.7.188" # IP of CloudStation instance
UDP_PORT=14550 # First UDP open port on CloudStation (will be incremented for each drone)
CUSTOM_LOC="" # First Location of the drone
if [[ $4 ]]; then
CUSTOM_LOC=$4
fi
args="" # Other args
counter=1
for arg in "$@"
do
if [ $counter -ge 5 ]; then
args+="$arg "
((counter++))
fi
done
# Command Line Args
for arg in "$@"
do
case $arg in
-h|--help)
echo "$HELP_MSG"
exit 0
;;
--loc=*)
ARDUPILOT_LOC="${arg#*=}"
shift # Remove --cache= from processing
;;
--ip=*)
CLOUDSTATION_IP="${arg#*=}"
shift # Remove --cache= from processing
;;
--udp=*)
UDP_PORT="${arg#*=}"
shift # Remove --cache= from processing
;;
*)
shift # Remove generic argument from processing
;;
esac
done
echo "Note: It is not recommended to generate multiple instances of a vehicle when running it for the first time, as it will need to be compiled.
"
echo "ArduPilot location: $ARDUPILOT_LOC"
echo "CloudStation IP: $CLOUDSTATION_IP"
echo "First open UDP port: $UDP_PORT"
echo "
# of copters to start:"
read copters
# echo "# of planes to start:"
# read planes
# echo "# of subs to start:"
# read subs
echo "
# of rovers to start:"
read rovers
vehicle=0
cd $ARDUPILOT_LOC
echo "
Launching $copters copters..."
for (( i=0; i<copters; i++ ))
do
echo "Assigning UDP port $UDP_PORT"
mintty Tools/autotest/sim_vehicle.py -v ArduCopter --no-extra-ports -I $vehicle --out=udp:$CLOUDSTATION_IP:$UDP_PORT $CUSTOM_LOC $args &
((UDP_PORT++))
((vehicle++))
sleep 8s
done
# Launch Rovers
echo "
Launching $rovers rovers..."
for (( i=0; i<rovers; i++ ))
do
echo "Assigning UDP port $UDP_PORT"
mintty Tools/autotest/sim_vehicle.py -v Rover --no-extra-ports -I $vehicle --out=udp:$CLOUDSTATION_IP:$UDP_PORT $CUSTOM_LOC $args &
((UDP_PORT++))
((vehicle++))
sleep 8s
done