Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] GZ_BRIDGE Check GZ_SIM_RESOURCE_PATH is set correctly. #23705

Closed
Varchasvin10 opened this issue Sep 21, 2024 · 38 comments · Fixed by #24164
Closed

[Bug] GZ_BRIDGE Check GZ_SIM_RESOURCE_PATH is set correctly. #23705

Varchasvin10 opened this issue Sep 21, 2024 · 38 comments · Fixed by #24164

Comments

@Varchasvin10
Copy link

Varchasvin10 commented Sep 21, 2024

I ran the gazebo sitl simulation model make px4_sitl gz_x500_depth and the gz-bridge doesnt seem to be working. I killed all gz servers running and still this issue persists.

Screenshot from 2024-09-21 11-01-03

Im using ROS2 Humble on Ubuntu 22.04

To Reproduce

No response

Expected behavior

No response

Screenshot / Media

No response

Flight Log

No response

Software Version

No response

Flight controller

No response

Vehicle type

None

How are the different components wired up (including port information)

No response

Additional context

No response

@dirksavage88
Copy link
Contributor

I can fully replicate this as well, even though I am setting the sim resource path manually the error still persists

@dirksavage88
Copy link
Contributor

It has to do with changes to the gz bridge adding a scene service and setting a default follow distance to the airframe. I am using this patch to get around it for now.

diff --git a/src/modules/simulation/gz_bridge/GZBridge.cpp b/src/modules/simulation/gz_bridge/GZBridge.cpp
index 29d19fe111..b4cc4a27c0 100644
--- a/src/modules/simulation/gz_bridge/GZBridge.cpp
+++ b/src/modules/simulation/gz_bridge/GZBridge.cpp
@@ -155,17 +155,17 @@ int GZBridge::init()
 			}
 
 			std::string scene_info_service = "/world/" + _world_name + "/scene/info";
-			bool scene_created = false;
-
-			while (scene_created == false) {
-				if (!callSceneInfoMsgService(scene_info_service)) {
-					PX4_WARN("Service call timed out as Gazebo has not been detected.");
-					system_usleep(2000000);
-
-				} else {
-					scene_created = true;
-				}
-			}
+			// bool scene_created = false;
+
+			// while (scene_created == false) {
+			// 	if (!callSceneInfoMsgService(scene_info_service)) {
+			// 		PX4_WARN("Service call timed out as Gazebo has not been detected.");
+			// 		system_usleep(2000000);
+			//
+			// 	} else {
+			// 		scene_created = true;
+			// 	}
+			// }
 
 			gz::msgs::StringMsg follow_msg{};
 			follow_msg.set_data(_model_name);

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Sep 22, 2024

@dirksavage88 Which version of gazebo are you using? Can you check if the service exist? The fact that the error message only appears once seems that the service call succeeds in the end no?

@dirksavage88
Copy link
Contributor

dirksavage88 commented Sep 22, 2024

@dirksavage88 Which version of gazebo are you using? Can you check if the service exist? The fact that the error message only appears once seems that the service call succeeds in the end no?

Gazebo Sim, version 8.6.0

I see now, yes it does eventually create the scene. The px4 model follow view angle is offset though, which made me suspect something was wrong with the scene/view angle and the error was causing it...So the view angle was just jarring enough and coupled with the error was just confusing.

@Varchasvin10
Copy link
Author

It has to do with changes to the gz bridge adding a scene service and setting a default follow distance to the airframe. I am using this patch to get around it for now.

diff --git a/src/modules/simulation/gz_bridge/GZBridge.cpp b/src/modules/simulation/gz_bridge/GZBridge.cpp
index 29d19fe111..b4cc4a27c0 100644
--- a/src/modules/simulation/gz_bridge/GZBridge.cpp
+++ b/src/modules/simulation/gz_bridge/GZBridge.cpp
@@ -155,17 +155,17 @@ int GZBridge::init()
 			}
 
 			std::string scene_info_service = "/world/" + _world_name + "/scene/info";
