Skip to content

Commit

Permalink
fix the issue (SteveMacenski#198) that loop closures can rotate the m…
Browse files Browse the repository at this point in the history
…ap 180° if the lidar is mounted backwards

Set the edges (constraints) based on the robot base frame (base_footprint) instead of sensor frame (laser).
  • Loading branch information
WLwind committed Feb 3, 2021
1 parent 54d735f commit d5dcd6b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions slam_toolbox/lib/karto_sdk/src/Mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,11 @@ namespace karto
// only attach link information if the edge is new
if (isNewEdge == true)
{
pEdge->SetLabel(new LinkInfo(pFromScan->GetSensorPose(), rMean, rCovariance));
auto corrected_pose=pToScan->GetCorrectedPose();
pToScan->SetSensorPose(rMean);
auto corrected_mean_pose=pToScan->GetCorrectedPose();
pToScan->SetCorrectedPose(corrected_pose);
pEdge->SetLabel(new LinkInfo(pFromScan->GetCorrectedPose(), corrected_mean_pose, rCovariance));
if (m_pMapper->m_pScanOptimizer != NULL)
{
m_pMapper->m_pScanOptimizer->AddConstraint(pEdge);
Expand Down Expand Up @@ -1990,7 +1994,7 @@ namespace karto
{
continue;
}
scan->SetSensorPose(iter->second);
scan->SetCorrectedPose(iter->second);
}

pSolver->Clear();
Expand Down

0 comments on commit d5dcd6b

Please sign in to comment.