From 1ae579b5d502ee143aaa4bd759a1d8972b6689ce Mon Sep 17 00:00:00 2001 From: Anton Erasmus Date: Mon, 24 Aug 2020 17:01:11 +0200 Subject: [PATCH] Update sitl_run to check for -gen.sdf files (#15232) Co-authored-by: Anton Erasmus --- Tools/sitl_run.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Tools/sitl_run.sh b/Tools/sitl_run.sh index 58020d9653..70da2c9383 100755 --- a/Tools/sitl_run.sh +++ b/Tools/sitl_run.sh @@ -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 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