Skip to content

TrajectoryAlignerSim3 - add point3 constraints if available, optionally use GNC#2445

Merged
dellaert merged 9 commits intodevelopfrom
sim3-points
Mar 1, 2026
Merged

TrajectoryAlignerSim3 - add point3 constraints if available, optionally use GNC#2445
dellaert merged 9 commits intodevelopfrom
sim3-points

Conversation

@akshay-krishnan
Copy link
Copy Markdown
Contributor

No description provided.

@akshay-krishnan akshay-krishnan requested a review from dellaert March 1, 2026 05:19
@akshay-krishnan akshay-krishnan requested a review from Copilot March 1, 2026 05:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends TrajectoryAlignerSim3 to optionally accept point3-to-point3 correspondence constraints between overlapping trajectories and optionally use a GNC (Graduated Non-Convexity) optimizer instead of the default Levenberg-Marquardt optimizer.

Changes:

  • Extended the single constructor with two new optional parameters: overlapping_points and use_gnc_optimizer
  • Added new overloaded constructors in the SWIG interface to expose the new functionality
  • Implemented the point3 constraint graph building and conditional GNC optimizer selection

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
gtsam/sfm/TrajectoryAlignerSim3.cpp Core implementation of point3 constraints and GNC optimizer branching
gtsam/sfm/TrajectoryAlignerSim3.h Header updated with new optional parameters and new member field
gtsam/sfm/sfm.i SWIG interface updated with new constructor overloads

const Expression<Similarity3> bSa(simKey);
for (const auto &[p1, p2] : overlap) {
const Point3_ b_p2_(bSa, &Similarity3::transformFrom, p1);
graph_.addExpressionFactor(b_p2_, p2, noiseModel::Isotropic::Sigma(3, 3-2));
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The noise sigma value 3-2 evaluates to 1 at compile time. This looks like an unintentional leftover expression — likely either 3.0 or some other meaningful constant was intended as the sigma. The magic arithmetic makes the intent unclear and could mask a bug if the wrong value was left in accidentally. Replace with the intended numeric literal and, ideally, name it.

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +117
const Point3_ b_p2_(bSa, &Similarity3::transformFrom, p1);
graph_.addExpressionFactor(b_p2_, p2, noiseModel::Isotropic::Sigma(3, 3-2));
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The variable b_p2_ has a trailing underscore, which in the GTSAM codebase conventionally denotes an Expression<> type, not a plain value. While that is technically correct here, the name itself is confusing: p1 is the point in the a frame being transformed to the b frame, so it represents the b-frame version of p1, not of p2. A clearer name such as b_p1_ would match the semantics.

Suggested change
const Point3_ b_p2_(bSa, &Similarity3::transformFrom, p1);
graph_.addExpressionFactor(b_p2_, p2, noiseModel::Isotropic::Sigma(3, 3-2));
const Point3_ b_p1_(bSa, &Similarity3::transformFrom, p1);
graph_.addExpressionFactor(b_p1_, p2, noiseModel::Isotropic::Sigma(3, 3-2));

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +121


Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The closing brace on line 122 closes the constructor body, but the if (!overlapping_points.empty()) block opened on line 106 is never explicitly closed — there is a missing } to close the if block (and its inner for loop is also correctly closed). As written, the constructor body terminates prematurely, meaning any code that should follow this block (e.g., the use_gnc_optimizer_ member initialization) is never reached, and the constructor is also missing the assignment use_gnc_optimizer_ = use_gnc_optimizer;. The missing closing brace for the if block must be added before line 122.

Suggested change
}
use_gnc_optimizer_ = use_gnc_optimizer;

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +72
const std::vector<Similarity3> &bSa_all = {},
const std::vector<std::vector<std::pair<Point3, Point3>>> &overlapping_points = {},
const bool use_gnc_optimizer = false);
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The new constructor signature adds overlapping_points and use_gnc_optimizer as optional parameters to the existing constructor, but the corresponding .cpp implementation shown in the diff only adds overlapping_points — the use_gnc_optimizer parameter is absent from the definition's parameter list. This mismatch means use_gnc_optimizer_ is never set from the constructor argument, so the GNC path is never taken regardless of what the caller passes.

Copilot uses AI. Check for mistakes.
gtsam/sfm/sfm.i Outdated
Comment on lines +188 to +193
TrajectoryAlignerSim3(
const std::vector<gtsam::UnaryMeasurement<gtsam::Pose3>>& aTi,
const std::vector<std::vector<gtsam::UnaryMeasurement<gtsam::Pose3>>>& bTi_all,
const std::vector<gtsam::Similarity3>& bSa_all,
const std::vector<std::vector<std::pair<gtsam::Point3, gtsam::Point3>>> &overlapping_points,
const bool use_gnc_optimizer);
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

Because the C++ header now exposes a single constructor with all parameters defaulted, the SWIG interface should mirror this instead of declaring multiple overloads. Having separate overloads in the .i file that differ only by the presence of overlapping_points and use_gnc_optimizer creates redundancy and can diverge from the header over time. Consider using a single SWIG declaration with default arguments matching the header, or at minimum ensuring the overloads stay in sync with any future signature changes.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 1, 2026

timeSFMBAL benchmark

  • Head: 0a9f08845e12d27254ff60ef52cdda47d546d6ff
  • Base: f7dddec7b8766e97c1c04894da096d304bbdda92

No head benchmark results were found.

Worker runs

Role Runner SHA Conclusion
head linux-x64 0a9f08845e12d27254ff60ef52cdda47d546d6ff failure
base linux-x64 f7dddec7b8766e97c1c04894da096d304bbdda92 success
head linux-arm64 0a9f08845e12d27254ff60ef52cdda47d546d6ff failure
base linux-arm64 f7dddec7b8766e97c1c04894da096d304bbdda92 success
head macos-arm64 0a9f08845e12d27254ff60ef52cdda47d546d6ff failure
base macos-arm64 f7dddec7b8766e97c1c04894da096d304bbdda92 success

Copy link
Copy Markdown
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.

LGTM but some CI failures. Make sure to compile with warnings treated as errors.

@akshay-krishnan akshay-krishnan requested a review from dellaert March 1, 2026 18:55
Copy link
Copy Markdown
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.

LGTM< will merge after CI succeeds

@dellaert dellaert merged commit 9abbd45 into develop Mar 1, 2026
32 checks passed
@dellaert dellaert deleted the sim3-points branch March 1, 2026 21:40
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