-			bool scene_created = false;
-
-			while (scene_created == false) {
-				if (!callSceneInfoMsgService(scene_info_service)) {
-					PX4_WARN("Service call timed out as Gazebo has not been detected.");
-					system_usleep(2000000);
-
-				} else {
-					scene_created = true;
-				}
-			}
+			// bool scene_created = false;
+
+			// while (scene_created == false) {
+			// 	if (!callSceneInfoMsgService(scene_info_service)) {
+			// 		PX4_WARN("Service call timed out as Gazebo has not been detected.");
+			// 		system_usleep(2000000);
+			//
+			// 	} else {
+			// 		scene_created = true;
+			// 	}
+			// }
 
 			gz::msgs::StringMsg follow_msg{};
 			follow_msg.set_data(_model_name);

Replicated this and it shows a new gz_bridge error

Screenshot from 2024-09-23 11-37-07

@snDevX
Copy link

snDevX commented Sep 23, 2024

In 24.04 I get the same error.

I noticed that make px4_sitl leaves the directory ~/PX4/PX4-Autopilot/build/px4_sitl_default/build_gz empty which I think its where the problem stems.

@Jaeyoung-Lim
Copy link
Member

@Varchasvin10 @snDevX The problems you are experiencing is different with @dirksavage88

The problem is that gz is not being built or started. I would check whether you can run gz

@Varchasvin10
Copy link
Author

@Varchasvin10 @snDevX The problems you are experiencing is different with @dirksavage88

The problem is that gz is not being built or started. I would check whether you can run gz

gz sim is running in my system but the terminal shows gz_bridge warning and when i run an offboard example to control the uav, the gazebo simulation does not respond and the odom values also were not published.

image

with the offboard example,

image

@stw124
Copy link

stw124 commented Sep 27, 2024

I have the same problem. Has anyone solved the problem?

@Jaeyoung-Lim
Copy link
Member

@Varchasvin10 The warning has nothing to do with your problems in offboard. Can you fly the vehicle using QGC?

@stw124 What do you mean by the "same"? It is not clear what the problem is in this thread.

@Varchasvin10
Copy link
Author

@Varchasvin10 The warning has nothing to do with your problems in offboard. Can you fly the vehicle using QGC?

@stw124 What do you mean by the "same"? It is not clear what the problem is in this thread.

Even with QGC i cannot arm the uav, it gets disarmed and the teleop doesnt work.

@Jaeyoung-Lim
Copy link
Member

@Varchasvin10 sounds like your problem is not related to the one reported here

@Varchasvin10
Copy link
Author

It is, the gz_bridge error is not letting the messages be published to the gazebo

@Jaeyoung-Lim
Copy link
Member

@Varchasvin10 I don't think the error is related to the message not being published. You need to elaborate on why you have come to this conclusion.

@JustinHsuNctu
Copy link

I have the same problem when I download the latest version. But when I return to the old version which I downloaded on June 11 ,2024, it's OK! I can control the UAV in Gazebo.
Post this message for reference.

@usmanNoor5
Copy link

same issue

@usmanNoor5
Copy link

what is the solution does any one know

@octavioaguila
Copy link

