Only compute old error when solved successfully

When the LM system has not been solved successfully,
an exception may be thrown when computing the old error,
so this change makes sure the old error is computed after checking.
release/4.3a0
Michael Bosse 2020-01-23 19:13:41 -08:00
parent 1f43d73b34
commit 1324cfd283
1 changed files with 4 additions and 4 deletions

View File

@ -152,18 +152,18 @@ bool LevenbergMarquardtOptimizer::tryLambda(const GaussianFactorGraph& linear,
systemSolvedSuccessfully = false;
}
// Compute the old linearized error as it is not the same
// as the nonlinear error when robust noise models are used.
double oldLinearizedError = linear.error(VectorValues::Zero(delta));
if (systemSolvedSuccessfully) {
if (verbose)
cout << "linear delta norm = " << delta.norm() << endl;
if (params_.verbosityLM >= LevenbergMarquardtParams::TRYDELTA)
delta.print("delta");
// cost change in the linearized system (old - new)
// Compute the old linearized error as it is not the same
// as the nonlinear error when robust noise models are used.
double oldLinearizedError = linear.error(VectorValues::Zero(delta));
double newlinearizedError = linear.error(delta);
// cost change in the linearized system (old - new)
double linearizedCostChange = oldLinearizedError - newlinearizedError;
if (verbose)
cout << "newlinearizedError = " << newlinearizedError