From b108adc5f128695dfb82ae3c6d7b9b09040d4faa Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 28 Jul 2020 08:23:28 +0200 Subject: [PATCH] Tools: retry gz model if gzserver is not ready yet This should prevent the race between gzserver and gz model and fix the integration tests which sometimes timeout because the model is not spawned correctly. This patch also changes the shebang to what's generally recommended. --- Tools/sitl_run.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Tools/sitl_run.sh b/Tools/sitl_run.sh index bd872b133c..58020d9653 100755 --- a/Tools/sitl_run.sh +++ b/Tools/sitl_run.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + set -e @@ -106,10 +107,10 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then fi SIM_PID=$! - if gz model --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 "An instance of Gazebo is not running."; then - echo "Start of gzserver failed" - exit 1 - fi + 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 + echo "gzserver not ready yet, trying again!" + sleep 1 + done if [[ -n "$HEADLESS" ]]; then echo "not running gazebo gui"