-
Notifications
You must be signed in to change notification settings - Fork 58
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
Slow CameraSensor update rate compared to GUI scene refresh rate #332
Comments
I think
gui rendering runs in a separate process from server and has its own thread for rendering. On the server side, all the rendering sensors perform updates in the same rendering thread. While some parallelizations are done on the GPU for the camera updates, there could still be other places where there is contention for resources, e.g. when reading data back from GPU to CPU, serializing and publishing the msgs.
I think we would need to profile where the performance bottleneck is first. In the past, getting data from GPU to CPU had been slow for us. That could be something to look into. But I'm not sure if there's a workaround that can be done on the user side unfortunately (apart from running without a gui which didn't seem to help in your case).
I don't think that functionality is supported yet. |
Thank you so much for these information! I did more testing with the camera sensor purely in gz sim and found more "issues". If I do not use the ImageDisplay plugin to subscribe to one of the camera sensors, the real-time factor is almost 100% all the time. The moment I enable ImageDisplay and subscribe to one of the sensors, the RTF starts to fluctuate dramatically, between 50%- 90%. Similar issue happens when I echo the camera sensor with I also noticed that there is a |
So in gazebo cameras do not actually update if there are no subscribers, hence the high RTF, i.e. no work is done because there are no consumers. It's only when you subscribe to the image topic e.g. through As for the |
Thanks! I did some primitive poking and have more question now.
So now all of the cameras are publishing their info to the default |
Oh that loop measures the update rate for just 1 sensor (there is a
Hmm that was added recently but the doc hasn't been updated yet. To fix the issue,
You'll also need make sure your sdformat 13 version is >= 13.4.1 as there was a recent patch to fix the |
Ah I see, the actual render loop is giving me around 12 HZ when 4 cameras are subscribed, which is consistent with the real time update rate. |
I timed each stage in the camera sensor's update process and found that there is a dramatic slow down from the sensor update loop to the manager update loop. Hope this is helpful and I will keep digging.
Edit: The Manager Loop rate makes sense because each camera is publishing at 100hz and there are 4 of them so the loop should be 100/4 = 25hz. The issue is within the render and copy step I think. |
similar issue in ros-gz #368 |
I started testing with only one camera this time, the first slow down is at copying data from GPU, then preparing image data for publishing, and lastly in the RenderThread.
|
thanks for the profiling the update loops! I do expect there are differences but it's larger than I thought. This led me to investigate what's causing the differences and made some slight optmizations in gazebosim/gz-sim#1938. If you have time, feel free to try out the branch and see if it helps your use case. |
Thank you so much for this fix. I just tested this branch and the performance improvement is great for a single camera sensor. ROS reported update rate matches the target (both at 30hz). For the 4-camera scenario the RenderThread is reporting 15 hz, instead of 12hz from before. For my usage I could just run 4 different simulations with only one camera enable each time and get somewhat realtime data after combining them.
|
My problem
My application requires me to simulate at least 3 cameras to capture the scene and track a target's position. Each camera is set to 1920x1080 resolution at 30 fps in the .sdf file. However, when I run the simulation each camera can at most publish at 15 HZ (I am using ros-gz bridge and inspected the rate with
ros2 topic hz
). Even when I am only running one camera at this resolution it never reaches 30 fps and fluctuates around 23 HZ.My setup
mangohud
.My question
gz topic
I would really appreciate if anyone can point me to a direction and I would love to help if you already started working on a fix.
The text was updated successfully, but these errors were encountered: