From 7fc5393afcee87f7878caba16c2cc4dbb7dac215 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 1 Aug 2025 12:14:09 +0300 Subject: [PATCH] Update px4-rc.gzsim. Fix gz_world checking for PX4_GZ_STANDALONE=1 mode. Priority of gz_world (really running) over PX4_GZ_WORLD (#25346) --- ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim b/ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim index 9cb534c57b..43563ea606 100644 --- a/ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim +++ b/ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim @@ -28,11 +28,15 @@ else exit 1 fi +# Look for an already running world +get_gz_world() { + gz_world=$( ${gz_command} topic -l | grep -m 1 -e "^/world/.*/clock" | sed 's/\/world\///g; s/\/clock//g' ) +} + # If not standalone if [ -z "${PX4_GZ_STANDALONE}" ]; then - # Look for an already running world - gz_world=$( ${gz_command} topic -l | grep -m 1 -e "^/world/.*/clock" | sed 's/\/world\///g; s/\/clock//g' ) + get_gz_world # shellcheck disable=SC2153 if [ -z "${gz_world}" ] && [ -n "${PX4_GZ_WORLD}" ]; then @@ -66,6 +70,13 @@ fi # Wait for Gazebo world to be ready before proceeding check_scene_info() { + + get_gz_world + + if [ -n "${PX4_GZ_STANDALONE}" ] && [ -n "${gz_world}" ]; then + PX4_GZ_WORLD=${gz_world} + fi + SERVICE_INFO=$(${gz_command} service -i --service "/world/${PX4_GZ_WORLD}/scene/info" 2>&1) if echo "$SERVICE_INFO" | grep -q "Service providers"; then return 0