Browse Source

Update sitl_run to check for -gen.sdf files (#15232)

Co-authored-by: Anton Erasmus <antonerasm@gmail.com>
sbg
Anton Erasmus 5 years ago committed by GitHub
parent
commit
1ae579b5d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      Tools/sitl_run.sh

9
Tools/sitl_run.sh

@ -80,6 +80,13 @@ if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ]; then @@ -80,6 +80,13 @@ if [ "$program" == "jmavsim" ] && [ ! -n "$no_sim" ]; then
SIM_PID=`echo $!`
elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
if [ -x "$(command -v gazebo)" ]; then
# Get the model name
model_name="${model}"
# Check if a 'modelname-gen.sdf' file exist for the models using jinja and generating the SDF files
if [ -f "${src_path}/Tools/sitl_gazebo/models/${model}/${model}-gen.sdf" ]; then
model_name="${model}-gen"
fi
# Set the plugin path so Gazebo finds our model and sim
source "$src_path/Tools/setup_gazebo.bash" "${src_path}" "${build_path}"
if [ -z $PX4_SITL_WORLD ]; then
@ -107,7 +114,7 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then @@ -107,7 +114,7 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
fi
SIM_PID=$!
while gz model --verbose --spawn-file="${src_path}/Tools/sitl_gazebo/models/${model}/${model}.sdf" --model-name=${model} -x 1.01 -y 0.98 -z 0.83 2>&1 | grep -q "An instance of Gazebo is not running."; do
while gz model --verbose --spawn-file="${src_path}/Tools/sitl_gazebo/models/${model}/${model_name}.sdf" --model-name=${model} -x 1.01 -y 0.98 -z 0.83 2>&1 | grep -q "An instance of Gazebo is not running."; do
echo "gzserver not ready yet, trying again!"
sleep 1
done

Loading…
Cancel
Save