2018-09-13 09:49:56 -03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
2016-06-14 06:03:37 -03:00
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
cd "$SCRIPT_DIR/jMAVSim"
|
|
|
|
|
2018-11-13 10:22:35 -04:00
|
|
|
tcp_port=4560
|
2016-10-20 11:50:35 -03:00
|
|
|
extra_args=
|
|
|
|
baudrate=921600
|
|
|
|
device=
|
2017-03-09 06:12:48 -04:00
|
|
|
ip="127.0.0.1"
|
2018-10-04 13:40:06 -03:00
|
|
|
while getopts ":b:d:p:qr:f:i:" opt; do
|
2016-09-19 15:09:12 -03:00
|
|
|
case $opt in
|
2016-10-20 11:50:35 -03:00
|
|
|
b)
|
|
|
|
baudrate=$OPTARG
|
|
|
|
;;
|
|
|
|
d)
|
|
|
|
device="$OPTARG"
|
|
|
|
;;
|
2017-03-09 06:12:48 -04:00
|
|
|
i)
|
|
|
|
ip="$OPTARG"
|
|
|
|
;;
|
2016-09-19 15:09:12 -03:00
|
|
|
p)
|
2018-11-13 10:22:35 -04:00
|
|
|
tcp_port=$OPTARG
|
2016-09-19 15:09:12 -03:00
|
|
|
;;
|
2016-10-20 11:50:35 -03:00
|
|
|
q)
|
|
|
|
extra_args="$extra_args -qgc"
|
|
|
|
;;
|
2017-03-03 12:42:41 -04:00
|
|
|
r)
|
|
|
|
extra_args="$extra_args -r $OPTARG"
|
|
|
|
;;
|
2018-10-04 13:40:06 -03:00
|
|
|
f)
|
|
|
|
extra_args="$extra_args -f $OPTARG"
|
|
|
|
;;
|
2016-09-19 15:09:12 -03:00
|
|
|
\?)
|
|
|
|
echo "Invalid option: -$OPTARG" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2016-10-20 11:50:35 -03:00
|
|
|
if [ "$device" == "" ]; then
|
2018-11-13 10:22:35 -04:00
|
|
|
device="-tcp $ip:$tcp_port"
|
2016-10-20 11:50:35 -03:00
|
|
|
else
|
|
|
|
device="-serial $device $baudrate"
|
|
|
|
fi
|
|
|
|
|
2018-09-13 09:50:15 -03:00
|
|
|
# jMAVSim crashes with Java 9 on macOS, therefore we need to use Java 8
|
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
|
|
bold=$(tput bold)
|
|
|
|
normal=$(tput sgr0)
|
|
|
|
if ! /usr/libexec/java_home -V 2>&1 | grep --quiet "Java SE 8" ; then
|
|
|
|
echo "${bold}You need to have Java 8 installed for macOS, for more info, see:${normal}"
|
|
|
|
echo "${bold}https://github.com/PX4/jMAVSim/issues/81${normal}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
|
|
|
|
fi
|
|
|
|
|
2016-06-14 06:03:37 -03:00
|
|
|
ant create_run_jar copy_res
|
|
|
|
cd out/production
|
2017-10-26 10:02:20 -03:00
|
|
|
|
|
|
|
java -XX:GCTimeRatio=20 -Djava.ext.dirs= -jar jmavsim_run.jar $device $extra_args
|
|
|
|
ret=$?
|
|
|
|
if [ $ret -ne 0 -a $ret -ne 130 ]; then # 130 is Ctrl-C
|
|
|
|
# if the start of java fails, it's probably because the GC option is not
|
|
|
|
# understood. Try starting without it
|
|
|
|
java -Djava.ext.dirs= -jar jmavsim_run.jar $device $extra_args
|
|
|
|
fi
|
|
|
|
|