diff --git a/Tools/sitl_run.sh b/Tools/sitl_run.sh index 5745a039a2..35280c011f 100755 --- a/Tools/sitl_run.sh +++ b/Tools/sitl_run.sh @@ -128,16 +128,27 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then SIM_PID=$! # Check all paths in ${GAZEBO_MODEL_PATH} for specified model - readarray -d : -t paths <<< ${GAZEBO_MODEL_PATH} - for possibleModelPath in "${paths[@]}"; do + IFS_bak=$IFS + IFS=":" + for possible_model_path in ${GAZEBO_MODEL_PATH}; do + if [ -z $possible_model_path ]; then + continue + fi # trim \r from path - possibleModelPath=$(echo $possibleModelPath | tr -d '\r') - if test -f "${possibleModelPath}/${model}/${model}.sdf" ; then - modelpath=$possibleModelPath + possible_model_path=$(echo $possible_model_path | tr -d '\r') + if test -f "${possible_model_path}/${model}/${model}.sdf" ; then + modelpath=$possible_model_path break fi done - echo "Using: ${modelpath}/${model}/${model}.sdf" + IFS=$IFS_bak + + if [ -z $modelpath ]; then + echo "Model ${model} not found in model path: ${GAZEBO_MODEL_PATH}" + exit 1 + else + echo "Using: ${modelpath}/${model}/${model}.sdf" + fi while gz model --verbose --spawn-file="${modelpath}/${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!"