-
Notifications
You must be signed in to change notification settings - Fork 277
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
Allow running Sensors and Physics update in Lockstep mode #2669
Comments
This should be supported by default in gz-sim (without needing to specify any args on launch). If you set a camera sensor to run at 30 Hz, it should run at the specified rate in sim time. If the camera can not render fast enough, it would block the main / physics thread and hence lowering the sim RTF.
Are you running into issues where you see that physics and sensors are not lockstepping? |
Technically, it is possible for the next physics step to occur before the rendering/sensor system blocks, but this only introduces one extra time step in physics. If this is a concern for you, I'd like to know, but otherwise, as @iche033 said, Sensors and Physics do run in lockstep by default in the new Gazebo. |
Hi @iche033 and @azeey,
We may have observed physics and sensors updating at different time frames. To be more specific on the testing setup, my project partner @Magnusgaertner and I were running a Distrobox of Ubuntu 24.04 with ROS2 Jazzy. When running some of the single-camera examples from this repo, the
Out of curiosity, how is this mechanism for synchronizing and spinning a new physics iteration implemented? Thank you in advance 🙏 |
is the 8 Hz output from |
I wrote a simple python program to verify camera timestamps some time ago, see osrf/mbzirc#147 (comment) in case it helps |
I have been experiencing a similar issue... I am running Gazebo Fortress with ROS2 Humble and have a robot with multiple senors. The senors currently in use are a Velodyne PUCK (gpu_lidar) and a camera. My laptop is powered by a i9 14900HX and an RTX 4070 with 32GB of ram. The RTF is constantly between 90 and 100% but the camera images are lagging behind. The camera is set to 30Hz but i receive only around 16-20Hz on the ros topic with the image header stamps acting as if were to be running at 30 Hz which than makes the timestamps fall behind the sim time by a large amount ever increasingly. Even visualising the image in RViZ the lagging behind is soon obvious (the longer you wait the bigger the discrepancy). |
can you check to see if the camera images are also lagging in Gazebo's Image Display GUI plugin (top right menu, select Image Display, and choose topic)? This visualizes the camera images coming through gz topic instead of ROS topic. If the images from gz topic is not lagging like in rviz, then it suggests the issue might be in the ros_gz bridge. |
ah yes for image / point cloud topics, it's recommended to separate them out into it's own bridge process. You can also enable lazy subscriber to save some compute resources: If you able to use harmonic, you can take advantage of node composition for further speedup |
I have tried lazy=true didnt help much... Now I have quickly built a docker container which than runs ROS2 Jazzy with Harmonic (I could not have used humble as ros2 control for gazebo does not support that configuration)... I have now implemented GZ server + 3 bridges as compostable nodes in one container and the problem remains the same but different :)... The large change in difference between times is due to different sensor setups (img 1 rtf locked to 0.5, both sensors reduced quaility, while img 2 is running both sensor at real life quality with rtf 1). I hope this can help you have a better insight into what might be causing the issue as well as step how could I improve it. The only main improvement untill now was to reduce the quality on both sensors (resolution, range, ...) as well as locking the rtf to a value with which the sensor can keep up, but I find that to be a sub optimal solution as I lose the senor quality I expect to have on the real robot. I am looking forward to any possible tips or tricks and am at your disposal if you need any further info. Here is also my composable node setup if it helps:
- ros_topic_name: "/clock"
gz_topic_name: "/clock"
ros_type_name: "rosgraph_msgs/msg/Clock"
gz_type_name: "gz.msgs.Clock"
lazy: true
direction: GZ_TO_ROS
- ros_topic_name: "base_controller/cmd_vel"
gz_topic_name: "base_controller/cmd_vel"
ros_type_name: "geometry_msgs/msg/TwistStamped"
gz_type_name: "gz.msgs.Twist"
lazy: true
direction: GZ_TO_ROS
Further 2 bridges are made in the same way. |
Desired behavior
Classic Gazebo provided a Lockstep mode that synchronized the update of physics and sensors -> https://classic.gazebosim.org/tutorials?tut=lockstep_physics_sensors
This mode allowed the simulation to better resemble a real-system, where sensors are sampled uniformly following a global clock, fitting the same timeline as the physics.
However, this feature does not seem to be present in New/Ignition Gazebo. Could it be implemented? Happy to help if so!
Alternatives considered
Not relying on the Lockstep mode, but this would make our simulation less representative of a real system.
Implementation suggestion
Implementing an equivalent of the Classic Gazebo Lockstep mode.
Additional context
None
The text was updated successfully, but these errors were encountered: