-
Notifications
You must be signed in to change notification settings - Fork 152
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
Speed up improvement in LaserScan and PointCloud2 #525
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look like great changes. I haven't tested them yet, but most of them are common sense memory management. I did note a stylistic gripe with your implementation of the trig cache.
Actually, if you wouldn't mind factoring that out into a separate PR, I think that speed up the process for us to merge this in.
void LaserScanPlugin::updatePreComputedTriginometic(const sensor_msgs::LaserScanConstPtr& msg) | ||
{ | ||
static size_t prev_size = 0; | ||
static float prev_angle_min = msg->angle_min; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid the use of local static variables by refactoring these to class variables or creating a new object to encapsulate the entire trigonometry cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is just a matter of "personal taste". Or is there any technical reason to avoid static?
No problem, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand you point now. You are right
1eb1772
to
124b19c
Compare
EDIT: I stand corrected. Cheers and thanks again for the amazing tool. |
For the records:
|
This looks good to me. Tested and works in my Kinetic Docker environment. Thanks! |
* improve speed of laserScanCallback (2.5X faster) * improve speed of pointcloud2 plugin (3X faster)
Hi,
it is possible to reduce dramatically the memory allocation in both std::vector::reserve or recycling instances popped from the scan_ buffers.
In my benchmarks, these change roughly reduce the amount of CPU used by these two plugins to 1/3rd.