-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_simulation.sh
executable file
·85 lines (67 loc) · 1.71 KB
/
run_simulation.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
#!/bin/bash
#
# Connect our thermal soaring program to APM:Plane in crrcsim, a simulator
#
# Setup: look at docs/PixhawkSimulation.md
#
# Path to find APM's sim_vehicle.sh script
APM="../ardupilot"
# Configuration
ProxyPort=2050
Script="soaring.py"
# Kill/interrupt all the processes we started on Ctrl+C
intList=()
killList=()
exiting() {
echo "Exiting..."
for i in "${killList[@]}"; do
kill $i &>/dev/null
done
# Otherwise we'll be left with it's child proccesses still running
mavlink="$(pgrep mavlink.py)"
[[ -n $mavlink ]] && kill -INT $mavlink
exit 1
}
trap "exiting" 2 15
# Start the crrcsim simulation
run_simulation() {
crrcsim -i APM &>/dev/null &
killList+=("$!")
}
# Start the autopilot
run_autopilot () {
cd "$APM/Tools/autotest"
./sim_vehicle.sh -v ArduPlane -f CRRCSim -j 4 --console --map --out=127.0.0.1:$ProxyPort
}
# Run our code which connects to the MAVProxy ground station started by the
# autopilot script
run_ourcode() {
xterm -e "python3 \"$Script\" -d" &
killList+=("$!")
}
waitline() {
echo -n "Press enter to continue..."
read
}
run_simulation
# Display message if not in fast mode
if [[ $1 != "-f" ]]; then
cat <<EOF
In the simulator,
Options -> Launch -> Load Preset: Motor
Options -> Airplane -> Select airplane: Flexifly XLM
Options -> Wind, Thermals -> adjust as desired
Press 't' to show thermals
Press 'r' to reset
Once the simulator starts, this window will become a MAVProxy
shell. Type the following to start flying after you get some
messages in the Console about EXF2 IMU0.
wp load ArduPlane-Missions/CMAC-toff-loop.txt
arm throttle
mode auto
EOF
waitline
fi
run_ourcode
run_autopilot
wait