2014-04-10 23:29:28 -03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# home location lat, lon, alt, heading
|
|
|
|
LOCATION="CMAC"
|
|
|
|
TRACKER_LOCATION="CMAC_PILOTSBOX"
|
|
|
|
VEHICLE=""
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
FRAME=""
|
2014-05-21 09:13:06 -03:00
|
|
|
NUM_PROCS=1
|
2015-03-27 17:52:53 -03:00
|
|
|
SPEEDUP="1"
|
2014-04-10 23:29:28 -03:00
|
|
|
|
|
|
|
# check the instance number to allow for multiple copies of the sim running at once
|
|
|
|
INSTANCE=0
|
|
|
|
USE_VALGRIND=0
|
|
|
|
USE_GDB=0
|
|
|
|
USE_GDB_STOPPED=0
|
2015-05-22 02:53:54 -03:00
|
|
|
DEBUG_BUILD=0
|
2015-01-28 17:44:59 -04:00
|
|
|
USE_MAVLINK_GIMBAL=0
|
2014-04-10 23:29:28 -03:00
|
|
|
CLEAN_BUILD=0
|
|
|
|
START_ANTENNA_TRACKER=0
|
|
|
|
WIPE_EEPROM=0
|
2014-06-03 20:40:07 -03:00
|
|
|
REVERSE_THROTTLE=0
|
2014-08-09 08:21:27 -03:00
|
|
|
NO_REBUILD=0
|
2014-08-13 07:46:53 -03:00
|
|
|
START_HIL=0
|
2016-05-07 19:09:26 -03:00
|
|
|
SITLRCIN=1
|
2015-11-02 18:53:47 -04:00
|
|
|
EXTRA_ARGS=""
|
2015-05-22 23:22:41 -03:00
|
|
|
MODEL=""
|
2015-05-24 23:11:42 -03:00
|
|
|
BREAKPOINT=""
|
2015-06-19 03:24:07 -03:00
|
|
|
OVERRIDE_BUILD_TARGET=""
|
2015-11-30 23:19:31 -04:00
|
|
|
DELAY_START=0
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH=""
|
2016-01-11 18:20:22 -04:00
|
|
|
MAVLINK_PROTOCOL_VERSION="1"
|
2014-04-10 23:29:28 -03:00
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Usage: sim_vehicle.sh [options] [mavproxy_options]
|
|
|
|
Options:
|
|
|
|
-v VEHICLE vehicle type (ArduPlane, ArduCopter or APMrover2)
|
|
|
|
vehicle type defaults to working directory
|
|
|
|
-I INSTANCE instance of simulator (default 0)
|
|
|
|
-V enable valgrind for memory access checking (very slow!)
|
|
|
|
-G use gdb for debugging ardupilot
|
|
|
|
-g use gdb for debugging ardupilot, but don't auto-start
|
2015-05-24 23:11:42 -03:00
|
|
|
-D build with debugging
|
|
|
|
-B add a breakpoint at given location in debugger
|
2014-04-10 23:29:28 -03:00
|
|
|
-T start an antenna tracker instance
|
2015-11-02 18:53:47 -04:00
|
|
|
-A pass arguments to SITL instance
|
2014-04-10 23:29:28 -03:00
|
|
|
-t set antenna tracker start location
|
|
|
|
-L select start location from Tools/autotest/locations.txt
|
2015-05-06 18:24:55 -03:00
|
|
|
-l set the custom start location from -L
|
2014-04-10 23:29:28 -03:00
|
|
|
-c do a make clean before building
|
2014-08-09 08:21:27 -03:00
|
|
|
-N don't rebuild before starting ardupilot
|
2014-04-10 23:29:28 -03:00
|
|
|
-w wipe EEPROM and reload parameters
|
2014-06-03 20:40:07 -03:00
|
|
|
-R reverse throttle in plane
|
2015-05-23 05:39:26 -03:00
|
|
|
-M enable MAVLink gimbal
|
2014-04-10 23:29:28 -03:00
|
|
|
-f FRAME set aircraft frame type
|
|
|
|
for copters can choose +, X, quad or octa
|
|
|
|
for planes can choose elevon or vtail
|
2015-06-19 03:24:07 -03:00
|
|
|
-b BUILD_TARGET override SITL build target
|
2014-05-21 09:13:06 -03:00
|
|
|
-j NUM_PROC number of processors to use during build (default 1)
|
2014-08-13 07:46:53 -03:00
|
|
|
-H start HIL
|
2015-03-27 17:52:53 -03:00
|
|
|
-S SPEEDUP set simulation speedup (1 for wall clock time)
|
2015-11-30 23:19:31 -04:00
|
|
|
-d TIME delays the start of mavproxy by the number of seconds
|
2016-01-11 18:20:22 -04:00
|
|
|
-P VERSION mavlink protocol version (1 or 2)
|
2014-04-10 23:29:28 -03:00
|
|
|
|
|
|
|
mavproxy_options:
|
|
|
|
--map start with a map
|
|
|
|
--console start with a status console
|
|
|
|
--out DEST start MAVLink output to DEST
|
|
|
|
|
|
|
|
Note:
|
|
|
|
eeprom.bin in the starting directory contains the parameters for your
|
|
|
|
simulated vehicle. Always start from the same directory. It is recommended that
|
|
|
|
you start in the main vehicle directory for the vehicle you are simulating,
|
|
|
|
for example, start in the ArduPlane directory to simulate ArduPlane
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# parse options. Thanks to http://wiki.bash-hackers.org/howto/getopts_tutorial
|
2016-01-11 18:20:22 -04:00
|
|
|
while getopts ":I:VgGcj:TA:t:L:l:v:hwf:RNHeMS:DB:b:d:P:" opt; do
|
2014-04-10 23:29:28 -03:00
|
|
|
case $opt in
|
|
|
|
v)
|
|
|
|
VEHICLE=$OPTARG
|
|
|
|
;;
|
|
|
|
I)
|
|
|
|
INSTANCE=$OPTARG
|
|
|
|
;;
|
|
|
|
V)
|
|
|
|
USE_VALGRIND=1
|
|
|
|
;;
|
2014-08-09 08:21:27 -03:00
|
|
|
N)
|
|
|
|
NO_REBUILD=1
|
|
|
|
;;
|
2014-08-13 07:46:53 -03:00
|
|
|
H)
|
|
|
|
START_HIL=1
|
|
|
|
NO_REBUILD=1
|
|
|
|
;;
|
2014-04-10 23:29:28 -03:00
|
|
|
T)
|
|
|
|
START_ANTENNA_TRACKER=1
|
|
|
|
;;
|
2014-07-23 05:40:13 -03:00
|
|
|
A)
|
2015-11-02 18:53:47 -04:00
|
|
|
EXTRA_ARGS="$OPTARG"
|
2014-07-23 05:40:13 -03:00
|
|
|
;;
|
2014-06-03 20:40:07 -03:00
|
|
|
R)
|
|
|
|
REVERSE_THROTTLE=1
|
|
|
|
;;
|
2014-04-10 23:29:28 -03:00
|
|
|
G)
|
|
|
|
USE_GDB=1
|
|
|
|
;;
|
2015-05-22 02:53:54 -03:00
|
|
|
D)
|
|
|
|
DEBUG_BUILD=1
|
|
|
|
;;
|
2015-11-30 23:19:31 -04:00
|
|
|
d)
|
|
|
|
DELAY_START="$OPTARG"
|
|
|
|
;;
|
2015-05-24 23:11:42 -03:00
|
|
|
B)
|
|
|
|
BREAKPOINT="$OPTARG"
|
|
|
|
;;
|
2015-01-28 17:44:59 -04:00
|
|
|
M)
|
|
|
|
USE_MAVLINK_GIMBAL=1
|
|
|
|
;;
|
2014-04-10 23:29:28 -03:00
|
|
|
g)
|
|
|
|
USE_GDB=1
|
|
|
|
USE_GDB_STOPPED=1
|
|
|
|
;;
|
|
|
|
L)
|
|
|
|
LOCATION="$OPTARG"
|
|
|
|
;;
|
2015-05-06 18:24:55 -03:00
|
|
|
l)
|
|
|
|
CUSTOM_LOCATION="$OPTARG"
|
|
|
|
;;
|
2014-04-10 23:29:28 -03:00
|
|
|
f)
|
|
|
|
FRAME="$OPTARG"
|
|
|
|
;;
|
2015-03-27 17:52:53 -03:00
|
|
|
S)
|
|
|
|
SPEEDUP="$OPTARG"
|
|
|
|
;;
|
2014-04-10 23:29:28 -03:00
|
|
|
t)
|
|
|
|
TRACKER_LOCATION="$OPTARG"
|
|
|
|
;;
|
|
|
|
c)
|
|
|
|
CLEAN_BUILD=1
|
|
|
|
;;
|
2014-05-21 09:13:06 -03:00
|
|
|
j)
|
|
|
|
NUM_PROCS=$OPTARG
|
|
|
|
;;
|
2014-04-10 23:29:28 -03:00
|
|
|
w)
|
|
|
|
WIPE_EEPROM=1
|
|
|
|
;;
|
2015-06-19 03:24:07 -03:00
|
|
|
b)
|
|
|
|
OVERRIDE_BUILD_TARGET="$OPTARG"
|
|
|
|
;;
|
2016-01-11 18:20:22 -04:00
|
|
|
P)
|
|
|
|
MAVLINK_PROTOCOL_VERSION="$OPTARG"
|
|
|
|
;;
|
2014-04-10 23:29:28 -03:00
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
# allow other args to pass on to mavproxy
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
:)
|
|
|
|
echo "Option -$OPTARG requires an argument." >&2
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
|
|
|
|
# kill existing copy if this is the '0' instance only
|
|
|
|
kill_tasks()
|
|
|
|
{
|
|
|
|
[ "$INSTANCE" -eq "0" ] && {
|
2015-05-25 01:10:26 -03:00
|
|
|
for pname in JSBSim lt-JSBSim ArduPlane.elf ArduCopter.elf APMrover2.elf AntennaTracker.elf JSBSIm.exe MAVProxy.exe; do
|
|
|
|
pkill "$pname"
|
|
|
|
done
|
2014-04-10 23:29:28 -03:00
|
|
|
pkill -f runsim.py
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-13 08:33:25 -03:00
|
|
|
if [ $START_HIL == 0 ]; then
|
2014-04-10 23:29:28 -03:00
|
|
|
kill_tasks
|
2015-03-13 08:33:25 -03:00
|
|
|
fi
|
2014-04-10 23:29:28 -03:00
|
|
|
|
|
|
|
trap kill_tasks SIGINT
|
|
|
|
|
|
|
|
# setup ports for this instance
|
|
|
|
MAVLINK_PORT="tcp:127.0.0.1:"$((5760+10*$INSTANCE))
|
|
|
|
SIMOUT_PORT="127.0.0.1:"$((5501+10*$INSTANCE))
|
|
|
|
|
|
|
|
[ -z "$VEHICLE" ] && {
|
2015-08-12 23:02:45 -03:00
|
|
|
CDIR="$PWD"
|
|
|
|
rpath=$(which realpath)
|
2015-08-23 21:47:41 -03:00
|
|
|
[ -n "$rpath" ] && {
|
2015-08-12 23:02:45 -03:00
|
|
|
CDIR=$(realpath $CDIR)
|
|
|
|
}
|
|
|
|
VEHICLE=$(basename $CDIR)
|
2014-04-10 23:29:28 -03:00
|
|
|
}
|
|
|
|
|
2015-04-19 19:36:52 -03:00
|
|
|
[ -z "$FRAME" -a "$VEHICLE" = "APMrover2" ] && {
|
|
|
|
FRAME="rover"
|
|
|
|
}
|
|
|
|
|
2015-05-22 02:53:54 -03:00
|
|
|
[ -z "$FRAME" -a "$VEHICLE" = "ArduPlane" ] && {
|
|
|
|
FRAME="jsbsim"
|
|
|
|
}
|
2015-05-24 23:11:42 -03:00
|
|
|
[ -z "$FRAME" -a "$VEHICLE" = "ArduCopter" ] && {
|
|
|
|
FRAME="quad"
|
|
|
|
}
|
2015-05-31 23:54:06 -03:00
|
|
|
[ -z "$FRAME" -a "$VEHICLE" = "AntennaTracker" ] && {
|
|
|
|
FRAME="tracker"
|
|
|
|
}
|
2015-05-22 02:53:54 -03:00
|
|
|
|
2014-04-10 23:29:28 -03:00
|
|
|
EXTRA_PARM=""
|
2015-03-27 17:52:53 -03:00
|
|
|
|
2015-05-22 23:22:41 -03:00
|
|
|
check_jsbsim_version()
|
|
|
|
{
|
|
|
|
jsbsim_version=$(JSBSim --version)
|
|
|
|
if [[ $jsbsim_version != *"ArduPilot"* ]]
|
|
|
|
then
|
|
|
|
cat <<EOF
|
|
|
|
=========================================================
|
|
|
|
You need the latest ArduPilot version of JSBSim installed
|
|
|
|
and in your \$PATH
|
|
|
|
|
|
|
|
Please get it from git://github.com/tridge/jsbsim.git
|
|
|
|
See
|
2016-04-23 17:51:14 -03:00
|
|
|
http://dev.ardupilot.org/wiki/simulation-2/sitl-simulator-software-in-the-loop/setting-up-sitl-on-linux/
|
2015-05-22 23:22:41 -03:00
|
|
|
for more details
|
|
|
|
=========================================================
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-06 18:10:20 -04:00
|
|
|
autotest="../Tools/autotest"
|
|
|
|
[ -d "$autotest" ] || {
|
|
|
|
# we are not running from one of the standard vehicle directories. Use
|
|
|
|
# the location of the sim_vehicle.sh script to find the path
|
|
|
|
autotest=$(dirname $(readlink -e $0))
|
|
|
|
}
|
|
|
|
|
2014-04-10 23:29:28 -03:00
|
|
|
# modify build target based on copter frame type
|
|
|
|
case $FRAME in
|
2016-04-27 21:05:18 -03:00
|
|
|
+|quad|quad-*)
|
2014-04-10 23:29:28 -03:00
|
|
|
BUILD_TARGET="sitl"
|
2016-04-27 21:05:18 -03:00
|
|
|
MODEL="$FRAME"
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH="$autotest/copter_params.parm"
|
2014-04-10 23:29:28 -03:00
|
|
|
;;
|
2016-04-27 21:05:18 -03:00
|
|
|
X*)
|
2014-04-10 23:29:28 -03:00
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
EXTRA_PARM="param set FRAME 1;"
|
2016-04-27 21:05:18 -03:00
|
|
|
MODEL="$FRAME"
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH="$autotest/copter_params.parm"
|
2014-04-10 23:29:28 -03:00
|
|
|
;;
|
2015-05-24 23:11:42 -03:00
|
|
|
octa*)
|
2014-04-10 23:29:28 -03:00
|
|
|
BUILD_TARGET="sitl-octa"
|
2015-05-24 23:11:42 -03:00
|
|
|
MODEL="$FRAME"
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH="$autotest/copter_params.parm"
|
2015-02-25 00:04:09 -04:00
|
|
|
;;
|
2016-04-21 07:30:15 -03:00
|
|
|
tri*)
|
|
|
|
BUILD_TARGET="sitl-tri"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/tri_params.parm"
|
|
|
|
;;
|
2016-04-21 08:11:56 -03:00
|
|
|
y6*)
|
|
|
|
BUILD_TARGET="sitl-y6"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/y6_params.parm"
|
|
|
|
;;
|
2016-04-21 21:27:42 -03:00
|
|
|
firefly*)
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/firefly.parm"
|
|
|
|
;;
|
2015-06-01 20:08:55 -03:00
|
|
|
heli-dual)
|
2016-01-06 18:10:20 -04:00
|
|
|
BUILD_TARGET="sitl-heli-dual"
|
2015-06-01 20:08:55 -03:00
|
|
|
MODEL="heli-dual"
|
2016-01-06 18:10:20 -04:00
|
|
|
;;
|
2015-06-01 20:08:55 -03:00
|
|
|
heli-compound)
|
2016-01-06 18:10:20 -04:00
|
|
|
BUILD_TARGET="sitl-heli-compound"
|
2015-06-01 20:08:55 -03:00
|
|
|
MODEL="heli-compound"
|
2016-01-06 18:10:20 -04:00
|
|
|
;;
|
2016-04-27 22:33:55 -03:00
|
|
|
heli*)
|
|
|
|
BUILD_TARGET="sitl-heli"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/Helicopter.parm"
|
|
|
|
;;
|
2016-05-26 03:29:37 -03:00
|
|
|
singlecopter*)
|
|
|
|
BUILD_TARGET="sitl-single"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/SingleCopter.parm"
|
|
|
|
;;
|
2016-05-26 04:09:31 -03:00
|
|
|
coaxcopter*)
|
|
|
|
BUILD_TARGET="sitl-coax"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/CoaxCopter.parm"
|
|
|
|
;;
|
2015-04-01 13:14:03 -03:00
|
|
|
IrisRos)
|
|
|
|
BUILD_TARGET="sitl"
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH="$autotest/copter_params.parm"
|
2015-04-01 13:14:03 -03:00
|
|
|
;;
|
2015-07-16 19:30:13 -03:00
|
|
|
Gazebo)
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
MODEL="$FRAME"
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH="$autotest/copter_params.parm"
|
2015-07-16 19:30:13 -03:00
|
|
|
;;
|
2015-05-22 23:22:41 -03:00
|
|
|
CRRCSim|last_letter*)
|
2015-04-17 20:33:33 -03:00
|
|
|
BUILD_TARGET="sitl"
|
2015-05-22 23:22:41 -03:00
|
|
|
MODEL="$FRAME"
|
2015-04-17 20:33:33 -03:00
|
|
|
;;
|
2015-05-22 23:22:41 -03:00
|
|
|
jsbsim*)
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
check_jsbsim_version
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH="$autotest/ArduPlane.parm"
|
2014-08-28 17:58:59 -03:00
|
|
|
;;
|
2016-05-01 19:52:43 -03:00
|
|
|
quadplane-tilttri*)
|
|
|
|
BUILD_TARGET="sitl-tri"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/quadplane-tilttri.parm"
|
|
|
|
;;
|
2015-12-31 23:15:49 -04:00
|
|
|
quadplane*)
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
MODEL="$FRAME"
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH="$autotest/quadplane.parm"
|
2015-12-31 23:15:49 -04:00
|
|
|
;;
|
2016-04-21 21:27:42 -03:00
|
|
|
plane-elevon*)
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/plane-elevons.parm"
|
|
|
|
;;
|
|
|
|
plane-vtail*)
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/plane-vtail.parm"
|
|
|
|
;;
|
|
|
|
plane*)
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/plane.parm"
|
|
|
|
;;
|
2016-05-23 21:21:04 -03:00
|
|
|
rover-skid)
|
|
|
|
BUILD_TARGET="sitl"
|
|
|
|
MODEL="$FRAME"
|
|
|
|
DEFAULTS_PATH="$autotest/Rover-skid.parm"
|
|
|
|
;;
|
2016-05-07 19:09:26 -03:00
|
|
|
flightaxis*)
|
|
|
|
MODEL="$FRAME"
|
|
|
|
SITLRCIN=0
|
|
|
|
;;
|
2016-06-17 19:17:18 -03:00
|
|
|
xplane*)
|
|
|
|
MODEL="$FRAME"
|
|
|
|
SITLRCIN=0
|
|
|
|
;;
|
2015-11-20 06:42:30 -04:00
|
|
|
*-heli)
|
|
|
|
BUILD_TARGET="sitl-heli"
|
|
|
|
MODEL="$FRAME"
|
2016-01-06 18:10:20 -04:00
|
|
|
DEFAULTS_PATH="$autotest/Helicopter.parm"
|
2015-11-20 06:42:30 -04:00
|
|
|
;;
|
2015-06-13 07:07:46 -03:00
|
|
|
*)
|
2015-05-31 23:54:06 -03:00
|
|
|
MODEL="$FRAME"
|
|
|
|
;;
|
2014-04-10 23:29:28 -03:00
|
|
|
esac
|
|
|
|
|
2015-05-22 02:53:54 -03:00
|
|
|
if [ $DEBUG_BUILD == 1 ]; then
|
|
|
|
BUILD_TARGET="$BUILD_TARGET-debug"
|
|
|
|
fi
|
|
|
|
|
2015-06-19 03:24:07 -03:00
|
|
|
if [ -n "$OVERRIDE_BUILD_TARGET" ]; then
|
|
|
|
BUILD_TARGET="$OVERRIDE_BUILD_TARGET"
|
|
|
|
fi
|
|
|
|
|
2015-08-12 23:02:45 -03:00
|
|
|
VEHICLEDIR="$autotest/../../$VEHICLE"
|
|
|
|
[ -d "$VEHICLEDIR" ] || {
|
|
|
|
VEHICLEDIR=$(dirname $(readlink -e $VEHICLEDIR))
|
|
|
|
}
|
|
|
|
pushd $VEHICLEDIR || {
|
|
|
|
echo "Failed to change to vehicle directory for $VEHICLEDIR"
|
2014-04-10 23:29:28 -03:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
}
|
2015-07-09 00:06:35 -03:00
|
|
|
AUTOTEST=$autotest
|
|
|
|
export AUTOTEST
|
2015-05-10 19:06:31 -03:00
|
|
|
VEHICLEDIR=$(pwd)
|
2015-05-25 01:10:26 -03:00
|
|
|
|
|
|
|
if [ $NO_REBUILD == 0 ]; then
|
2014-04-10 23:29:28 -03:00
|
|
|
if [ $CLEAN_BUILD == 1 ]; then
|
2015-05-25 01:10:26 -03:00
|
|
|
echo "Building clean"
|
2014-04-10 23:29:28 -03:00
|
|
|
make clean
|
|
|
|
fi
|
2015-05-25 01:10:26 -03:00
|
|
|
echo "Building $BUILD_TARGET"
|
2014-05-21 09:13:06 -03:00
|
|
|
make $BUILD_TARGET -j$NUM_PROCS || {
|
2014-04-10 23:29:28 -03:00
|
|
|
make clean
|
2015-05-21 19:41:58 -03:00
|
|
|
make $BUILD_TARGET -j$NUM_PROCS || {
|
|
|
|
echo >&2 "$0: Build failed"
|
|
|
|
exit 1
|
|
|
|
}
|
2014-04-10 23:29:28 -03:00
|
|
|
}
|
2014-08-09 08:21:27 -03:00
|
|
|
fi
|
2015-05-25 01:10:26 -03:00
|
|
|
popd
|
2014-04-10 23:29:28 -03:00
|
|
|
|
|
|
|
# get the location information
|
2015-05-06 18:24:55 -03:00
|
|
|
if [ -z $CUSTOM_LOCATION ]; then
|
2015-12-27 01:55:24 -04:00
|
|
|
SIMHOME=$(cat $autotest/locations.txt | grep -i "^$LOCATION=" | head -1 | cut -d= -f2)
|
2015-05-06 18:24:55 -03:00
|
|
|
else
|
|
|
|
SIMHOME=$CUSTOM_LOCATION
|
|
|
|
LOCATION="Custom_Location"
|
|
|
|
fi
|
|
|
|
|
2014-04-10 23:29:28 -03:00
|
|
|
[ -z "$SIMHOME" ] && {
|
|
|
|
echo "Unknown location $LOCATION"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
echo "Starting up at $LOCATION : $SIMHOME"
|
|
|
|
|
|
|
|
TRACKER_HOME=$(cat $autotest/locations.txt | grep -i "^$TRACKER_LOCATION=" | cut -d= -f2)
|
|
|
|
[ -z "$TRACKER_HOME" ] && {
|
|
|
|
echo "Unknown tracker location $TRACKER_LOCATION"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ $START_ANTENNA_TRACKER == 1 ]; then
|
2014-08-14 00:31:06 -03:00
|
|
|
pushd $autotest/../../AntennaTracker
|
2014-04-10 23:29:28 -03:00
|
|
|
if [ $CLEAN_BUILD == 1 ]; then
|
|
|
|
make clean
|
|
|
|
fi
|
2015-05-31 23:54:06 -03:00
|
|
|
make sitl-debug -j$NUM_PROCS || {
|
2014-04-10 23:29:28 -03:00
|
|
|
make clean
|
2015-05-31 23:54:06 -03:00
|
|
|
make sitl-debug -j$NUM_PROCS
|
2014-04-10 23:29:28 -03:00
|
|
|
}
|
|
|
|
TRACKER_INSTANCE=1
|
|
|
|
TRACKER_UARTA="tcp:127.0.0.1:"$((5760+10*$TRACKER_INSTANCE))
|
2015-05-31 23:54:06 -03:00
|
|
|
cmd="nice /tmp/AntennaTracker.build/AntennaTracker.elf -I1 --model=tracker --home=$TRACKER_HOME"
|
2014-04-10 23:29:28 -03:00
|
|
|
$autotest/run_in_terminal_window.sh "AntennaTracker" $cmd || exit 1
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2015-05-10 19:06:31 -03:00
|
|
|
cmd="$VEHICLEDIR/$VEHICLE.elf -S -I$INSTANCE --home $SIMHOME"
|
2014-04-10 23:29:28 -03:00
|
|
|
if [ $WIPE_EEPROM == 1 ]; then
|
|
|
|
cmd="$cmd -w"
|
|
|
|
fi
|
|
|
|
|
2015-11-02 18:53:47 -04:00
|
|
|
cmd="$cmd --model $MODEL --speedup=$SPEEDUP $EXTRA_ARGS"
|
2015-05-31 23:54:06 -03:00
|
|
|
|
2015-05-24 23:11:42 -03:00
|
|
|
if [ $USE_MAVLINK_GIMBAL == 1 ]; then
|
|
|
|
echo "Using MAVLink gimbal"
|
|
|
|
cmd="$cmd --gimbal"
|
|
|
|
fi
|
|
|
|
|
2016-01-06 18:10:20 -04:00
|
|
|
if [ -n "$DEFAULTS_PATH" ]; then
|
|
|
|
echo "Using defaults from $DEFAULTS_PATH"
|
|
|
|
cmd="$cmd --defaults $DEFAULTS_PATH"
|
|
|
|
fi
|
|
|
|
|
2014-08-13 07:46:53 -03:00
|
|
|
if [ $START_HIL == 0 ]; then
|
2014-04-10 23:29:28 -03:00
|
|
|
if [ $USE_VALGRIND == 1 ]; then
|
|
|
|
echo "Using valgrind"
|
|
|
|
$autotest/run_in_terminal_window.sh "ardupilot (valgrind)" valgrind $cmd || exit 1
|
|
|
|
elif [ $USE_GDB == 1 ]; then
|
|
|
|
echo "Using gdb"
|
|
|
|
tfile=$(mktemp)
|
|
|
|
[ $USE_GDB_STOPPED == 0 ] && {
|
2015-05-24 23:11:42 -03:00
|
|
|
if [ -n "$BREAKPOINT" ]; then
|
|
|
|
echo "b $BREAKPOINT" >> $tfile
|
|
|
|
fi
|
2015-03-27 01:23:17 -03:00
|
|
|
echo r >> $tfile
|
2014-04-10 23:29:28 -03:00
|
|
|
}
|
|
|
|
$autotest/run_in_terminal_window.sh "ardupilot (gdb)" gdb -x $tfile --args $cmd || exit 1
|
|
|
|
else
|
|
|
|
$autotest/run_in_terminal_window.sh "ardupilot" $cmd || exit 1
|
|
|
|
fi
|
2014-08-13 07:46:53 -03:00
|
|
|
fi
|
2014-04-10 23:29:28 -03:00
|
|
|
|
2015-09-17 08:37:43 -03:00
|
|
|
if [ $START_HIL == 1 ]; then
|
|
|
|
$autotest/run_in_terminal_window.sh "JSBSim" $autotest/jsb_sim/runsim.py --home $SIMHOME --speedup=$SPEEDUP || exit 1
|
|
|
|
fi
|
|
|
|
|
2014-04-10 23:29:28 -03:00
|
|
|
trap kill_tasks SIGINT
|
|
|
|
|
|
|
|
# mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 --out 127.0.0.1:14550 --out 127.0.0.1:14551
|
2014-08-13 07:46:53 -03:00
|
|
|
options=""
|
|
|
|
if [ $START_HIL == 0 ]; then
|
2016-05-07 19:09:26 -03:00
|
|
|
options="--master $MAVLINK_PORT"
|
|
|
|
if [ $SITLRCIN == 1 ]; then
|
|
|
|
options="$options --sitl $SIMOUT_PORT"
|
|
|
|
fi
|
2014-08-13 07:46:53 -03:00
|
|
|
fi
|
2015-01-20 15:51:19 -04:00
|
|
|
|
|
|
|
# If running inside of a vagrant guest, then we probably want to forward our mavlink out to the containing host OS
|
|
|
|
if [ $USER == "vagrant" ]; then
|
|
|
|
options="$options --out 10.0.2.2:14550"
|
|
|
|
fi
|
2014-08-13 07:46:53 -03:00
|
|
|
options="$options --out 127.0.0.1:14550 --out 127.0.0.1:14551"
|
2016-04-28 00:47:39 -03:00
|
|
|
extra_cmd=""
|
2014-04-10 23:29:28 -03:00
|
|
|
if [ $START_ANTENNA_TRACKER == 1 ]; then
|
|
|
|
options="$options --load-module=tracker"
|
2016-04-28 06:39:12 -03:00
|
|
|
extra_cmd="$extra_cmd module load map; tracker set port $TRACKER_UARTA; tracker start; tracker arm"
|
2014-04-10 23:29:28 -03:00
|
|
|
fi
|
2014-08-13 07:46:53 -03:00
|
|
|
if [ $START_HIL == 1 ]; then
|
|
|
|
options="$options --load-module=HIL"
|
|
|
|
fi
|
2015-01-28 17:44:59 -04:00
|
|
|
if [ $USE_MAVLINK_GIMBAL == 1 ]; then
|
|
|
|
options="$options --load-module=gimbal"
|
|
|
|
fi
|
2015-11-30 23:19:31 -04:00
|
|
|
if [ $DELAY_START != 0 ]; then
|
|
|
|
sleep $DELAY_START
|
|
|
|
fi
|
2015-05-25 01:10:26 -03:00
|
|
|
|
2016-01-11 18:20:22 -04:00
|
|
|
if [ $MAVLINK_PROTOCOL_VERSION == 2 ]; then
|
|
|
|
options="$options --mav20"
|
|
|
|
fi
|
|
|
|
|
2015-05-25 01:10:26 -03:00
|
|
|
if [ -f /usr/bin/cygstart ]; then
|
|
|
|
cygstart -w "/cygdrive/c/Program Files (x86)/MAVProxy/mavproxy.exe" $options --cmd="$extra_cmd" $*
|
|
|
|
else
|
|
|
|
mavproxy.py $options --cmd="$extra_cmd" $*
|
|
|
|
fi
|
2015-03-13 08:33:25 -03:00
|
|
|
if [ $START_HIL == 0 ]; then
|
2014-04-10 23:29:28 -03:00
|
|
|
kill_tasks
|
2015-03-13 08:33:25 -03:00
|
|
|
fi
|