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.
This commit is contained in:
Julian Oes
2020-07-28 08:23:28 +02:00
parent 71b7647ca1
commit b108adc5f1
+6 -5
View File
@@ -1,4 +1,5 @@
#!/bin/bash #!/usr/bin/env bash
set -e set -e
@@ -106,10 +107,10 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
fi fi
SIM_PID=$! 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 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 "Start of gzserver failed" echo "gzserver not ready yet, trying again!"
exit 1 sleep 1
fi done
if [[ -n "$HEADLESS" ]]; then if [[ -n "$HEADLESS" ]]; then
echo "not running gazebo gui" echo "not running gazebo gui"