-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Considerable CPU saving in BaseRealSenseNode::publishPointCloud() #1097
Considerable CPU saving in BaseRealSenseNode::publishPointCloud() #1097
Conversation
There were two missed opportunities for optimization: - sensor_msgs::PointCloud2 should not be created at any frame, because, that would force memory allocation, that is costly. - using std::list should be forbidden ;)
To be fair, once the "decimation" filter is applied, the CPU saving is less dramatic, but still significant 😄 |
On my machine it was also around 35% less CPU. Thanks! |
Applied this and no longer seem to get the following error message after launching the ros node:
I do still get these warnings though:
Update: Not sure the errors above had anything to do with this PR but they disappeared after running
|
The "Out of frame resources!" message usually mean that your machine is overloaded and processing cannot keep up with incoming frames. You did not mention what machine you are running on or what frame rate you use but these could be the reason. |
Hi all, Nonetheless, I wanted to report that I recently found that it breaks the code from: I have a fork of the repo which uses the function toggleSensors to turn off/on the sensors during operation, and after the change I'm getting a segmentation fault when the program reaches this point: https://github.com/IntelRealSense/realsense-ros/blob/development/realsense2_camera/src/base_realsense_node.cpp#L2088 I also have another function to toggle RGB on and off (as I've found it decreases the metadata quality, i.e. exposure values are fixed and in a different scale). And the same issue happens. Both toggle functions are called by a ROS service. @facontidavide Could you help in debugging this issue? As you know your code and your train of thought the best. Thank you in advance. Best, |
Hi, I will try to figure this out. Inspecting the code I can find no reason why this is happening. It is really weird! I will try to reproduce it |
Thanks a lot. If there is any further info or test needed from my side please let me know. |
@YoshuaNava , I think that I need to have a look to your fork, because in the official repo there is no way to easily call that method. Otherwise it will take me a while to reproduce this :( |
There were two missed opportunities for optimization:
sensor_msgs::PointCloud2 should not be created at any frame, because that would force memory allocation, that is costly.
using std::list should be forbidden ;)
On "My Machine", we are talking about about 40% less CPU using a D435i (I am looking forward to know if you see similar improvement ratio).