mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 08:13:35 +08:00
simulation organization and cleanup
- new modules/simulation directory to collect all simulators and related modules - new Tools/simulation directory to collect and organize scattered simulation submodules, scripts, etc - simulation module renamed to simulator_mavlink - sih renamed to simulator_sih (not a great name, but I wanted to be clear it was a simulator) - ignition_simulator renamed to simulator_ignition_bridge - large sitl_target.cmake split by simulation option and in some cases pushed to appropriate modules - sitl targets broken down to what's actually available (eg jmavsim only has 1 model and 1 world) - new Gazebo consistently referred to as Ignition for now (probably the least confusing thing until we fully drop Gazebo classic support someday)
This commit is contained in:
Submodule
+1
Submodule Tools/simulation/jmavsim/jMAVSim added at 66b764ada5
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd "$SCRIPT_DIR/jMAVSim"
|
||||
|
||||
port=4560
|
||||
extra_args=
|
||||
baudrate=921600
|
||||
device=
|
||||
ip="127.0.0.1"
|
||||
protocol="tcp"
|
||||
while getopts ":b:d:u:p:qsr:f:i:loat" opt; do
|
||||
case $opt in
|
||||
b)
|
||||
baudrate=$OPTARG
|
||||
;;
|
||||
d)
|
||||
device="$OPTARG"
|
||||
;;
|
||||
u)
|
||||
protocol="udp"
|
||||
;;
|
||||
i)
|
||||
ip="$OPTARG"
|
||||
;;
|
||||
p)
|
||||
port=$OPTARG
|
||||
;;
|
||||
q)
|
||||
extra_args="$extra_args -qgc"
|
||||
;;
|
||||
s)
|
||||
extra_args="$extra_args -sdk"
|
||||
;;
|
||||
r)
|
||||
extra_args="$extra_args -r $OPTARG"
|
||||
;;
|
||||
l)
|
||||
extra_args="$extra_args -lockstep"
|
||||
;;
|
||||
o)
|
||||
extra_args="$extra_args -disponly"
|
||||
;;
|
||||
a)
|
||||
extra_args="$extra_args -fw" # aircraft model
|
||||
;;
|
||||
t)
|
||||
extra_args="$extra_args -ts" # tailsitter model
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$device" == "" ]; then
|
||||
if [ "$protocol" == "tcp" ]; then
|
||||
device="-tcp $ip:$port"
|
||||
else
|
||||
device="-udp $port"
|
||||
fi
|
||||
else
|
||||
device="-serial $device $baudrate"
|
||||
fi
|
||||
|
||||
if [ "$HEADLESS" = "1" ]; then
|
||||
extra_args="$extra_args -no-gui"
|
||||
fi
|
||||
|
||||
ant create_run_jar copy_res
|
||||
cd out/production
|
||||
|
||||
java -XX:GCTimeRatio=20 -Djava.ext.dirs= -jar jmavsim_run.jar $device $extra_args
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$#" -lt 3 ]; then
|
||||
echo usage: sitl_run.sh sitl_bin debugger src_path build_path
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sitl_bin="$1"
|
||||
debugger="$2"
|
||||
src_path="$3"
|
||||
build_path="$4"
|
||||
|
||||
echo SITL ARGS
|
||||
|
||||
echo sitl_bin: $sitl_bin
|
||||
echo debugger: $debugger
|
||||
echo src_path: $src_path
|
||||
echo build_path: $build_path
|
||||
|
||||
rootfs="$build_path/rootfs" # this is the working directory
|
||||
mkdir -p "$rootfs"
|
||||
|
||||
# To disable user input
|
||||
if [[ -n "$NO_PXH" ]]; then
|
||||
no_pxh=-d
|
||||
else
|
||||
no_pxh=""
|
||||
fi
|
||||
|
||||
jmavsim_pid=`ps aux | grep java | grep "\-jar jmavsim_run.jar" | awk '{ print $2 }'`
|
||||
if [ -n "$jmavsim_pid" ]; then
|
||||
kill $jmavsim_pid
|
||||
fi
|
||||
|
||||
export PX4_SIM_MODEL="iris"
|
||||
|
||||
# Start Java simulator
|
||||
"$src_path"/Tools/simulation/jmavsim/jmavsim_run.sh -r 250 -l &
|
||||
SIM_PID=$!
|
||||
|
||||
pushd "$rootfs" >/dev/null
|
||||
|
||||
# Do not exit on failure now from here on because we want the complete cleanup
|
||||
set +e
|
||||
|
||||
sitl_command="\"$sitl_bin\" $no_pxh \"$build_path\"/etc"
|
||||
|
||||
echo SITL COMMAND: $sitl_command
|
||||
|
||||
if [ "$debugger" == "lldb" ]; then
|
||||
eval lldb -- $sitl_command
|
||||
elif [ "$debugger" == "gdb" ]; then
|
||||
eval gdb --args $sitl_command
|
||||
elif [ "$debugger" == "valgrind" ]; then
|
||||
eval valgrind --track-origins=yes --leak-check=full -v $sitl_command
|
||||
elif [ "$debugger" == "callgrind" ]; then
|
||||
eval valgrind --tool=callgrind -v $sitl_command
|
||||
else
|
||||
eval $sitl_command
|
||||
fi
|
||||
|
||||
popd >/dev/null
|
||||
|
||||
pkill -9 -P $SIM_PID
|
||||
kill -9 $SIM_PID
|
||||
Reference in New Issue
Block a user