mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-22 00:27:35 +08:00
Improvements to SITL to make paths more flexible. (#5181)
This commit is contained in:
+1
-1
Submodule Tools/sitl_gazebo updated: 00dcabb1c2...9486c331a7
+44
-39
@@ -1,22 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
rc_script=$1
|
||||
debugger=$2
|
||||
program=$3
|
||||
model=$4
|
||||
build_path=$5
|
||||
curr_dir=`pwd`
|
||||
set -e
|
||||
|
||||
echo args: $@
|
||||
|
||||
sitl_bin=$1
|
||||
rc_script=$2
|
||||
debugger=$3
|
||||
program=$4
|
||||
model=$5
|
||||
src_path=$6
|
||||
build_path=$7
|
||||
|
||||
echo SITL ARGS
|
||||
|
||||
echo sitl_bin: $sitl_bin
|
||||
echo rc_script: $rc_script
|
||||
echo debugger: $debugger
|
||||
echo program: $program
|
||||
echo model: $model
|
||||
echo src_path: $src_path
|
||||
echo build_path: $build_path
|
||||
|
||||
mkdir -p $build_path/src/firmware/posix/rootfs/fs/microsd
|
||||
mkdir -p $build_path/src/firmware/posix/rootfs/eeprom
|
||||
touch $build_path/src/firmware/posix/rootfs/eeprom/parameters
|
||||
working_dir=`pwd`
|
||||
sitl_bin=$build_path/src/firmware/posix/px4
|
||||
|
||||
if [ "$chroot" == "1" ]
|
||||
then
|
||||
@@ -35,32 +42,36 @@ fi
|
||||
|
||||
if [ "$#" -lt 5 ]
|
||||
then
|
||||
echo usage: sitl_run.sh rc_script debugger program model build_path
|
||||
echo usage: sitl_run.sh rc_script debugger program model devel_path
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command_exists () {
|
||||
type "$1" &> /dev/null ;
|
||||
}
|
||||
|
||||
# kill process names that might stil
|
||||
# be running from last time
|
||||
pkill gazebo
|
||||
pkill px4
|
||||
jmavsim_pid=`jps | grep Simulator | cut -d" " -f1`
|
||||
if [ -n "$jmavsim_pid" ]
|
||||
pgrep gazebo && pkill gazebo
|
||||
pgrep px4 && pkill px4
|
||||
if command_exists jps
|
||||
then
|
||||
kill $jmavsim_pid
|
||||
jmavsim_pid=`jps | grep Simulator | cut -d" " -f1`
|
||||
if [ -n "$jmavsim_pid" ]
|
||||
then
|
||||
kill $jmavsim_pid
|
||||
fi
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
cd $build_path/..
|
||||
cp Tools/posix_lldbinit $build_path/src/firmware/posix/.lldbinit
|
||||
cp Tools/posix.gdbinit $build_path/src/firmware/posix/.gdbinit
|
||||
cp $src_path/Tools/posix_lldbinit $working_dir/.lldbinit
|
||||
cp $src_path/Tools/posix.gdbinit $working_dir/.gdbinit
|
||||
|
||||
SIM_PID=0
|
||||
|
||||
if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ]
|
||||
then
|
||||
cd Tools/jMAVSim
|
||||
cd $src_path/Tools/jMAVSim
|
||||
ant create_run_jar copy_res
|
||||
cd out/production
|
||||
java -Djava.ext.dirs= -jar jmavsim_run.jar -udp 127.0.0.1:14560 &
|
||||
@@ -71,15 +82,9 @@ then
|
||||
if [ -x "$(command -v gazebo)" ]
|
||||
then
|
||||
# Set the plugin path so Gazebo finds our model and sim
|
||||
export GAZEBO_PLUGIN_PATH=$curr_dir/build_gazebo:${GAZEBO_PLUGIN_PATH}
|
||||
# Set the model path so Gazebo finds the airframes
|
||||
export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$curr_dir/Tools/sitl_gazebo/models
|
||||
# The next line would disable online model lookup, can be commented in, in case of unstable behaviour.
|
||||
# export GAZEBO_MODEL_DATABASE_URI=""
|
||||
export SITL_GAZEBO_PATH=$curr_dir/Tools/sitl_gazebo
|
||||
make --no-print-directory gazebo_build
|
||||
|
||||
gzserver --verbose $curr_dir/Tools/sitl_gazebo/worlds/${model}.world &
|
||||
source /usr/share/gazebo/setup.sh
|
||||
source $src_path/integrationtests/setup_gazebo_ros.bash ${src_path} ${build_path}
|
||||
gzserver --verbose worlds/${model}.world &
|
||||
SIM_PID=`echo $!`
|
||||
|
||||
if [[ -n "$HEADLESS" ]]; then
|
||||
@@ -98,17 +103,17 @@ then
|
||||
# This is not a simulator, but a log file to replay
|
||||
|
||||
# Check if we need to creat a param file to allow user to change parameters
|
||||
if ! [ -f "${build_path}/src/firmware/posix/rootfs/replay_params.txt" ]
|
||||
if ! [ -f "$rootfs/replay_params.txt" ]
|
||||
then
|
||||
touch ${build_path}/src/firmware/posix/rootfs/replay_params.txt
|
||||
touch $rootfs/replay_params.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $build_path/src/firmware/posix
|
||||
cd $working_dir
|
||||
|
||||
if [ "$logfile" != "" ]
|
||||
then
|
||||
cp $logfile rootfs/replay.px4log
|
||||
cp $logfile $rootfs/replay.px4log
|
||||
fi
|
||||
|
||||
# Do not exit on failure now from here on because we want the complete cleanup
|
||||
@@ -117,18 +122,18 @@ set +e
|
||||
# Start Java simulator
|
||||
if [ "$debugger" == "lldb" ]
|
||||
then
|
||||
lldb -- px4 ../../../../${rc_script}_${program}_${model}
|
||||
lldb -- $sitl_bin $src_path $src_path/${rc_script}_${program}_${model}
|
||||
elif [ "$debugger" == "gdb" ]
|
||||
then
|
||||
gdb --args px4 ../../../../${rc_script}_${program}_${model}
|
||||
gdb --args $sitl_bin $src_path $src_path/${rc_script}_${program}_${model}
|
||||
elif [ "$debugger" == "ddd" ]
|
||||
then
|
||||
ddd --debugger gdb --args px4 ../../../../${rc_script}_${program}_${model}
|
||||
ddd --debugger gdb --args px4 $src_path $src_path/${rc_script}_${program}_${model}
|
||||
elif [ "$debugger" == "valgrind" ]
|
||||
then
|
||||
valgrind ./px4 ../../../../${rc_script}_${program}_${model}
|
||||
valgrind $sitl_bin $src_path $src_path/${rc_script}_${program}_${model}
|
||||
else
|
||||
$sudo_enabled ./px4 $chroot_enabled ../../../../${rc_script}_${program}_${model}
|
||||
$sudo_enabled $sitl_bin $chroot_enabled $src_path $src_path/${rc_script}_${program}_${model}
|
||||
fi
|
||||
|
||||
if [ "$program" == "jmavsim" ]
|
||||
|
||||
Reference in New Issue
Block a user