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

Port graph printing on optimization failures from ROS1 to ROS2 #332

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from
Open
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
17 changes: 11 additions & 6 deletions fuse_optimizers/src/fixed_lag_smoother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,28 @@ void FixedLagSmoother::optimizationLoop()
// Optimize the entire graph
summary_ = graph_->optimize(params_.solver_options);

// Optimization is complete. Notify all the things about the graph changes.
const auto new_transaction_stamp = new_transaction->stamp();
notify(std::move(new_transaction), graph_->clone());

// Abort if optimization failed. Not converging is not a failure because the solution found is
// usable.
if (!summary_.IsSolutionUsable()) {
std::ostringstream oss;
oss << "Graph:\n";
graph_->print(oss);
oss << "\nTransaction:\n";
new_transaction->print(oss);

RCLCPP_FATAL_STREAM(
logger_,
"Optimization failed after updating the graph with the transaction with timestamp "
<< new_transaction_stamp.nanoseconds() <<
". Leaving optimization loop and requesting node shutdown...");
<< new_transaction->stamp().nanoseconds() <<
". Leaving optimization loop and requesting node shutdown...\n" << oss.str());
RCLCPP_INFO(logger_, summary_.FullReport().c_str());
rclcpp::shutdown();
break;
}

// Optimization is complete. Notify all the things about the graph changes.
notify(std::move(new_transaction), graph_->clone());

// Compute a transaction that marginalizes out those variables.
lag_expiration_ = computeLagExpirationTime();
marginal_transaction_ = fuse_constraints::marginalizeVariables(
Expand Down