19 #include <tbb/tbb_thread.h> 20 #include <tbb/concurrent_queue.h> 40 #define MAX_VARIANCE 500.0 41 #define DISTANCE_PENALTY_GAIN 0.2 42 #define ANGLE_PENALTY_GAIN 0.2 252 if (pSensorDataManager != NULL)
273 sensorNames.
Add(iter->first);
341 objects.
Add(rObjects);
390 m_ScanMatcherGridSets.push(
new ScanMatcherGridSet(pCorrelationGrid, pSearchSpaceProbs, pGridLookup));
397 m_ScanMatcherGridSets.push(NULL);
399 m_ScanMatcherGridSets.clear();
410 m_ScanMatcherGridSets.pop(pScanMatcherGridSet);
412 return pScanMatcherGridSet;
420 m_ScanMatcherGridSets.push(pScanMatcherGridSet);
424 tbb::concurrent_bounded_queue<SmartPointer<ScanMatcherGridSet> > m_ScanMatcherGridSets;
438 delete m_pScanMatcherGridSetBank;
452 if (smearDeviation < 0)
456 if (rangeThreshold <= 0)
468 kt_int32u pointReadingMargin =
static_cast<kt_int32u>(ceil(rangeThreshold / resolution));
470 kt_int32s gridSize = searchSpaceSideSize + 2 * pointReadingMargin;
473 assert(gridSize % 2 == 1);
482 pScanMatcher->m_pScanMatcherGridSet =
new ScanMatcherGridSet(pCorrelationGrid, pSearchSpaceProbs, pGridLookup);
487 pScanMatcher->m_pScanMatcherGridSetBank =
new ScanMatcherGridSetBank(10, gridSize, gridSize, resolution, smearDeviation, searchSpaceSideSize, searchSpaceSideSize);
489 pScanMatcher->m_pScanMatcherGridSetBank = NULL;
500 if (m_pOpenMapper->IsMultiThreaded())
503 pScanMatcherGridSet = m_pScanMatcherGridSetBank->CheckOut();
505 pScanMatcherGridSet = m_pScanMatcherGridSet;
510 pScanMatcherGridSet = m_pScanMatcherGridSet;
513 CorrelationGrid* pCorrelationGrid = pScanMatcherGridSet->m_pCorrelationGrid;
514 Grid<kt_double>* pSearchSpaceProbs = pScanMatcherGridSet->m_pSearchSpaceProbs;
531 rCovariance(2, 2) = 4 *
math::Square(m_pOpenMapper->m_pCoarseAngleResolution->GetValue());
533 if (m_pOpenMapper->IsMultiThreaded())
536 m_pScanMatcherGridSetBank->Return(pScanMatcherGridSet);
557 AddScansNew(pCorrelationGrid, rBaseScans, scanPose.
GetPosition());
561 Vector2d coarseSearchOffset(0.5 * (searchDimensions.GetX() - 1) * pCorrelationGrid->
GetResolution(), 0.5 * (searchDimensions.GetY() - 1) * pCorrelationGrid->
GetResolution());
567 kt_double bestResponse = CorrelateScan(pScanMatcherGridSet, pScan, scanPose, coarseSearchOffset, coarseSearchResolution, m_pOpenMapper->m_pCoarseSearchAngleOffset->GetValue(), m_pOpenMapper->m_pCoarseAngleResolution->GetValue(), doPenalize, rMean, rCovariance,
false);
569 if (m_pOpenMapper->m_pUseResponseExpansion->GetValue() ==
true)
574 std::cout <<
"Mapper Info: Expanding response search space!" << std::endl;
577 kt_double newSearchAngleOffset = m_pOpenMapper->m_pCoarseSearchAngleOffset->GetValue();
582 bestResponse = CorrelateScan(pScanMatcherGridSet, pScan, scanPose, coarseSearchOffset, coarseSearchResolution, newSearchAngleOffset, m_pOpenMapper->m_pCoarseAngleResolution->GetValue(), doPenalize, rMean, rCovariance,
false);
593 std::cout <<
"Mapper Warning: Unable to calculate response!" << std::endl;
601 Vector2d fineSearchOffset(coarseSearchResolution * 0.5);
603 bestResponse = CorrelateScan(pScanMatcherGridSet, pScan, rMean, fineSearchOffset, fineSearchResolution, 0.5 * m_pOpenMapper->m_pCoarseAngleResolution->GetValue(), m_pOpenMapper->m_pFineSearchAngleOffset->GetValue(), doPenalize, rMean, rCovariance,
true);
607 std::cout <<
" BEST POSE = " << rMean <<
" BEST RESPONSE = " << bestResponse <<
", VARIANCE = " << rCovariance(0, 0) <<
", " << rCovariance(1, 1) << std::endl;
612 if (m_pOpenMapper->IsMultiThreaded())
615 m_pScanMatcherGridSetBank->Return(pScanMatcherGridSet);
623 class Parallel_CorrelateScan
626 Parallel_CorrelateScan(std::vector<kt_double>* pNewPositionsY, std::vector<kt_double>* pSquaresY,
627 std::vector<kt_double>* pNewPositionsX, std::vector<kt_double>* pSquaresX,
628 std::vector<kt_double>* pAngles,
629 std::vector<std::pair<kt_double, Pose2> >* pPoseResponses,
634 : m_pNewPositionsY(pNewPositionsY)
635 , m_pSquaresY(pSquaresY)
636 , m_pNewPositionsX(pNewPositionsX)
637 , m_pSquaresX(pSquaresX)
639 , m_pPoseResponses(pPoseResponses)
640 , m_pScanMatcher(pScanMatcher)
641 , m_DoPenalize(doPenalize)
642 , m_DistanceVariancePenalty(distanceVariancePenalty)
643 , m_MinimumDistancePenalty(minimumDistancePenalty)
644 , m_AngleVariancePenalty(angleVariancePenalty)
645 , m_MinimumAnglePenalty(minimumAnglePenalty)
646 , m_SearchCenterHeading(searchCenterHeading)
647 , m_pScanMatcherGridSet(pScanMatcherGridSet)
649 m_nX = pNewPositionsX->size();
650 m_nAngles = pAngles->size();
653 void operator()(
const tbb::blocked_range3d<kt_int32s, kt_int32s, kt_int32s>& rRange)
const 655 CorrelationGrid* pCorrelationGrid = m_pScanMatcherGridSet->m_pCorrelationGrid;
657 for (tbb::blocked_range<kt_int32s>::const_iterator yIndex = rRange.pages().begin(); yIndex != rRange.pages().end(); yIndex++)
659 kt_double newPositionY = m_pNewPositionsY->at(yIndex);
660 kt_double squareY = m_pSquaresY->at(yIndex);
662 for (tbb::blocked_range<kt_int32s>::const_iterator xIndex = rRange.rows().begin(); xIndex != rRange.rows().end(); xIndex++)
664 kt_double newPositionX = m_pNewPositionsX->at(xIndex);
665 kt_double squareX = m_pSquaresX->at(xIndex);
669 assert(gridIndex >= 0);
671 kt_double squaredDistance = squareX + squareY;
673 for (tbb::blocked_range<kt_int32s>::const_iterator angleIndex = rRange.cols().begin(); angleIndex != rRange.cols().end(); angleIndex++)
675 kt_int32u poseResponseIndex = (m_nX * m_nAngles) * yIndex + m_nAngles * xIndex + angleIndex;
679 kt_double response = m_pScanMatcher->GetResponse(m_pScanMatcherGridSet, angleIndex, gridIndex);
685 distancePenalty =
math::Maximum(distancePenalty, m_MinimumDistancePenalty);
689 anglePenalty =
math::Maximum(anglePenalty, m_MinimumAnglePenalty);
691 response *= (distancePenalty * anglePenalty);
695 m_pPoseResponses->at(poseResponseIndex) = std::pair<kt_double, Pose2>(response,
Pose2(newPositionX, newPositionY,
math::NormalizeAngle(angle)));
702 std::vector<kt_double>* m_pNewPositionsY;
703 std::vector<kt_double>* m_pSquaresY;
704 std::vector<kt_double>* m_pNewPositionsX;
705 std::vector<kt_double>* m_pSquaresX;
706 std::vector<kt_double>* m_pAngles;
707 std::vector<std::pair<kt_double, Pose2> >* m_pPoseResponses;
710 kt_double m_DistanceVariancePenalty, m_MinimumDistancePenalty;
711 kt_double m_AngleVariancePenalty, m_MinimumAnglePenalty;
721 assert(searchAngleResolution != 0.0);
733 pSearchSpaceProbs->
Clear();
743 std::vector<kt_double> xPoses(nX), newPositionsX(nX), squaresX(nX);
745 for (
kt_int32u xIndex = 0; xIndex < nX; xIndex++)
749 newPositionsX[xIndex] = rSearchCenter.
GetX() + x;
755 std::vector<kt_double> yPoses(nY), newPositionsY(nY), squaresY(nY);
757 for (
kt_int32u yIndex = 0; yIndex < nY; yIndex++)
761 newPositionsY[yIndex] = rSearchCenter.
GetY() + y;
768 std::vector<kt_double>
angles(nAngles);
771 for (
kt_int32u angleIndex = 0; angleIndex < nAngles; angleIndex++)
773 angle = startAngle + angleIndex * searchAngleResolution;
774 angles[angleIndex] = angle;
779 kt_int32u poseResponseSize = nX * nY * nAngles;
780 std::vector<std::pair<kt_double, Pose2> > poseResponses = std::vector<std::pair<kt_double, Pose2> >(poseResponseSize);
786 if (m_pOpenMapper->IsMultiThreaded())
790 Parallel_CorrelateScan myTask(&newPositionsY, &squaresY, &newPositionsX, &squaresX, &angles,
791 &poseResponses,
this, doPenalize,
792 m_pOpenMapper->m_pDistanceVariancePenalty->GetValue(),
793 m_pOpenMapper->m_pMinimumDistancePenalty->GetValue(),
794 m_pOpenMapper->m_pAngleVariancePenalty->GetValue(),
795 m_pOpenMapper->m_pMinimumAnglePenalty->GetValue(),
796 rSearchCenter.
GetHeading(), pScanMatcherGridSet);
799 int grainSizeAngle = 10;
800 tbb::parallel_for(tbb::blocked_range3d<kt_int32s>(0, static_cast<kt_int32s>(nY), grainSizeY, 0, static_cast<kt_int32s>(nX), grainSizeX, 0, nAngles, grainSizeAngle), myTask);
808 for (
kt_int32u yIndex = 0; yIndex < nY; yIndex++)
810 kt_double newPositionY = newPositionsY[yIndex];
813 for (
kt_int32u xIndex = 0; xIndex < nX; xIndex++)
815 kt_double newPositionX = newPositionsX[xIndex];
820 assert(gridIndex >= 0);
822 kt_double squaredDistance = squareX + squareY;
823 for (
kt_int32u angleIndex = 0; angleIndex < nAngles; angleIndex++)
833 distancePenalty =
math::Maximum(distancePenalty, m_pOpenMapper->m_pMinimumDistancePenalty->GetValue());
837 anglePenalty =
math::Maximum(anglePenalty, m_pOpenMapper->m_pMinimumAnglePenalty->GetValue());
839 response *= (distancePenalty * anglePenalty);
843 poseResponses[poseResponseCounter] = std::pair<kt_double, Pose2>(response,
Pose2(newPositionX, newPositionY,
math::NormalizeAngle(angle)));
844 poseResponseCounter++;
849 assert(poseResponseSize == poseResponseCounter);
854 for (
kt_int32u i = 0; i < poseResponseSize; i++)
856 bestResponse =
math::Maximum(bestResponse, poseResponses[i].first);
861 const Pose2& rPose = poseResponses[i].second;
867 throw Exception(
"Mapper FATAL ERROR - Index out of range in probability search!");
879 for (
kt_int32u i = 0; i < poseResponseSize; i++)
883 averagePosition += poseResponses[i].second.GetPosition();
885 kt_double heading = poseResponses[i].second.GetHeading();
886 thetaX += cos(heading);
887 thetaY += sin(heading);
894 if (averagePoseCount > 0)
896 averagePosition /= averagePoseCount;
898 thetaX /= averagePoseCount;
899 thetaY /= averagePoseCount;
901 averagePose =
Pose2(averagePosition, atan2(thetaY, thetaX));
905 throw Exception(
"Mapper FATAL ERROR - Unable to find best position");
909 std::cout <<
"bestPose: " << averagePose << std::endl;
910 std::cout <<
"bestResponse: " << bestResponse << std::endl;
915 ComputePositionalCovariance(pSearchSpaceProbs, averagePose, bestResponse, rSearchCenter, rSearchSpaceOffset, rSearchSpaceResolution, searchAngleResolution, rCovariance);
919 ComputeAngularCovariance(pScanMatcherGridSet, averagePose, bestResponse, rSearchCenter, searchAngleOffset, searchAngleResolution, rCovariance);
925 std::cout <<
"bestPose: " << averagePose << std::endl;
928 if (bestResponse > 1.0)
940 const Pose2& rSearchCenter,
const Vector2d& rSearchSpaceOffset,
951 rCovariance(2, 2) = 4 *
math::Square(searchAngleResolution);
975 for (
kt_int32u yIndex = 0; yIndex < nY; yIndex++)
979 for (
kt_int32u xIndex = 0; xIndex < nX; xIndex++)
987 if (response >= (bestResponse - 0.1))
990 accumulatedVarianceXX += (
math::Square(x - dx) * response);
991 accumulatedVarianceXY += ((x - dx) * (y - dy) * response);
992 accumulatedVarianceYY += (
math::Square(y - dy) * response);
999 kt_double varianceXX = accumulatedVarianceXX / norm;
1000 kt_double varianceXY = accumulatedVarianceXY / norm;
1001 kt_double varianceYY = accumulatedVarianceYY / norm;
1012 kt_double multiplier = 1.0 / bestResponse;
1013 rCovariance(0, 0) = varianceXX * multiplier;
1014 rCovariance(0, 1) = varianceXY * multiplier;
1015 rCovariance(1, 0) = varianceXY * multiplier;
1016 rCovariance(1, 1) = varianceYY * multiplier;
1017 rCovariance(2, 2) = varianceTHTH;
1052 kt_double accumulatedVarianceThTh = 0.0;
1053 for (
kt_int32u angleIndex = 0; angleIndex < nAngles; angleIndex++)
1055 angle = startAngle + angleIndex * searchAngleResolution;
1059 if (response >= (bestResponse - 0.1))
1062 accumulatedVarianceThTh += (
math::Square(angle - bestAngle) * response);
1071 accumulatedVarianceThTh =
math::Square(searchAngleResolution);
1074 accumulatedVarianceThTh /= norm;
1078 accumulatedVarianceThTh = 1000 *
math::Square(searchAngleResolution);
1081 rCovariance(2, 2) = accumulatedVarianceThTh;
1086 pCorrelationGrid->
Clear();
1091 AddScan(pCorrelationGrid, *iter, rViewPoint);
1097 pCorrelationGrid->
Clear();
1112 pValidPoints[index++] = FindValidPoints(*iter, rViewPoint);
1118 AddScanNew(pCorrelationGrid, pValidPoints[i]);
1121 delete[] pValidPoints;
1126 Vector2dList validPoints = FindValidPoints(pScan, rViewPoint);
1138 int gridIndex = pCorrelationGrid->
GridIndex(gridPoint);
1150 if (doSmear ==
true)
1169 int gridIndex = pCorrelationGrid->
GridIndex(gridPoint);
1181 if (doSmear ==
true)
1208 firstPoint = currentPoint;
1212 Vector2d delta = firstPoint - currentPoint;
1220 double a = rViewPoint.
GetY() - firstPoint.
GetY();
1221 double b = firstPoint.
GetX() - rViewPoint.
GetX();
1222 double c = firstPoint.
GetY() * rViewPoint.
GetX() - firstPoint.
GetX() * rViewPoint.
GetY();
1223 double ss = currentPoint.GetX() * a + currentPoint.GetY() * b + c;
1226 firstPoint = currentPoint;
1230 trailingPointIter = iter;
1234 for (; trailingPointIter != iter; trailingPointIter++)
1236 validPoints.
Add(*trailingPointIter);
1256 assert(pOffsets != NULL);
1270 kt_int32s pointGridIndex = gridPositionIndex + pAngleIndexPointer[i];
1277 response += pByte[pAngleIndexPointer[i]];
1282 assert(fabs(response) <= 1.0);
1289 if (m_pOpenMapper->IsMultiThreaded())
1291 throw Exception(
"Correlation grid only available in single-threaded mode");
1295 return m_pScanMatcherGridSet->m_pCorrelationGrid;
1301 if (m_pOpenMapper->IsMultiThreaded())
1303 throw Exception(
"Search grid only available in single-threaded mode");
1307 return m_pScanMatcherGridSet->m_pSearchSpaceProbs;
1315 template<
typename T>
1343 std::queue<Vertex<T>*> toVisit;
1344 std::set<Vertex<T>*> seenVertices;
1345 std::vector<Vertex<T>*> validVertices;
1347 toVisit.push(pStartVertex);
1348 seenVertices.insert(pStartVertex);
1355 if (pVisitor->
Visit(pNext))
1358 validVertices.push_back(pNext);
1366 if (seenVertices.find(pAdjacent) == seenVertices.end())
1368 toVisit.push(pAdjacent);
1369 seenVertices.insert(pAdjacent);
1373 }
while (toVisit.empty() ==
false);
1378 objects.
Add((*iter)->GetVertexObject());
1394 : m_MaxDistanceSquared(math::
Square(maxDistance))
1395 , m_UseScanBarycenter(useScanBarycenter)
1415 return (squaredDistance <= m_MaxDistanceSquared -
KT_TOLERANCE);
1430 : m_pOpenMapper(pOpenMapper)
1451 if (pObject == NULL)
1483 if (pLastScan != NULL)
1500 if (pLastScan == NULL)
1504 assert(pSensorManager->
GetScans(rSensorName).
Size() == 1);
1509 const Identifier& rCandidateSensorName = *iter;
1512 if ((rCandidateSensorName == rSensorName) || (pSensorManager->
GetScans(rCandidateSensorName).
IsEmpty()))
1520 LinkObjects(pSensorManager->
GetScans(rCandidateSensorName)[0], pScan, bestPose, covariance);
1525 means.
Add(bestPose);
1526 covariances.
Add(covariance);
1537 means.
Add(scanPose);
1538 covariances.
Add(rCovariance);
1559 while (!candidateChain.
IsEmpty())
1562 std::cout <<
"Candidate chain for " << pScan->
GetStateId() <<
": [ ";
1565 std::cout << (*iter)->GetStateId() <<
" ";
1567 std::cout <<
"]" << std::endl;
1601 if (fineResponse < m_pOpenMapper->m_pLoopMatchMinimumResponseFine->GetValue())
1636 kt_double bestSquaredDistance = DBL_MAX;
1643 if (squaredDistance < bestSquaredDistance)
1645 bestSquaredDistance = squaredDistance;
1646 pClosestScan = *iter;
1650 return pClosestScan;
1686 if (isNewEdge ==
true)
1705 class Parallel_LinkNearChains
1713 , m_pChains(pChains)
1714 , m_pWasChainLinked(pWasChainLinked)
1716 , m_pCovariances(pCovariances)
1717 , m_MinChainSize(minChainSize)
1718 , m_MinResponse(minResponse)
1722 void operator()(
const tbb::blocked_range<kt_int32s>& rRange)
const 1724 for (
kt_int32s i = rRange.begin(); i != rRange.end(); i++)
1726 m_pWasChainLinked[i] =
false;
1730 if (rChain.
Size() < m_MinChainSize)
1742 m_pWasChainLinked[i] =
true;
1743 m_pMeans->Set(i, mean);
1744 m_pCovariances->Set(i, covariance);
1778 int grainSize = 100;
1779 Parallel_LinkNearChains myTask(
m_pOpenMapper, pScan, &nearChains, pWasChainLinked, &means, &covariances,
1782 tbb::parallel_for(tbb::blocked_range<kt_int32s>(0, static_cast<kt_int32s>(nearChains.
Size()), grainSize), myTask);
1786 if (pWasChainLinked[i] ==
true)
1788 rMeans.
Add(means[i]);
1789 rCovariances.
Add(covariances[i]);
1794 delete [] pWasChainLinked;
1798 if (gotTbb ==
false)
1803 std::cout <<
"Near chain for " << pScan->
GetStateId() <<
": [ ";
1806 std::cout << (*iter2)->GetStateId() <<
" ";
1826 std::cout <<
" ACCEPTED" << std::endl;
1829 rCovariances.
Add(covariance);
1847 assert(pClosestScan != NULL);
1854 LinkObjects(pClosestScan, pScan, rMean, rCovariance);
1856 std::cout <<
"Linking scan " << pScan->
GetStateId() <<
" to chain scan " << pClosestScan->
GetStateId() << std::endl;
1875 if (pNearScan == pScan)
1881 if (processed.
Contains(pNearScan) ==
true)
1890 processed.
Add(pNearScan);
1899 assert(nearScanIndex >= 0);
1902 for (
kt_int32s candidateScanIndex = nearScanIndex - 1; candidateScanIndex >= 0; candidateScanIndex--)
1907 if (pCandidateScan == pScan)
1910 std::cout <<
"INVALID CHAIN: Scan " << pScan->
GetStateId() <<
" is not allowed in chain." << std::endl;
1912 isValidChain =
false;
1920 chain.
Add(pCandidateScan);
1921 processed.
Add(pCandidateScan);
1924 std::cout <<
"Building chain for " << pScan->
GetStateId() <<
": [ ";
1927 std::cout << (*iter2)->GetStateId() <<
" ";
1929 std::cout <<
"]" << std::endl;
1938 chain.
Add(pNearScan);
1942 for (
kt_size_t candidateScanIndex = nearScanIndex + 1; candidateScanIndex < end; candidateScanIndex++)
1946 if (pCandidateScan == pScan)
1949 std::cout <<
"INVALID CHAIN: Scan " << pScan->
GetStateId() <<
" is not allowed in chain." << std::endl;
1951 isValidChain =
false;
1959 chain.
Add(pCandidateScan);
1960 processed.
Add(pCandidateScan);
1963 std::cout <<
"Building chain for " << pScan->
GetStateId() <<
": [ ";
1966 std::cout << (*iter2)->GetStateId() <<
" ";
1968 std::cout <<
"]" << std::endl;
1980 nearChains.
Add(chain);
2000 nearLinkedScans.
Add(pScan);
2004 return nearLinkedScans;
2018 if (pCandidateScan == NULL)
2025 nearScans.
Add(pCandidateScan);
2035 assert(rMeans.
Size() == rCovariances.
Size());
2045 inverses.Add(inverse);
2047 sumOfInverses += inverse;
2052 Pose2 accumulatedPose;
2059 Pose2 pose = *meansIter;
2061 thetaX += cos(angle);
2062 thetaY += sin(angle);
2064 Matrix3 weight = inverseOfSumOfInverses * (*iter);
2065 accumulatedPose += weight * pose;
2070 thetaX /= rMeans.
Size();
2071 thetaY /= rMeans.
Size();
2072 accumulatedPose.
SetHeading(atan2(thetaY, thetaX));
2074 return accumulatedPose;
2089 for (; rStartScanIndex < nScans; rStartScanIndex++)
2099 if (nearLinkedScans.
Contains(pCandidateScan) ==
true)
2105 chain.
Add(pCandidateScan);
2129 if (pSolver != NULL)
2161 , m_pScanSolver(NULL)
2162 , m_Initialized(false)
2163 , m_MultiThreaded(multiThreaded)
2164 , m_pSequentialScanMatcher(NULL)
2165 , m_pMapperSensorManager(NULL)
2189 OpenMapper::~OpenMapper()
2271 if (pObject == NULL)
2278 if (IsLaserRangeFinder(pObject))
2295 if (pLocalizedObject != NULL)
2303 if (pLaserRangeFinder == NULL)
2309 pLaserRangeFinder->
Validate(pScan);
2325 if (pLastScan != NULL)
2387 isObjectProcessed =
true;
2390 return isObjectProcessed;
2396 if (pLastScan == NULL)
kt_int32s GetHeight() const
virtual kt_size_t Size() const
kt_int32s GetStateId() const
kt_int32u m_RunningBufferMaximumSize
kt_int32s GetDataSize() const
virtual const T & Back() const
LocalizedObject * GetLocalizedObject(const Identifier &rSensorName, kt_int32s stateId)
kt_double GetHeading() const
Grid< kt_double > * GetSearchGrid() const
SensorDataManager(kt_int32u runningBufferMaximumSize, kt_double runningBufferMaximumDistance)
const VertexList & GetVertices() const
void SetUniqueId(kt_int32u uniqueId)
#define forEach(listtype, list)
LocalizedLaserScanList FindOverlappingScans(LocalizedLaserScan *pScan)
void RegisterSensor(const Identifier &rSensorName)
Parameter< kt_double > * m_pLoopSearchSpaceResolution
virtual const T & Front() const
Parameter< kt_double > * m_pLoopSearchSpaceSmearDeviation
NearScanVisitor(LocalizedLaserScan *pScan, kt_double maxDistance, kt_bool useScanBarycenter)
void AddObject(LocalizedObject *pObject, kt_int32s uniqueId)
LocalizedLaserScanList m_RunningScans
void AddEdge(Edge< T > *pEdge)
CorrelationGrid * GetCorrelationGrid() const
virtual const T & GetValue() const
virtual T & Get(kt_size_t index)
const T & Maximum(const T &value1, const T &value2)
const BoundingBox2 & GetBoundingBox() const
SmartPointer< CorrelationGrid > m_pCorrelationGrid
static void ComputeAngularCovariance(ScanMatcherGridSet *pScanMatcherGridSet, const Pose2 &rBestPose, kt_double bestResponse, const Pose2 &rSearchCenter, kt_double searchAngleOffset, kt_double searchAngleResolution, Matrix3 &rCovariance)
kt_bool m_UseScanBarycenter
kt_int32s * GetArrayPointer()
LocalizedLaserScan * GetLastScan()
virtual void Resize(kt_size_t newSize)
LocalizedObjectList GetAllObjects()
void AddEdges(LocalizedObject *pObject)
static void AddScansNew(CorrelationGrid *pCorrelationGrid, const LocalizedLaserScanList &rScans, const Vector2d &rViewPoint)
static EventArguments & Empty()
List< LocalizedLaserScanList > FindNearChains(LocalizedLaserScan *pScan)
Parameter< kt_double > * m_pMinimumTravelHeading
Parameter< kt_double > * m_pLoopMatchMinimumResponseFine
T GetVertexObject() const
const Identifier & GetIdentifier() const
Parameter< kt_double > * m_pMinimumDistancePenalty
void LinkObjects(LocalizedObject *pFromObject, LocalizedObject *pToObject, const Pose2 &rMean, const Matrix3 &rCovariance)
LocalizedLaserScanList & GetScans(const Identifier &rSensorName)
Parameter< kt_double > * m_pLinkScanMaximumDistance
Parameter< kt_double > * m_pAngleVariancePenalty
static void ComputePositionalCovariance(Grid< kt_double > *pSearchSpaceProbs, const Pose2 &rBestPose, kt_double bestResponse, const Pose2 &rSearchCenter, const Vector2d &rSearchSpaceOffset, const Vector2d &rSearchSpaceResolution, kt_double searchAngleResolution, Matrix3 &rCovariance)
Parameter< kt_double > * m_pLoopMatchMaximumVarianceCoarse
kt_bool IsUpTo(const T &value, const T &maximum)
SensorDataManager * GetSensorDataManager(LocalizedObject *pObject)
void AddVertex(LocalizedObject *pObject)
virtual ~SensorDataManager()
virtual void Add(const T &rValue)
kt_int32s GetWidth() const
static kt_double GetResponse(ScanMatcherGridSet *pScanMatcherGridSet, kt_int32u angleIndex, kt_int32s gridPositionIndex)
void SetScanSolver(ScanSolver *pSolver)
static ScanMatcher * Create(OpenMapper *pOpenMapper, kt_double searchSize, kt_double resolution, kt_double smearDeviation, kt_double rangeThreshold)
void SetStateId(kt_int32s stateId)
kt_double Round(kt_double value)
LocalizedLaserScanList & GetRunningScans(const Identifier &rSensorName)
Parameter< kt_double > * m_pMinimumTravelDistance
void SetLastScan(LocalizedLaserScan *pScan)
#define const_forEach(listtype, list)
Pose2 GetSensorAt(const Pose2 &rPose) const
TFSIMD_FORCE_INLINE const tfScalar & y() const
virtual ~BreadthFirstTraversal()
kt_int32u m_RunningBufferMaximumSize
Pose2 GetSensorPose() const
Parameter< kt_double > * m_pLoopMatchMinimumResponseCoarse
Parameter< kt_double > * m_pScanBufferMaximumScanDistance
std::map< Identifier, SensorDataManager * > SensorDataManagerMap
void SetOffset(const Vector2d &rOffset)
BasicEvent< EventArguments > ScansUpdated
virtual kt_bool Process(Object *pObject)
void ComputeOffsets(LocalizedLaserScan *pScan, kt_double angleCenter, kt_double angleOffset, kt_double angleResolution)
const Rectangle2< kt_int32s > & GetROI() const
Parameter< kt_bool > * m_pUseScanBarycenter
List< Identifier > GetSensorNames()
virtual kt_bool Remove(const T &rValue)
#define karto_const_forEachAs(listtype, list, iter)
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
void ClearLastScan(const Identifier &rSensorName)
virtual void ScanMatchingEnd(LocalizedLaserScan *pScan)
LocalizedObjectList & GetObjects()
virtual kt_bool Visit(Vertex< T > *pVertex)=0
BreadthFirstTraversal(Graph< T > *pGraph)
const LocalizedLaserScanList GetAllProcessedScans() const
Parameter< kt_double > * m_pLinkMatchMinimumResponseFine
void SetSensorPose(const Pose2 &rSensorPose)
List< Vertex< T > * > GetAdjacentVertices() const
Parameter< kt_int32u > * m_pScanBufferSize
virtual ConstListIterator< T > GetConstIterator() const
void Log(LogLevel level, const karto::String &rMessage)
MapperSensorManager * m_pMapperSensorManager
LocalizedLaserScanList m_Scans
virtual const IdPoseVector & GetCorrections() const =0
virtual kt_bool Process(karto::Object *pObject)
const Identifier & GetSensorIdentifier() const
void AddRunningScan(LocalizedLaserScan *pScan)
static Vector2dList FindValidPoints(LocalizedLaserScan *pScan, const Vector2d &rViewPoint)
Parameter< kt_double > * m_pMinimumAnglePenalty
void LinkNearChains(LocalizedLaserScan *pScan, Pose2List &rMeans, List< Matrix3 > &rCovariances)
kt_double MatchScan(LocalizedLaserScan *pScan, const LocalizedLaserScanList &rBaseScans, Pose2 &rMean, Matrix3 &rCovariance, kt_bool doPenalize=true, kt_bool doRefineMatch=true)
void EnsureCapacity(kt_size_t newCapacity)
kt_double GetResolution() const
ScanMatcher * GetLoopScanMatcher() const
virtual void ScanMatched(LocalizedLaserScan *pScan)
virtual kt_bool IsEmpty() const
kt_bool TryCloseLoop(LocalizedLaserScan *pScan, const Identifier &rSensorName)
kt_int32s GetUniqueId() const
const LookupArray * GetLookupArray(kt_int32u index) const
void SmearPoint(const Vector2i &rGridPoint)
TFSIMD_FORCE_INLINE Quaternion inverse(const Quaternion &q)
static Grid * CreateGrid(kt_int32s width, kt_int32s height, kt_double resolution)
static kt_int32s ScanIndexComparator(const LocalizedLaserScanPtr &pScan1, const LocalizedLaserScanPtr &pScan2)
Parameter< kt_double > * m_pCoarseSearchAngleOffset
GridIndexLookup< kt_int8u > * m_pGridLookup
kt_int32s GetScanIndex(LocalizedLaserScan *pScan)
static String ToString(const char *value)
ScanSolver * GetScanSolver() const
const kt_double KT_TOLERANCE
BasicEvent< MapperEventArguments > PreLoopClosed
ScanMatcher * GetSequentialScanMatcher() const
ScanMatcher * m_pSequentialScanMatcher
SensorDataManagerMap m_SensorDataManagers
SmartPointer< ScanSolver > m_pScanSolver
Parameter< kt_bool > * m_pUseScanMatching
TFSIMD_FORCE_INLINE const tfScalar & x() const
void AddLocalizedObject(LocalizedObject *pObject)
virtual kt_bool Contains(const T &rValue) const
void AddRunningScan(LocalizedLaserScan *pScan)
LocalizedLaserScanList & GetScans()
LocalizedObjectList m_Objects
Parameter< kt_double > * m_pDistanceVariancePenalty
BasicEvent< MapperEventArguments > PostLoopClosed
kt_double SquaredDistance(const Vector2 &rOther) const
LocalizedLaserScanList GetAllScans()
const String & ToString() const
MapperSensorManagerPrivate * m_pMapperSensorManagerPrivate
void SetLastScan(LocalizedLaserScan *pScan)
LocalizedLaserScan * GetClosestScanToPose(const LocalizedLaserScanList &rScans, const Pose2 &rPose) const
virtual kt_int32s GridIndex(const Vector2i &rGrid, kt_bool boundaryCheck=true) const
void LinkChainToScan(const LocalizedLaserScanList &rChain, LocalizedLaserScan *pScan, const Pose2 &rMean, const Matrix3 &rCovariance)
const Vector2d & GetPosition() const
void AddVertex(Vertex< T > *pVertex)
const LocalizedObjectList GetAllProcessedObjects() const
kt_int32u GetSize() const
Pose2 ComputeWeightedMean(const Pose2List &rMeans, const List< Matrix3 > &rCovariances) const
static void AddScans(CorrelationGrid *pCorrelationGrid, const LocalizedLaserScanList &rScans, const Vector2d &rViewPoint)
kt_int32s BinarySearch(const T &rValue, kt_int32s(*f)(const T &a, const T &b))
OpenMapper(kt_bool multiThreaded=true)
static CorrelationGrid * CreateGrid(kt_int32s width, kt_int32s height, kt_double resolution, kt_double smearDeviation)
LocalizedLaserScanList FindPossibleLoopClosure(LocalizedLaserScan *pScan, const Identifier &rSensorName, kt_int32u &rStartScanIndex)
Parameter< kt_double > * m_pCorrelationSearchSpaceResolution
virtual void SetCorrectedPose(const Pose2 &rPose)
Vector2< kt_double > Vector2d
virtual kt_bool Visit(Vertex< LocalizedObjectPtr > *pVertex)
kt_bool IsGpsReadingValid() const
CoordinateConverter * GetCoordinateConverter() const
virtual ~MapperSensorManager()
kt_double NormalizeAngleDifference(kt_double minuend, kt_double subtrahend)
kt_double DegreesToRadians(kt_double degrees)
MapperSensorManager(kt_int32u runningBufferMaximumSize, kt_double runningBufferMaximumDistance)
Parameter< kt_double > * m_pCoarseAngleResolution
kt_double NormalizeAngle(kt_double angle)
kt_bool InRange(const T &value, const T &a, const T &b)
Parameter< kt_double > * m_pLoopSearchSpaceDimension
LocalizedObjectList m_Objects
Parameter< kt_double > * m_pCorrelationSearchSpaceSmearDeviation
void InitializeParameters()
kt_bool DoubleEqual(kt_double a, kt_double b)
virtual MapperGraph * GetGraph() const
kt_double SquaredLength() const
LocalizedLaserScanPtr m_pLastScan
kt_int32s GetScanIndex(LocalizedLaserScan *pScan)
ScanMatcher * m_pLoopScanMatcher
ParameterSet * GetParameterSet()
void SetLabel(EdgeLabel *pLabel)
Vector2i WorldToGrid(const Vector2d &rWorld, kt_bool flipY=false) const
SmartPointer< Grid< kt_double > > m_pSearchSpaceProbs
#define ANGLE_PENALTY_GAIN
kt_bool IsMultiThreaded()
void SetHeading(kt_double heading)
static void AddScanNew(CorrelationGrid *pCorrelationGrid, const Vector2dList &rValidPoints, kt_bool doSmear=true)
kt_double CorrelateScan(ScanMatcherGridSet *pScanMatcherGridSet, LocalizedLaserScan *pScan, const Pose2 &rSearchCenter, const Vector2d &rSearchSpaceOffset, const Vector2d &rSearchSpaceResolution, kt_double searchAngleOffset, kt_double searchAngleResolution, kt_bool doPenalize, Pose2 &rMean, Matrix3 &rCovariance, kt_bool doingFineMatch)
const Pose2 & GetOdometricPose() const
Parameter< kt_double > * m_pFineSearchAngleOffset
Vertex< LocalizedObjectPtr > * GetVertex(LocalizedObject *pObject)
static void AddScan(CorrelationGrid *pCorrelationGrid, LocalizedLaserScan *pScan, const Vector2d &rViewPoint, kt_bool doSmear=true)
Parameter< kt_bool > * m_pUseResponseExpansion
Parameter< kt_double > * m_pCorrelationSearchSpaceDimension
Vertex< T > * GetTarget() const
Parameter< kt_int32u > * m_pLoopMatchMinimumChainSize
kt_double m_RunningBufferMaximumDistance
OpenMapper * m_pOpenMapper
kt_bool HasMovedEnough(LocalizedLaserScan *pScan, LocalizedLaserScan *pLastScan) const
kt_bool Intersects(const BoundingBox2 &rOther) const
Edge< LocalizedObjectPtr > * AddEdge(LocalizedObject *pSourceObject, LocalizedObject *pTargetObject, kt_bool &rIsNewEdge)
T * GetDataPointer(const Vector2i &rGrid)
MapperGraph(OpenMapper *pOpenMapper, kt_double rangeThreshold)
virtual List< T > Traverse(Vertex< T > *pStartVertex, Visitor< T > *pVisitor)
ScanMatcher * GetLoopScanMatcher() const
kt_double GetRangeThreshold() const
LocalizedLaserScan * GetLastScan(const Identifier &rSensorName)
const Pose2 & GetCorrectedPose() const
Parameter< kt_double > * m_pLoopSearchMaximumDistance
GraphTraversal< LocalizedObjectPtr > * m_pTraversal
LocalizedLaserScanList & GetRunningScans()
Pose2 GetReferencePose(kt_bool useBarycenter) const
const std::string response
#define karto_const_forEach(listtype, list)
LaserRangeFinder * GetLaserRangeFinder() const
#define DISTANCE_PENALTY_GAIN
void Initialize(kt_double rangeThreshold)
kt_double m_RunningBufferMaximumDistance
BasicEvent< MapperEventArguments > Message
kt_double m_MaxDistanceSquared
const Vector2dList & GetPointReadings(kt_bool wantFiltered=false) const
LocalizedLaserScanList FindNearLinkedScans(LocalizedLaserScan *pScan, kt_double maxDistance)