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

LinearFactorContainer rekey() #1904

Open
svdt opened this issue Nov 20, 2024 · 0 comments
Open

LinearFactorContainer rekey() #1904

svdt opened this issue Nov 20, 2024 · 0 comments

Comments

@svdt
Copy link

svdt commented Nov 20, 2024

Hi,
I am getting seg faults or ValuesKeyDoesNotExist errors when using rekey on the LinearFactorContainer.

Description

As the linearization point is optional and there are checks for linearizationPoint_ in some methods, the rekey method is missing these checks.
https://github.com/borglab/gtsam/blob/develop/gtsam/nonlinear/LinearContainerFactor.cpp#L180

Steps to reproduce

  1. create LinearContainerFactor with GaussianFactor but without a linearization point
  2. rekey the LinearContainerFactor

#include <gtsam/linear/HessianFactor.h>
#include <gtsam/nonlinear/LinearContainerFactor.h>

int main(int argc, char *argv[]) {

    double mu = 1e10;
    size_t dim = 3;
    gtsam::Key key = 0;

    gtsam::HessianFactor H(key, mu * gtsam::Matrix::Identity(dim, dim), gtsam::Vector::Zero(dim), 0.0);
    gtsam::LinearContainerFactor factor(H);

    gtsam::Key new_key = 1;
    std::map<gtsam::Key, gtsam::Key> rekey_mapping = {{key, new_key}};
    factor.rekey(rekey_mapping);

    gtsam::KeyVector rekey_vector = {new_key};
    factor.rekey(rekey_vector);

    return 0;
}

Expected behavior

Remap the keys of the GaussianFactor and only modify linearizationPoint_ if it has a value.

Environment

C++, Ubuntu 20.04, gtsam develop branch commit: 164c354

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

No branches or pull requests

1 participant