-
Notifications
You must be signed in to change notification settings - Fork 47
/
entrypoint.sh
69 lines (59 loc) · 1.65 KB
/
entrypoint.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
#!/bin/bash
function show_help {
echo ""
echo "Usage: ${0} [-h | -v VEHICLE | -w WORLD] [HOST_API | HOST_QGC HOST_API]"
echo ""
echo "Run a headless px4-gazebo simulation in a docker container. The"
echo "available vehicles and worlds are the ones available in PX4"
echo "(i.e. when running e.g. \`make px4_sitl gazebo_iris__baylands\`)"
echo ""
echo " -h Show this help"
echo " -v Set the vehicle (default: iris)"
echo " -w Set the world (default: empty)"
echo ""
echo " <HOST_API> is the host or IP to which PX4 will send MAVLink on UDP port 14540"
echo " <HOST_QGC> is the host or IP to which PX4 will send MAVLink on UDP port 14550"
echo ""
echo "By default, MAVLink is sent to the host."
}
function get_ip {
output=$(getent hosts "$1" | awk '{print $1}')
if [ -z $output ];
then
# No output, assume IP
echo $1
else
# Got IP, use it
echo $output
fi
}
OPTIND=1 # Reset in case getopts has been used previously in the shell.
vehicle=iris
world=empty
while getopts "h?v:w:" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
v) vehicle=$OPTARG
;;
w) world=$OPTARG
;;
esac
done
shift $((OPTIND-1))
if [ "$#" -eq 1 ]; then
IP_QGC=$(get_ip "$1")
elif [ "$#" -eq 2 ]; then
IP_API=$(get_ip "$1")
IP_QGC=$(get_ip "$2")
elif [ "$#" -gt 2 ]; then
show_help
exit 1;
fi
Xvfb :99 -screen 0 1600x1200x24+32 &
${SITL_RTSP_PROXY}/build/sitl_rtsp_proxy &
source ${WORKSPACE_DIR}/edit_rcS.bash ${IP_API} ${IP_QGC} &&
cd ${FIRMWARE_DIR} &&
HEADLESS=1 make px4_sitl gazebo_${vehicle}__${world}