-
Notifications
You must be signed in to change notification settings - Fork 92
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
Performance: Body::setPose() should use Eigen::Isometry3d::linear() instead of ::rotation(). #125
Comments
A guy on SO says newer Eigen should recognize and use the potential optimization, but at least the version used in Melodic doesn't do that. |
Could you create a pull-request and in the best case benchmark the performance improvement? |
I'll try that. Just as a confirmation, here's the disassembly of /opt/ros/melodic/lib/libgeometric_shapes.so version 0.6.1-0bionic.20191205.163901 (created by
The docs for
But apparently, Eigen development branch 3.3 doesn't contain this optimization: https://gitlab.com/libeigen/eigen/-/blob/3.3/Eigen/src/Geometry/Transform.h#L1061 . So no officially released version of Eigen contains this optimization. And even if it does, I think that since Moveit supports a wide variety of platforms, there's no other way than manually switching to |
This is indeed the case and it is very frustrating that nobody noticed this during the transition from Could you prepare the corresponding pull-request? |
Yes, I'll have a look at it. Do you know of a good example of performance tests, ideally in moveit? I haven't written these yet so I'd like to get them right... I assume the timeouts in tests should be "calibrated" for Release builds, is that right? |
I would not expect automated tests for the testsuite for performance expectations.
MoveIt does not do this kind of testing (yet).
Some measurements demonstrating the performance difference would be great.
|
Okay, I tested setPose() in a release build and the performance improvement is massive. I constructed a "test case" which calls setPose() 10.000.000 times for each of the defined bodies (for ConvexMesh I created 2 cases, one for unscaled, and one for scaled mesh). The mesh I used was the box.dae from the tests directory. Before the fix:
With the fix:
And with another improvement I found for ConvexMesh:
That yields setPose() duration about 10% of the original for Box, Cylinder and unscaled ConvexMesh, and about 20% for scaled ConvexMesh (the saved time doesn't influence this method that much because it anyways spends lots of time on recomputing the scaled vertices, and the benefit will be the smaller the more vertices the mesh has). The proposed fix is in #126. |
Fixed via #126. |
Here: https://github.com/ros-planning/geometric_shapes/blob/bca6b88be8ba70851c79f785e0d45b12cb1917df/src/bodies.cpp#L318
And here: https://github.com/ros-planning/geometric_shapes/blob/bca6b88be8ba70851c79f785e0d45b12cb1917df/src/bodies.cpp#L549
When using rotation(), Eigen unnecessarily does SVD decomposition via
Eigen::Transform::computeRotationScaliing()
. But we're working with isometries, so linear part of the transform is equal to the rotation. I've done some performance tests and callingsetPose()
on 20 000 bodies takes 250 ms, which is a lot (and according to the profiler, the time is dominated by SVD computations).The text was updated successfully, but these errors were encountered: