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

[RST-4390] Allow variables to be held constant during optimization #243

Merged
merged 4 commits into from
Aug 24, 2021

Conversation

svwilliams
Copy link
Contributor

@svwilliams svwilliams commented Aug 11, 2021

Ceres Solver allows you to mark variables as constant. Ceres will not alter the values of those variables during the optimization. In fact, it actually removes those variables from the linear optimization problem when solving for the best variable values. Add support for constant variables to fuse as follows:

  • Provide an accessor method in the Variable base class for checking if a variable is held constant. Default to return false.
  • Update the graph implementation to check the new variable property during insert and add them to the set of constant variables.
  • Update the marginalization code to check for constant variables and set their jacobians to zero. This is the rough equivalent of removing them from the linear problem entirely.
  • Add a unit test to verify the marginalization code works -- verify the remaining variables optimize to the same value before and after a constant variable is marginalized out.
  • Add a "fixed landmark" variable that uses the new "hold constant" feature

@svwilliams svwilliams merged commit 69b4592 into devel Aug 24, 2021
@svwilliams svwilliams deleted the RST-4390-variable-hold branch August 24, 2021 18:46

bool Point3DFixedLandmark::holdConstant() const
{
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@svwilliams Just curious, I wonder if this is the only difference wrt Point3DLandmark, why Point3DFixedLandmark wasn't simply implemented as:

class Point3DFixedLandmark : public Point3DLandmark
{
public:
  FUSE_VARIABLE_DEFINITIONS(Point3DFixedLandmark);

  bool holdConstant() const
  {
    return true;
  }
};

and the corresponding code for the serialization and pluginlib in the cpp file. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I think just an accident of history.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants