Skip to content

Commit bb25c35

Browse files
authored
Print graph & transaction on optimization failure (#321)
1 parent d7de264 commit bb25c35

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

fuse_optimizers/src/fixed_lag_smoother.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,26 @@ void FixedLagSmoother::optimizationLoop()
223223
// Optimize the entire graph
224224
summary_ = graph_->optimize(params_.solver_options);
225225

226-
// Optimization is complete. Notify all the things about the graph changes.
227-
const auto new_transaction_stamp = new_transaction->stamp();
228-
notify(std::move(new_transaction), graph_->clone());
229-
230226
// Abort if optimization failed. Not converging is not a failure because the solution found is usable.
231227
if (!summary_.IsSolutionUsable())
232228
{
229+
std::ostringstream oss;
230+
oss << "Graph:\n";
231+
graph_->print(oss);
232+
oss << "\nTransaction:\n";
233+
new_transaction->print(oss);
234+
233235
ROS_FATAL_STREAM("Optimization failed after updating the graph with the transaction with timestamp "
234-
<< new_transaction_stamp << ". Leaving optimization loop and requesting node shutdown...");
236+
<< new_transaction->stamp() << ". Leaving optimization loop and requesting node shutdown...\n"
237+
<< oss.str());
235238
ROS_INFO_STREAM(summary_.FullReport());
236239
ros::requestShutdown();
237240
break;
238241
}
239242

243+
// Optimization is complete and succeeded. Notify all the things about the graph changes.
244+
notify(std::move(new_transaction), graph_->clone());
245+
240246
// Compute a transaction that marginalizes out those variables.
241247
lag_expiration_ = computeLagExpirationTime();
242248
marginal_transaction_ = fuse_constraints::marginalizeVariables(

0 commit comments

Comments
 (0)