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

Stop ceres problem from freeing loss function #519

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions solvers/ceres_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ void CeresSolver::Configure(rclcpp::Node::SharedPtr node)
options_problem_.enable_fast_removal = true;
}

// we do not want the problem definition to own these objects, otherwise they get
// deleted along with the problem
options_problem_.loss_function_ownership = ceres::Ownership::DO_NOT_TAKE_OWNERSHIP;

problem_ = new ceres::Problem(options_problem_);
}

Expand All @@ -158,6 +162,9 @@ CeresSolver::~CeresSolver()
if (nodes_ != NULL) {
delete nodes_;
}
if (blocks_ != NULL) {
delete blocks_;
}
if (problem_ != NULL) {
delete problem_;
}
Expand Down Expand Up @@ -242,6 +249,8 @@ void CeresSolver::Reset()
was_constant_set_ = false;

if (problem_) {
// Note that this also frees anything the problem owns (i.e. local parameterization, cost
// function)
delete problem_;
}

Expand Down