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

Cayley Rot3 fixes #597

Merged
merged 10 commits into from
Nov 13, 2020
Merged

Cayley Rot3 fixes #597

merged 10 commits into from
Nov 13, 2020

Conversation

varunagrawal
Copy link
Collaborator

This PR is intended to fix #591.

  1. Make POSE3_EXPMAP and ROT3_EXPMAP depend on each other.
  2. CayleyChart Local is fully Eigen based, allowing for Eigen's optimization to do it's job.
  3. Updated failing Similarity3 test to only run check for Rot3 Expmap.

@varunagrawal varunagrawal added the bugfix Fixes an issue or bug label Nov 12, 2020
@varunagrawal varunagrawal self-assigned this Nov 12, 2020
Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, but need to see timing benchmark before approval :-)

@@ -31,6 +31,13 @@ if(NOT MSVC AND NOT XCODE_VERSION)
option(GTSAM_BUILD_WITH_CCACHE "Use ccache compiler cache" ON)
endif()

# Enable GTSAM_ROT3_EXPMAP if GTSAM_POSE3_EXPMAP is enabled, and vice versa.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit problematic as it is done "silently". Add a message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally it should be one flag 🙁 but I need to consult you before making that design change.

const double y = b * f - ce - c;
const double z = fg - di - d;
return K * Vector3(x, y, z);
const Matrix3 P = A + I_3x3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes if accompanied by benchmark results on effect on timing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old version is way faster ~650 ms vs 2248 ms for the fully Eigen based one. Reverting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll instead add more documentation.

@dellaert
Copy link
Member

Note, search through "timeXXX.cpp" files, might already be there.

@varunagrawal
Copy link
Collaborator Author

I added a CI path for the Cayley Transform in the last commit.

@varunagrawal
Copy link
Collaborator Author

@chrisbeall good news! The CI for the Cayley transform passes.

@dellaert
Copy link
Member

Good, now timing sanity-check and we can land this :-)

@varunagrawal
Copy link
Collaborator Author

varunagrawal commented Nov 12, 2020

Timing results for Rot3:

Before:

Rodriguez formula given axis angle
1121.42 milliseconds
11214.2 nanosecs/call

Rodriguez formula given canonical coordinates
1136.52 milliseconds
11365.2 nanosecs/call

Expmap
1516.92 milliseconds
15169.2 nanosecs/call

Retract
624.292 milliseconds
6242.92 nanosecs/call

Logmap
694.127 milliseconds
6941.27 nanosecs/call

localCoordinates
617.415 milliseconds
6174.15 nanosecs/call

Slow rotation matrix
1172.43 milliseconds
11724.3 nanosecs/call

Fast Rotation matrix
143.142 milliseconds
1431.42 nanosecs/call

After:

Rodriguez formula given axis angle
1146.84 milliseconds
11468.4 nanosecs/call

Rodriguez formula given canonical coordinates
1187.28 milliseconds
11872.8 nanosecs/call

Expmap
1598.05 milliseconds
15980.5 nanosecs/call

Retract
624.476 milliseconds
6244.76 nanosecs/call

Logmap
715.463 milliseconds
7154.63 nanosecs/call

localCoordinates
862.56 milliseconds
8625.6 nanosecs/call

Slow rotation matrix
1200.18 milliseconds
12001.8 nanosecs/call

Fast Rotation matrix
144.373 milliseconds
1443.73 nanosecs/call

There is negligible impact due to the determinant check.

@dellaert
Copy link
Member

I was not worried about the determinant check. I was worried about replacing hand optimized code with much nicer but more high-level code :-) could you just point out the isolated results for Cayley, which is affected by that piece of code? And make sure the right flags are set so Cayley is in fact called ? (You did not mention flags in your comment)

@varunagrawal
Copy link
Collaborator Author

I undid the change from hand optimized to high-level, so it is back to hand optimized code now (albeit with an extra determinant check). The flags being set are in the CI and I already verified that. 🙂

@dellaert
Copy link
Member

Wait! I liked your nicer code, if it is the same speed. What was the timing on that?

@dellaert
Copy link
Member

Oh, wait, I did not see your comment above. OK, I’ll approve this version, then :-)

@dellaert dellaert merged commit 1b89482 into develop Nov 13, 2020
@dellaert dellaert deleted the fix/rot3-cayley branch November 13, 2020 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes an issue or bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numerous unit test failures with GTSAM_ROT3_EXPMAP=OFF
2 participants