mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
DbViewer: fixed bug where null links were added when added links doen't have enough inliers. g2o/Optimizer: changed back to Levenberg as GaussNewton seems worst on Kinect multi-session mapping
This commit is contained in:
@@ -351,7 +351,7 @@ class RTABMAP_EXP Parameters
|
|||||||
RTABMAP_PARAM(Optimizer, Robust, bool, false, uFormat("Robust graph optimization using Vertigo (only work for g2o and GTSAM optimization strategies). Not compatible with \"%s\" if enabled.", kRGBDOptimizeMaxError().c_str()));
|
RTABMAP_PARAM(Optimizer, Robust, bool, false, uFormat("Robust graph optimization using Vertigo (only work for g2o and GTSAM optimization strategies). Not compatible with \"%s\" if enabled.", kRGBDOptimizeMaxError().c_str()));
|
||||||
|
|
||||||
RTABMAP_PARAM(g2o, Solver, int, 0, "0=csparse 1=pcg 2=cholmod");
|
RTABMAP_PARAM(g2o, Solver, int, 0, "0=csparse 1=pcg 2=cholmod");
|
||||||
RTABMAP_PARAM(g2o, Optimizer, int, 1, "0=Levenberg 1=GaussNewton");
|
RTABMAP_PARAM(g2o, Optimizer, int, 0, "0=Levenberg 1=GaussNewton");
|
||||||
RTABMAP_PARAM(g2o, PixelVariance, double, 1.0, "Pixel variance used for bundle adjustment.");
|
RTABMAP_PARAM(g2o, PixelVariance, double, 1.0, "Pixel variance used for bundle adjustment.");
|
||||||
|
|
||||||
// Odometry
|
// Odometry
|
||||||
|
|||||||
@@ -4294,7 +4294,7 @@ bool DatabaseViewer::addConstraint(int from, int to, bool silent, bool updateGra
|
|||||||
newLink = rtabmap::graph::findLink(linksRemoved_, from, to)->second;
|
newLink = rtabmap::graph::findLink(linksRemoved_, from, to)->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool updateConstraints = true;
|
bool updateConstraints = newLink.isValid();
|
||||||
float maxOptimizationError = uStr2Float(ui_->parameters_toolbox->getParameters().at(Parameters::kRGBDOptimizeMaxError()));
|
float maxOptimizationError = uStr2Float(ui_->parameters_toolbox->getParameters().at(Parameters::kRGBDOptimizeMaxError()));
|
||||||
if(newLink.isValid() &&
|
if(newLink.isValid() &&
|
||||||
maxOptimizationError > 0.0f &&
|
maxOptimizationError > 0.0f &&
|
||||||
@@ -4321,14 +4321,24 @@ bool DatabaseViewer::addConstraint(int from, int to, bool silent, bool updateGra
|
|||||||
std::map<int, Transform> poses;
|
std::map<int, Transform> poses;
|
||||||
std::multimap<int, Link> links;
|
std::multimap<int, Link> links;
|
||||||
optimizer->getConnectedGraph(fromId, poses_, linksIn, poses, links);
|
optimizer->getConnectedGraph(fromId, poses_, linksIn, poses, links);
|
||||||
|
UASSERT(poses.find(fromId) != poses.end());
|
||||||
|
UASSERT(poses.find(newLink.from()) != poses.end());
|
||||||
|
UASSERT(poses.find(newLink.to()) != poses.end());
|
||||||
|
UASSERT(graph::findLink(links, newLink.from(), newLink.to()) != links.end());
|
||||||
poses = optimizer->optimize(fromId, poses, links);
|
poses = optimizer->optimize(fromId, poses, links);
|
||||||
|
std::string msg;
|
||||||
|
if(poses.size())
|
||||||
|
{
|
||||||
for(std::multimap<int, Link>::iterator iter=links.begin(); iter!=links.end(); ++iter)
|
for(std::multimap<int, Link>::iterator iter=links.begin(); iter!=links.end(); ++iter)
|
||||||
{
|
{
|
||||||
// ignore links with high variance
|
// ignore links with high variance
|
||||||
if(iter->second.transVariance() <= 1.0)
|
if(iter->second.transVariance() <= 1.0)
|
||||||
{
|
{
|
||||||
Transform t1 = uValue(poses, iter->second.from(), Transform());
|
UASSERT(poses.find(iter->second.from())!=poses.end());
|
||||||
Transform t2 = uValue(poses, iter->second.to(), Transform());
|
UASSERT(poses.find(iter->second.to())!=poses.end());
|
||||||
|
Transform t1 = poses.at(iter->second.from());
|
||||||
|
Transform t2 = poses.at(iter->second.to());
|
||||||
|
UASSERT(!t1.isNull() && !t2.isNull());
|
||||||
Transform t = t1.inverse()*t2;
|
Transform t = t1.inverse()*t2;
|
||||||
float linearError = uMax3(
|
float linearError = uMax3(
|
||||||
fabs(iter->second.transform().x() - t.x()),
|
fabs(iter->second.transform().x() - t.x()),
|
||||||
@@ -4360,7 +4370,7 @@ bool DatabaseViewer::addConstraint(int from, int to, bool silent, bool updateGra
|
|||||||
|
|
||||||
if(maxLinearError > maxOptimizationError)
|
if(maxLinearError > maxOptimizationError)
|
||||||
{
|
{
|
||||||
std::string 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, %f deg for edge %d->%d). "
|
"graph error is too large after optimization (%f m for edge %d->%d, %f deg for edge %d->%d). "
|
||||||
"\"%s\" is %f m.",
|
"\"%s\" is %f m.",
|
||||||
newLink.from(),
|
newLink.from(),
|
||||||
@@ -4373,8 +4383,17 @@ bool DatabaseViewer::addConstraint(int from, int to, bool silent, bool updateGra
|
|||||||
maxAngularLink->to(),
|
maxAngularLink->to(),
|
||||||
Parameters::kRGBDOptimizeMaxError().c_str(),
|
Parameters::kRGBDOptimizeMaxError().c_str(),
|
||||||
maxOptimizationError);
|
maxOptimizationError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg = uFormat("Rejecting edge %d->%d because graph optimization has failed!",
|
||||||
|
newLink.from(),
|
||||||
|
newLink.to());
|
||||||
|
}
|
||||||
|
if(!msg.empty())
|
||||||
|
{
|
||||||
UWARN("%s", msg.c_str());
|
UWARN("%s", msg.c_str());
|
||||||
|
|
||||||
if(!silent)
|
if(!silent)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this,
|
QMessageBox::warning(this,
|
||||||
|
|||||||
Reference in New Issue
Block a user