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

Add Similarity(2) support in gtsam/geometry #918

Merged
merged 40 commits into from
Apr 30, 2022

Conversation

johnwlambert
Copy link
Contributor

@johnwlambert johnwlambert commented Nov 6, 2021

We previously had Similarity(3).

This adds a basic interface for Similarity(2) which is quite useful for my current work. Mostly parallels the implementation in Similarity3.h / .cpp, except this is a bare bones interface without wedge, adjointMap, expmap, or logmap for now.

@johnwlambert johnwlambert requested a review from dellaert November 6, 2021 19:43
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 CI does not pass… email me when a new review needed as might not catch a GitHub note

gtsam/geometry/Similarity2.cpp Outdated Show resolved Hide resolved
gtsam/geometry/Similarity2.cpp Show resolved Hide resolved
gtsam/geometry/Similarity2.cpp Show resolved Hide resolved
gtsam/geometry/Similarity2.cpp Outdated Show resolved Hide resolved
gtsam/geometry/Similarity2.cpp Outdated Show resolved Hide resolved
return T;
}

Similarity2::operator Pose2() const {
Copy link
Member

Choose a reason for hiding this comment

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

That’s a weird cast

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Casting Sim2 to Pose2 is a bit of an unusual cast, but quite useful for some of my use cases (sometimes ground truth is provided in this form for some datasets).


/// Convert to a rigid body pose (R, s*t)
/// TODO(frank): why is this here? Red flag! Definitely don't have it as a cast.
GTSAM_EXPORT operator Pose2() const;
Copy link
Member

Choose a reason for hiding this comment

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

Interesting that I have comments in this new PR ?? Must have forgotten. In any case, comment holds: remove this cast operator, as I don’t think there is a valid way to cast down, only cast from Pose2 to Sim2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is actually copy-pasted from Similarity3.h. We should probably address that there.

static gtsam::Similarity2 Align(const gtsam::Pose2Pairs& abPosePairs);

// Standard Interface
const Matrix matrix() const;
Copy link
Member

Choose a reason for hiding this comment

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

No const in return

@dellaert
Copy link
Member

@johnwlambert take a look at this again? CI fails, too.

@dellaert
Copy link
Member

dellaert commented Dec 7, 2021

@johnwlambert I think we should start thinking about merging this PR? I think the only thing missing is the closestto? I don’t think it’s appropriate to do that with a constructor, as I mentioned.

@varunagrawal
Copy link
Collaborator

I'm going to leave reviewing to @dellaert (or maybe someone else from gtsfm) since I am a contributor to this PR and hence biased. :)

@varunagrawal varunagrawal requested review from ayushbaid and removed request for varunagrawal March 25, 2022 20:52
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.

Sorry about the delay, let's try to land this. Note I am thinking we should prefer Matrix versions (and do computation there) for all Align constructors and add Rot2 and Rot3 versions, but that's for a different day.

Not yet approving as want to review after comments have been addressed (or rebuffed).

gtsam/geometry/Rot2.cpp Show resolved Hide resolved
@@ -113,6 +113,18 @@ list<Point2> circleCircleIntersection(Point2 c1, double r1, Point2 c2,
return circleCircleIntersection(c1, c2, fh);
}

Point2Pair means(const std::vector<Point2Pair> &abPointPairs) {
Copy link
Member

Choose a reason for hiding this comment

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

For this PR and my latest PR, I'm starting to think we should "light-deprecate" PointPairs and do the computation in Eigen.
https://eigen.tuxfamily.org/dox/group__TutorialReductionsVisitorsBroadcasting.html

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we save this for another PR in favor of landing this one?
We can create an issue to track it.

gtsam/geometry/Pose2.h Show resolved Hide resolved
gtsam/geometry/Similarity2.cpp Show resolved Hide resolved
gtsam/geometry/Similarity2.cpp Outdated Show resolved Hide resolved
gtsam/geometry/Similarity2.h Outdated Show resolved Hide resolved
gtsam/geometry/Similarity2.h Outdated Show resolved Hide resolved
gtsam/geometry/Similarity3.h Outdated Show resolved Hide resolved
gtsam/navigation/tests/testGPSFactor.cpp Show resolved Hide resolved
python/gtsam/tests/test_Sim2.py Outdated Show resolved Hide resolved
@varunagrawal varunagrawal requested a review from dellaert April 29, 2022 22:46
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, ready I think!

@varunagrawal
Copy link
Collaborator

I couldn't find any references for AdjointMap of Sim(2) and a C++ based unit test file is missing. :(

I'll push a test file with a single constructor test and then merge.

@varunagrawal varunagrawal merged commit 6931084 into develop Apr 30, 2022
@varunagrawal varunagrawal deleted the add-Similarity2-classes branch April 30, 2022 23:21
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.

3 participants