-
Notifications
You must be signed in to change notification settings - Fork 3
/
startArdu.sh
92 lines (73 loc) · 2.31 KB
/
startArdu.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
#!/bin/bash
numCopters=$1
numRovers=$2
numSubs=$3
numPlanes=$4
initialAgentLat=$5
initialAgentLon=$6
initialAgentAlt=$7
initialAgentHeading=$8
incrementStepLat=$9
incrementStepLon=${10}
COPTERMODEL=${11}
ROVERMODEL=${12}
SUBMODEL=${13}
PLANEMODEL=${14}
SPEEDUP=${15}
incrementStepAlt=0
incrementStepHdg=0
echo "Number of Copters: $numCopters"
echo "Number of Rovers: $numRovers"
echo "Number of Subs: $numSubs"
echo "Number of Planes: $numPlanes"
# Start ArduPilots
LAT=${initialAgentLat}
LON=${initialAgentLon}
ALT=${initialAgentAlt}
HDG=${initialAgentHeading}
echo "Initial Position: $LAT,$LON,$ALT,$HDG"
echo "Increment Lat: $incrementStepLat"
echo "Increment Lon: $incrementStepLon"
echo "CopterModel: $COPTERMODEL"
echo "RoverModel: $ROVERMODEL"
echo "SubModel: $SUBMODEL"
echo "PlaneModel: $PLANEMODEL"
echo "SPEEDUP: $SPEEDUP"
arduPilotInstance=0
if [ $numCopters != 0 ]; then
for i in $(seq 0 $(($numCopters-1))); do
VEHICLE=arducopter
INSTANCE=$arduPilotInstance
export SITL_RITW_TERMINAL="screen -D -m -S Copter${INSTANCE}"
mkdir /${VEHICLE}${INSTANCE} && cd /${VEHICLE}${INSTANCE}
cp /copter.parm copter.parm
echo "SYSID_THISMAV ${INSTANCE}" >> copter.parm
simCommand="/copter/Tools/autotest/sim_vehicle.py \
-I${INSTANCE} \
--vehicle ArduCopter -f gazebo-iris \
--custom-location=${LAT},${LON},${ALT},${DIR} \
-w \
--speedup ${SPEEDUP} \
--add-param-file copter.parm \
--no-rebuild \
--no-mavproxy"
echo "Starting Sim ${VEHICLE} with command '$simCommand'"
exec $simCommand &
pids[${arduPilotInstance}]=$!
#Make it so all the instances don't start at the same Lat/Lon
LAT=$(echo "$LAT + $incrementStepLat" | bc)
LON=$(echo "$LON + $incrementStepLon" | bc)
ALT=$(echo "$ALT + $incrementStepAlt" | bc)
HDG=$(echo "$HDG + $incrementStepHdg" | bc)
# Increment arduPilotInstance
let arduPilotInstance=$(($arduPilotInstance+1))
# This shouldn't be necessary, but let's give it some time to spin-up
sleep 3
done
fi
#sleep 3
#screen -list
# wait for all pids
for pid in ${pids[*]}; do
wait $pid
done