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

Considerable CPU saving in BaseRealSenseNode::publishPointCloud() #1097

Merged

Conversation

facontidavide
Copy link
Contributor

@facontidavide facontidavide commented Mar 2, 2020

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).

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 ;)
@facontidavide
Copy link
Contributor Author

To be fair, once the "decimation" filter is applied, the CPU saving is less dramatic, but still significant 😄

@facontidavide facontidavide changed the title very high CPU saving in BaseRealSenseNode::publishPointCloud() Considerable CPU saving in BaseRealSenseNode::publishPointCloud() Mar 2, 2020
@doronhi doronhi merged commit b06e55a into IntelRealSense:development Mar 5, 2020
@doronhi
Copy link
Contributor

doronhi commented Mar 5, 2020

On my machine it was also around 35% less CPU. Thanks!

@jorgemiar
Copy link

jorgemiar commented Mar 7, 2020

Applied this and no longer seem to get the following error message after launching the ros node:

[ERROR] [1583581271.939449058]: An error has occurred during frame callback: Error occured during execution of the processing block! See the log for more info

I do still get these warnings though:

 07/03 11:56:51,937 WARNING [139780868249344] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: No data available, number: 61
 07/03 11:56:52,000 WARNING [139780868249344] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: No data available, number: 61
 07/03 11:56:52,142 WARNING [139780868249344] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
 07/03 11:56:52,205 WARNING [139780868249344] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11
 07/03 11:56:52,267 WARNING [139780868249344] (messenger-libusb.cpp:42) control_transfer returned error, index: 768, error: Resource temporarily unavailable, number: 11

Update:

Not sure the errors above had anything to do with this PR but they disappeared after running sudo purge ros-kinetic-librealsense2. Still getting the following warnings when visualizing through rviz:

 07/03 16:49:26,051 WARNING [139661733263104] (types.cpp:49) Out of frame resources!
 07/03 16:49:26,052 ERROR [139661733263104] (synthetic-stream.cpp:48) Exception was thrown during user processing callback!

@doronhi
Copy link
Contributor

doronhi commented Mar 9, 2020

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.
As this is discussion is no longer connected to this specific PR, if you'd like, I would be happy to continue the discussion in a separate issue.

@YoshuaNava
Copy link

YoshuaNava commented Jul 20, 2020

Hi all,
This was a really nice contribution. Thank you very much!

Nonetheless, I wanted to report that I recently found that it breaks the code from:

https://github.com/IntelRealSense/realsense-ros/blob/development/realsense2_camera/src/base_realsense_node.cpp#L155

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,
Yoshua Nava

@facontidavide
Copy link
Contributor Author

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

@YoshuaNava
Copy link

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.

@facontidavide
Copy link
Contributor Author

@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 :(

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

Successfully merging this pull request may close these issues.

5 participants