Added error log message when graph optimization error is huge (error ratio over > 100) and RGBD/OptimizeMaxError is disabled.

This commit is contained in:
matlabbe
2023-07-03 18:04:54 -07:00
parent b8c298efd9
commit 64f79813cd

View File

@@ -3169,7 +3169,7 @@ bool Rtabmap::process(
UWARN("Optimization failed, rejecting localization!"); UWARN("Optimization failed, rejecting localization!");
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError > 0.0f) else
{ {
UINFO("Compute max graph errors..."); UINFO("Compute max graph errors...");
const Link * maxLinearLink = 0; const Link * maxLinearLink = 0;
@@ -3199,7 +3199,7 @@ bool Rtabmap::process(
maxLinearLink->transVariance(), maxLinearLink->transVariance(),
maxLinearError/sqrt(maxLinearLink->transVariance()), maxLinearError/sqrt(maxLinearLink->transVariance()),
_optimizationMaxError); _optimizationMaxError);
if(maxLinearErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxLinearErrorRatio > _optimizationMaxError)
{ {
UWARN("Rejecting localization (%d <-> %d) in this " UWARN("Rejecting localization (%d <-> %d) in this "
"iteration because a wrong loop closure has been " "iteration because a wrong loop closure has been "
@@ -3218,6 +3218,19 @@ bool Rtabmap::process(
_optimizationMaxError); _optimizationMaxError);
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError == 0.0f && maxLinearErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Linear error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxLinearErrorRatio,
maxLinearLink->from(),
maxLinearLink->to(),
maxLinearLink->type(),
maxLinearError,
sqrt(maxLinearLink->transVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
if(maxAngularLink) if(maxAngularLink)
{ {
@@ -3228,7 +3241,7 @@ bool Rtabmap::process(
maxAngularLink->rotVariance(), maxAngularLink->rotVariance(),
maxAngularError/sqrt(maxAngularLink->rotVariance()), maxAngularError/sqrt(maxAngularLink->rotVariance()),
_optimizationMaxError); _optimizationMaxError);
if(maxAngularErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxAngularErrorRatio > _optimizationMaxError)
{ {
UWARN("Rejecting localization (%d <-> %d) in this " UWARN("Rejecting localization (%d <-> %d) in this "
"iteration because a wrong loop closure has been " "iteration because a wrong loop closure has been "
@@ -3247,6 +3260,19 @@ bool Rtabmap::process(
_optimizationMaxError); _optimizationMaxError);
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError == 0.0f && maxAngularErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Angular error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxAngularErrorRatio,
maxAngularLink->from(),
maxAngularLink->to(),
maxAngularLink->type(),
maxAngularError*180.0f/CV_PI,
sqrt(maxAngularLink->rotVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
} }
@@ -3283,7 +3309,7 @@ bool Rtabmap::process(
UWARN("Optimization failed, rejecting localization!"); UWARN("Optimization failed, rejecting localization!");
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError > 0.0f) else
{ {
UINFO("Compute max graph errors..."); UINFO("Compute max graph errors...");
const Link * maxLinearLink = 0; const Link * maxLinearLink = 0;
@@ -3313,7 +3339,7 @@ bool Rtabmap::process(
maxLinearLink->transVariance(), maxLinearLink->transVariance(),
maxLinearError/sqrt(maxLinearLink->transVariance()), maxLinearError/sqrt(maxLinearLink->transVariance()),
_optimizationMaxError); _optimizationMaxError);
if(maxLinearErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxLinearErrorRatio > _optimizationMaxError)
{ {
UWARN("Rejecting localization (%d <-> %d) in this " UWARN("Rejecting localization (%d <-> %d) in this "
"iteration because a wrong loop closure has been " "iteration because a wrong loop closure has been "
@@ -3332,6 +3358,19 @@ bool Rtabmap::process(
_optimizationMaxError); _optimizationMaxError);
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError == 0.0f && maxLinearErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Linear error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxLinearErrorRatio,
maxLinearLink->from(),
maxLinearLink->to(),
maxLinearLink->type(),
maxLinearError,
sqrt(maxLinearLink->transVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
if(maxAngularLink) if(maxAngularLink)
{ {
@@ -3342,7 +3381,7 @@ bool Rtabmap::process(
maxAngularLink->rotVariance(), maxAngularLink->rotVariance(),
maxAngularError/sqrt(maxAngularLink->rotVariance()), maxAngularError/sqrt(maxAngularLink->rotVariance()),
_optimizationMaxError); _optimizationMaxError);
if(maxAngularErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxAngularErrorRatio > _optimizationMaxError)
{ {
UWARN("Rejecting localization (%d <-> %d) in this " UWARN("Rejecting localization (%d <-> %d) in this "
"iteration because a wrong loop closure has been " "iteration because a wrong loop closure has been "
@@ -3361,6 +3400,19 @@ bool Rtabmap::process(
_optimizationMaxError); _optimizationMaxError);
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError == 0.0f && maxAngularErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Angular error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxAngularErrorRatio,
maxAngularLink->from(),
maxAngularLink->to(),
maxAngularLink->type(),
maxAngularError*180.0f/CV_PI,
sqrt(maxAngularLink->rotVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
} }
} }
@@ -3597,7 +3649,6 @@ bool Rtabmap::process(
rejectedLandmark = true; rejectedLandmark = true;
} }
else if(_memory->isIncremental() && else if(_memory->isIncremental() &&
_optimizationMaxError > 0.0f &&
loopClosureLinksAdded.size() && loopClosureLinksAdded.size() &&
optimizationIterations > 0 && optimizationIterations > 0 &&
constraints.size()) constraints.size())
@@ -3623,7 +3674,7 @@ bool Rtabmap::process(
if(maxLinearLink) if(maxLinearLink)
{ {
UINFO("Max optimization linear error = %f m (link %d->%d, var=%f, ratio error/std=%f)", maxLinearError, maxLinearLink->from(), maxLinearLink->to(), maxLinearLink->transVariance(), maxLinearError/sqrt(maxLinearLink->transVariance())); UINFO("Max optimization linear error = %f m (link %d->%d, var=%f, ratio error/std=%f)", maxLinearError, maxLinearLink->from(), maxLinearLink->to(), maxLinearLink->transVariance(), maxLinearError/sqrt(maxLinearLink->transVariance()));
if(maxLinearErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxLinearErrorRatio > _optimizationMaxError)
{ {
UWARN("Rejecting all added loop closures (%d, first is %d <-> %d) in this " UWARN("Rejecting all added loop closures (%d, first is %d <-> %d) in this "
"iteration because a wrong loop closure has been " "iteration because a wrong loop closure has been "
@@ -3643,11 +3694,24 @@ bool Rtabmap::process(
_optimizationMaxError); _optimizationMaxError);
reject = true; reject = true;
} }
else if(_optimizationMaxError == 0.0f && maxLinearErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Linear error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxLinearErrorRatio,
maxLinearLink->from(),
maxLinearLink->to(),
maxLinearLink->type(),
maxLinearError,
sqrt(maxLinearLink->transVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
if(maxAngularLink) if(maxAngularLink)
{ {
UINFO("Max optimization angular error = %f deg (link %d->%d, var=%f, ratio error/std=%f)", maxAngularError*180.0f/CV_PI, maxAngularLink->from(), maxAngularLink->to(), maxAngularLink->rotVariance(), maxAngularError/sqrt(maxAngularLink->rotVariance())); UINFO("Max optimization angular error = %f deg (link %d->%d, var=%f, ratio error/std=%f)", maxAngularError*180.0f/CV_PI, maxAngularLink->from(), maxAngularLink->to(), maxAngularLink->rotVariance(), maxAngularError/sqrt(maxAngularLink->rotVariance()));
if(maxAngularErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxAngularErrorRatio > _optimizationMaxError)
{ {
UWARN("Rejecting all added loop closures (%d, first is %d <-> %d) in this " UWARN("Rejecting all added loop closures (%d, first is %d <-> %d) in this "
"iteration because a wrong loop closure has been " "iteration because a wrong loop closure has been "
@@ -3667,6 +3731,19 @@ bool Rtabmap::process(
_optimizationMaxError); _optimizationMaxError);
reject = true; reject = true;
} }
else if(_optimizationMaxError == 0.0f && maxAngularErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Angular error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxAngularErrorRatio,
maxAngularLink->from(),
maxAngularLink->to(),
maxAngularLink->type(),
maxAngularError*180.0f/CV_PI,
sqrt(maxAngularLink->rotVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
if(reject) if(reject)
@@ -5522,8 +5599,7 @@ int Rtabmap::detectMoreLoopClosures(
if(!t.isNull()) if(!t.isNull())
{ {
bool updateConstraints = true; bool updateConstraints = true;
if(_optimizationMaxError > 0.0f)
{
//optimize the graph to see if the new constraint is globally valid //optimize the graph to see if the new constraint is globally valid
int fromId = from; int fromId = from;
@@ -5571,7 +5647,7 @@ int Rtabmap::detectMoreLoopClosures(
if(maxLinearLink) if(maxLinearLink)
{ {
UINFO("Max optimization linear error = %f m (link %d->%d)", maxLinearError, maxLinearLink->from(), maxLinearLink->to()); UINFO("Max optimization linear error = %f m (link %d->%d)", maxLinearError, maxLinearLink->from(), maxLinearLink->to());
if(maxLinearErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxLinearErrorRatio > _optimizationMaxError)
{ {
msg = uFormat("Rejecting edge %d->%d because " msg = uFormat("Rejecting edge %d->%d because "
"graph error is too large after optimization (%f m for edge %d->%d with ratio %f > std=%f m). " "graph error is too large after optimization (%f m for edge %d->%d with ratio %f > std=%f m). "
@@ -5586,11 +5662,24 @@ int Rtabmap::detectMoreLoopClosures(
Parameters::kRGBDOptimizeMaxError().c_str(), Parameters::kRGBDOptimizeMaxError().c_str(),
_optimizationMaxError); _optimizationMaxError);
} }
else if(_optimizationMaxError == 0.0f && maxLinearErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Linear error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxLinearErrorRatio,
maxLinearLink->from(),
maxLinearLink->to(),
maxLinearLink->type(),
maxLinearError,
sqrt(maxLinearLink->transVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
else if(maxAngularLink) else if(maxAngularLink)
{ {
UINFO("Max optimization angular error = %f deg (link %d->%d)", maxAngularError*180.0f/M_PI, maxAngularLink->from(), maxAngularLink->to()); UINFO("Max optimization angular error = %f deg (link %d->%d)", maxAngularError*180.0f/M_PI, maxAngularLink->from(), maxAngularLink->to());
if(maxAngularErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxAngularErrorRatio > _optimizationMaxError)
{ {
msg = uFormat("Rejecting edge %d->%d because " msg = uFormat("Rejecting edge %d->%d because "
"graph error is too large after optimization (%f deg for edge %d->%d with ratio %f > std=%f deg). " "graph error is too large after optimization (%f deg for edge %d->%d with ratio %f > std=%f deg). "
@@ -5605,6 +5694,19 @@ int Rtabmap::detectMoreLoopClosures(
Parameters::kRGBDOptimizeMaxError().c_str(), Parameters::kRGBDOptimizeMaxError().c_str(),
_optimizationMaxError); _optimizationMaxError);
} }
else if(_optimizationMaxError == 0.0f && maxAngularErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Angular error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxAngularErrorRatio,
maxAngularLink->from(),
maxAngularLink->to(),
maxAngularLink->type(),
maxAngularError*180.0f/CV_PI,
sqrt(maxAngularLink->rotVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
} }
else else
@@ -5622,7 +5724,6 @@ int Rtabmap::detectMoreLoopClosures(
{ {
poses = optimizedPoses; poses = optimizedPoses;
} }
}
if(updateConstraints) if(updateConstraints)
{ {
@@ -5904,7 +6005,7 @@ bool Rtabmap::addLink(const Link & link)
{ {
msg = uFormat("Rejecting edge %d->%d because graph optimization has failed!", link.from(), link.to()); msg = uFormat("Rejecting edge %d->%d because graph optimization has failed!", link.from(), link.to());
} }
else if(_optimizationMaxError > 0.0f) else
{ {
float maxLinearError = 0.0f; float maxLinearError = 0.0f;
float maxLinearErrorRatio = 0.0f; float maxLinearErrorRatio = 0.0f;
@@ -5925,7 +6026,7 @@ bool Rtabmap::addLink(const Link & link)
if(maxLinearLink) if(maxLinearLink)
{ {
UINFO("Max optimization linear error = %f m (link %d->%d)", maxLinearError, maxLinearLink->from(), maxLinearLink->to()); UINFO("Max optimization linear error = %f m (link %d->%d)", maxLinearError, maxLinearLink->from(), maxLinearLink->to());
if(maxLinearErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxLinearErrorRatio > _optimizationMaxError)
{ {
msg = uFormat("Rejecting edge %d->%d because " msg = uFormat("Rejecting edge %d->%d because "
"graph error is too large after optimization (%f m for edge %d->%d with ratio %f > std=%f m). " "graph error is too large after optimization (%f m for edge %d->%d with ratio %f > std=%f m). "
@@ -5940,11 +6041,24 @@ bool Rtabmap::addLink(const Link & link)
Parameters::kRGBDOptimizeMaxError().c_str(), Parameters::kRGBDOptimizeMaxError().c_str(),
_optimizationMaxError); _optimizationMaxError);
} }
else if(_optimizationMaxError == 0.0f && maxLinearErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Linear error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxLinearErrorRatio,
maxLinearLink->from(),
maxLinearLink->to(),
maxLinearLink->type(),
maxLinearError,
sqrt(maxLinearLink->transVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
else if(maxAngularLink) else if(maxAngularLink)
{ {
UINFO("Max optimization angular error = %f deg (link %d->%d)", maxAngularError*180.0f/M_PI, maxAngularLink->from(), maxAngularLink->to()); UINFO("Max optimization angular error = %f deg (link %d->%d)", maxAngularError*180.0f/M_PI, maxAngularLink->from(), maxAngularLink->to());
if(maxAngularErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxAngularErrorRatio > _optimizationMaxError)
{ {
msg = uFormat("Rejecting edge %d->%d because " msg = uFormat("Rejecting edge %d->%d because "
"graph error is too large after optimization (%f deg for edge %d->%d with ratio %f > std=%f deg). " "graph error is too large after optimization (%f deg for edge %d->%d with ratio %f > std=%f deg). "
@@ -5959,6 +6073,19 @@ bool Rtabmap::addLink(const Link & link)
Parameters::kRGBDOptimizeMaxError().c_str(), Parameters::kRGBDOptimizeMaxError().c_str(),
_optimizationMaxError); _optimizationMaxError);
} }
else if(_optimizationMaxError == 0.0f && maxAngularErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Angular error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxAngularErrorRatio,
maxAngularLink->from(),
maxAngularLink->to(),
maxAngularLink->type(),
maxAngularError*180.0f/CV_PI,
sqrt(maxAngularLink->rotVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
} }
if(!msg.empty()) if(!msg.empty())
@@ -6063,7 +6190,7 @@ bool Rtabmap::addLink(const Link & link)
UWARN("Optimization failed, rejecting localization!"); UWARN("Optimization failed, rejecting localization!");
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError > 0.0f) else
{ {
UINFO("Compute max graph errors..."); UINFO("Compute max graph errors...");
float maxLinearError = 0.0f; float maxLinearError = 0.0f;
@@ -6090,7 +6217,7 @@ bool Rtabmap::addLink(const Link & link)
if(maxLinearLink) if(maxLinearLink)
{ {
UINFO("Max optimization linear error = %f m (link %d->%d, var=%f, ratio error/std=%f)", maxLinearError, maxLinearLink->from(), maxLinearLink->to(), maxLinearLink->transVariance(), maxLinearError/sqrt(maxLinearLink->transVariance())); UINFO("Max optimization linear error = %f m (link %d->%d, var=%f, ratio error/std=%f)", maxLinearError, maxLinearLink->from(), maxLinearLink->to(), maxLinearLink->transVariance(), maxLinearError/sqrt(maxLinearLink->transVariance()));
if(maxLinearErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxLinearErrorRatio > _optimizationMaxError)
{ {
UWARN("Rejecting localization (%d <-> %d) in this " UWARN("Rejecting localization (%d <-> %d) in this "
"iteration because a wrong loop closure has been " "iteration because a wrong loop closure has been "
@@ -6109,11 +6236,24 @@ bool Rtabmap::addLink(const Link & link)
_optimizationMaxError); _optimizationMaxError);
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError == 0.0f && maxLinearErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Linear error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxLinearErrorRatio,
maxLinearLink->from(),
maxLinearLink->to(),
maxLinearLink->type(),
maxLinearError,
sqrt(maxLinearLink->transVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
if(maxAngularLink) if(maxAngularLink)
{ {
UINFO("Max optimization angular error = %f deg (link %d->%d, var=%f, ratio error/std=%f)", maxAngularError*180.0f/CV_PI, maxAngularLink->from(), maxAngularLink->to(), maxAngularLink->rotVariance(), maxAngularError/sqrt(maxAngularLink->rotVariance())); UINFO("Max optimization angular error = %f deg (link %d->%d, var=%f, ratio error/std=%f)", maxAngularError*180.0f/CV_PI, maxAngularLink->from(), maxAngularLink->to(), maxAngularLink->rotVariance(), maxAngularError/sqrt(maxAngularLink->rotVariance()));
if(maxAngularErrorRatio > _optimizationMaxError) if(_optimizationMaxError > 0.0f && maxAngularErrorRatio > _optimizationMaxError)
{ {
UWARN("Rejecting localization (%d <-> %d) in this " UWARN("Rejecting localization (%d <-> %d) in this "
"iteration because a wrong loop closure has been " "iteration because a wrong loop closure has been "
@@ -6132,6 +6272,19 @@ bool Rtabmap::addLink(const Link & link)
_optimizationMaxError); _optimizationMaxError);
rejectLocalization = true; rejectLocalization = true;
} }
else if(_optimizationMaxError == 0.0f && maxAngularErrorRatio>100)
{
UERROR("Huge optimization error detected!"
"Angular error ratio of %f (edge %d->%d, type=%d, abs error=%f m, stddev=%f). You may consider "
"enabling \"%s\" to reject those bad optimizations by setting it to a non null value!",
maxAngularErrorRatio,
maxAngularLink->from(),
maxAngularLink->to(),
maxAngularLink->type(),
maxAngularError*180.0f/CV_PI,
sqrt(maxAngularLink->rotVariance()),
Parameters::kRGBDOptimizeMaxError().c_str());
}
} }
} }