Same issue :(

@dakejahl
Copy link
Contributor

dakejahl commented Oct 9, 2024

@Jaeyoung-Lim I think people are conflating problems here. The error messages about the /gui services being unavailable are valid, I see it everytime. The issue is that the service calls are happening before the services are available. I can fix it by adding a 1 second sleep after callEntityFactoryService and callSceneInfoMsgService. This might vary across computers though so a better solution would be to check if the service is available before trying to call it.

@Jaeyoung-Lim
Copy link
Member

@dakejahl The reason I have implemented that way was to not add a sleep (discussion with @dagar )

If you are interested in fixing this, could you modify the message to not report an error but something like failed and report success if it connected?

@snDevX
Copy link

snDevX commented Oct 10, 2024

@Jaeyoung-Lim I think people are conflating problems here. The error messages about the /gui services being unavailable are valid, I see it everytime. The issue is that the service calls are happening before the services are available. I can fix it by adding a 1 second sleep after callEntityFactoryService and callSceneInfoMsgService. This might vary across computers though so a better solution would be to check if the service is available before trying to call it.

tell us which files you changed

@dakejahl
Copy link
Contributor

@snDevX GZBridge.cpp

To be clear though... this error is harmless. It just means the /gui/follow service fails because the world isn't ready (defaulting the camera view to follow the drone). If your GZ sim is not working at all it's a different issue and unrelated to the "service called timed out" error

@NaShoval
Copy link

NaShoval commented Oct 14, 2024

Did anyone find a solution? I have ubuntu 24.04 and did not have this issue until now.

make` px4_sitl gz_advanced_plane
[0/1] cd /home/hawk/GitDir/PX4-Autopilot/build/px4_sitl_default/src/modules/simulation/gz_br...4_SIM_MODEL=gz_advanced_plane /home/hawk/GitDir/PX4-Autopilot/build/px4_sitl_default/bin/px4


| ___ \ \ \ / / / |
| |/ / \ V / / /| |
| __/ / \ / /
| |
| | / /^\ \ ___ |
_| / / |_/

px4 starting.

INFO [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
INFO [init] found model autostart file as SYS_AUTOSTART=4008
INFO [param] selected parameter default file parameters.bson
INFO [param] importing from 'parameters.bson'
INFO [parameters] BSON document size 460 bytes, decoded 460 bytes (INT32:18, FLOAT:5)
INFO [param] selected parameter backup file parameters_backup.bson
INFO [dataman] data manager file './dataman' size is 7872608 bytes
INFO [init] Gazebo simulator
INFO [init] starting gazebo with world: /home/hawk/GitDir/PX4-Autopilot/Tools/simulation/gz/worlds/default.sdf
WARN [init] PX4_GZ_MODEL_POSE not set, spawning at origin.
INFO [gz_bridge] world: default, model name: advanced_plane_0, simulation model: advanced_plane
INFO [gz_bridge] Requested Model Position: 0,0,0,0,0,0
INFO [gz_bridge] Model position z is less or equal 0.0, moving upwards
gz sim -g: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE
ERROR [gz_bridge] Service call timed out. Check GZ_SIM_RESOURCE_PATH is set correctly.
WARN [gz_bridge] Service call timed out as Gazebo has not been detected.
ERROR [gz_bridge] Service call timed out: /gui/follow
ERROR [gz_bridge] Service call timed out: /gui/follow/offset
INFO [lockstep_scheduler] setting initial absolute time to 3280000 us
INFO [commander] LED: open /dev/led0 failed (22)
WARN [health_and_arming_checks] Preflight Fail: Airspeed selector module down
WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN [health_and_arming_checks] Preflight Fail: No connection to the ground control station
INFO [airspeed_selector] No airspeed sensor detected. Switch to non-airspeed mode.
INFO [uxrce_dds_client] init UDP agent IP:127.0.0.1, port:8888
INFO [tone_alarm] home set
INFO [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550
INFO [mavlink] partner IP: 127.0.0.1
INFO [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
INFO [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030
INFO [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280

@Jaeyoung-Lim
Copy link
Member

@NaShoval Is there something that didn't work?

@NaShoval
Copy link

@NaShoval Is there something that didn't work?

When I run "make" in the PX4's directory, my gazebo does not initialise automatically.
When I manually initialise it, and than closing the gazebo window - the first window (that I expected PX4 to open), suddenly appears.
I just update to ubuntu 24.04 and did not have this issue until now..

@dirksavage88
Copy link
Contributor

@snDevX GZBridge.cpp

To be clear though... this error is harmless. It just means the /gui/follow service fails because the world isn't ready (defaulting the camera view to follow the drone). If your GZ sim is not working at all it's a different issue and unrelated to the "service called timed out" error

The default camera view is a little jarring since it's at an offset angle to the vehicle body:
camera_view

@Jaeyoung-Lim is it possible to get this fixed (just the timeout) since it still results in a degraded user experience? I understand it is a red herring for other errors users are seeing and commenting on, but fixing the core issue is still pretty important.

@benbaarber
Copy link

benbaarber commented Dec 17, 2024

Same issue here on ubuntu 24.04 when running make px4_sitl gz_x500:

ERROR [gz_bridge] Service call timed out. Check GZ_SIM_RESOURCE_PATH is set correctly.
WARN  [gz_bridge] Service call timed out as Gazebo has not been detected.

And gazebo launches exactly like @dirksavage88 most recent comment

I tried running the same command first in an ubuntu:22.04 docker container after running Tools/setup/ubuntu.sh, got the same error.

Update: the patch worked, hopefully this gets fixed eventually tho

@Jaeyoung-Lim
Copy link
Member

@benbaarber Please consider making a pull request for the fix

@mylongword
Copy link

Same issue here on ubuntu 24.04 when running PX4_GZ_WORLD=lawn make px4_sitl gz_x500:

ERROR [gz_bridge] Service call timed out. Check GZ_SIM_RESOURCE_PATH is set correctly.
ERROR [gz_bridge] Task start failed (-1)
ERROR [init] gz_bridge failed to start and spawn model

The Patch by @dirksavage88 worked (I don't understand why).
To avoid another timeout warning on my Nitro 5, I also changed, in the same file,
if (_node.Request(service, req, 1000, rep, result)) {
to
if (_node.Request(service, req, 5000, rep, result)) {

@ckjunaid
Copy link

@benbaarber Please consider making a pull request for the fix
sir i do face this problem , the problem is we launched 3 terminal one for simulation from px4 and dds communication and keyboard operation .
actually when i click the space it should arm but not responding to it but can arm and fly using qgc iam following the ark electronics git ....

@ckjunaid
Copy link


Uploading Screenshot from 2024-12-24 21-48-41.png…

@surajsurve4511
Copy link

ss

@surajsurve4511
Copy link

I also faced the error , I had tried solving the error with many ways but the GZBridge is not properly build in new versions of px4.
Shall we try to switch and use gazebo - classic , for that we need to downgrade to ubuntu 20

@Jaeyoung-Lim
Copy link
Member

@surajsurve4511 As mentioned above, this is not an error

@surajsurve4511
Copy link

But as of I tried of fetching Lidar sensor data with ros I was unable to get the data in ros2 node ..!
Can you just guide me to get lidar sensor data to ros2 node ,I want the data to be fetched in a python script.!

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Jan 1, 2025

@surajsurve4511 Publishing ros2 topics are not related to the issue on this thread. Please either open a new issue or post your question on https://discuss.px4.io/

@TheMightiestCarrot
Copy link

TheMightiestCarrot commented Jan 21, 2025

Guys! i have found a simple adhoc solution!
Run Gazebo first, wait a bit and then start px4:

gz sim ~/PX4-Autopilot/Tools/simulation/gz/worlds/default.sdf & GZ_PID=$!

sleep 5

PX4_SYS_AUTOSTART=4002 PX4_GZ_MODEL_POSE="268.08,-128.22,3.86,0.00,0,-0.7" PX4_GZ_MODEL=x500_depth ./build/px4_sitl_default/bin/px4

Or you can just start gazebo in one terminal:
gz sim ~/PX4-Autopilot/Tools/simulation/gz/worlds/default.sdf
and px4 in a new one:
PX4_SYS_AUTOSTART=4002 PX4_GZ_MODEL_POSE="268.08,-128.22,3.86,0.00,0,-0.7" PX4_GZ_MODEL=x500_depth ./build/px4_sitl_default/bin/px4

@dakejahl
Copy link
Contributor

It's fixed in the PR #24164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.