OpenMapper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011, SRI International (R)
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #ifndef __OpenKarto_Mapper_h__
21 #define __OpenKarto_Mapper_h__
22 
23 #ifdef USE_TBB
24 #include <tbb/mutex.h>
25 #include <tbb/parallel_for.h>
26 #include <tbb/blocked_range.h>
27 #include <tbb/blocked_range3d.h>
28 #endif
29 
30 #include <OpenKarto/Event.h>
31 #include <OpenKarto/Pair.h>
32 #include <OpenKarto/Geometry.h>
33 #include <OpenKarto/StringHelper.h>
34 #include <OpenKarto/SensorData.h>
35 #include <OpenKarto/Grid.h>
37 #include <OpenKarto/Module.h>
39 #include <OpenKarto/TypeCasts.h>
40 
41 namespace karto
42 {
43 
45 
46 
51  {
52  public:
57  MapperEventArguments(const String& rMessage)
58  : m_Message(rMessage)
59  {
60  }
61 
66  {
67  }
68 
69  public:
74  const String& GetEventMessage() const
75  {
76  return m_Message;
77  }
78 
79  private:
81  };
82 
83 #ifdef WIN32
84  EXPORT_KARTO_EVENT(KARTO_EXPORT, MapperEventArguments)
85 #endif
86 
90 
94  class EdgeLabel
95  {
96  public:
101  {
102  }
103 
107  virtual ~EdgeLabel()
108  {
109  }
110  }; // EdgeLabel
111 
115 
116  // Contains the requisite information for the "spring"
117  // that links two scans together--the pose difference and the uncertainty
118  // (represented by a covariance matrix).
119  class LinkInfo : public EdgeLabel
120  {
121  public:
128  LinkInfo(const Pose2& rPose1, const Pose2& rPose2, const Matrix3& rCovariance)
129  {
130  Update(rPose1, rPose2, rCovariance);
131  }
132 
136  virtual ~LinkInfo()
137  {
138  }
139 
140  public:
147  void Update(const Pose2& rPose1, const Pose2& rPose2, const Matrix3& rCovariance)
148  {
149  m_Pose1 = rPose1;
150  m_Pose2 = rPose2;
151 
152  // transform second pose into the coordinate system of the first pose
153  Transform transform(rPose1, Pose2());
154  m_PoseDifference = transform.TransformPose(rPose2);
155 
156  // transform covariance into reference of first pose
157  Matrix3 rotationMatrix;
158  rotationMatrix.FromAxisAngle(0, 0, 1, -rPose1.GetHeading());
159 
160  m_Covariance = rotationMatrix * rCovariance * rotationMatrix.Transpose();
161  }
162 
167  inline const Pose2& GetPose1()
168  {
169  return m_Pose1;
170  }
171 
176  inline const Pose2& GetPose2()
177  {
178  return m_Pose2;
179  }
180 
185  inline const Pose2& GetPoseDifference()
186  {
187  return m_PoseDifference;
188  }
189 
194  inline const Matrix3& GetCovariance()
195  {
196  return m_Covariance;
197  }
198 
199  private:
204  }; // LinkInfo
205 
209 
210  template<typename T>
211  class Edge;
212 
216  template<typename T>
217  class Vertex
218  {
219  friend class Edge<T>;
220 
221  public:
226  Vertex(T pObject)
227  : m_pObject(pObject)
228  {
229  }
230 
234  virtual ~Vertex()
235  {
236  }
237 
242  inline const List<Edge<T>*>& GetEdges() const
243  {
244  return m_Edges;
245  }
246 
251  inline T GetVertexObject() const
252  {
253  return m_pObject;
254  }
255 
261  {
262  List<Vertex<T>*> vertices;
263 
264  karto_const_forEach(typename List<Edge<T>*>, &m_Edges)
265  {
266  Edge<T>* pEdge = *iter;
267 
268  // check both source and target because we have a undirected graph
269  if (pEdge->GetSource() != this)
270  {
271  vertices.Add(pEdge->GetSource());
272  }
273 
274  if (pEdge->GetTarget() != this)
275  {
276  vertices.Add(pEdge->GetTarget());
277  }
278  }
279 
280  return vertices;
281  }
282 
283  private:
288  inline void AddEdge(Edge<T>* pEdge)
289  {
290  m_Edges.Add(pEdge);
291  }
292 
295  }; // Vertex<T>
296 
300 
304  template<typename T>
305  class Edge
306  {
307  public:
313  Edge(Vertex<T>* pSource, Vertex<T>* pTarget)
314  : m_pSource(pSource)
315  , m_pTarget(pTarget)
316  , m_pLabel(NULL)
317  {
318  m_pSource->AddEdge(this);
319  m_pTarget->AddEdge(this);
320  }
321 
325  virtual ~Edge()
326  {
327  m_pSource = NULL;
328  m_pTarget = NULL;
329 
330  if (m_pLabel != NULL)
331  {
332  delete m_pLabel;
333  m_pLabel = NULL;
334  }
335  }
336 
337  public:
342  inline Vertex<T>* GetSource() const
343  {
344  return m_pSource;
345  }
346 
351  inline Vertex<T>* GetTarget() const
352  {
353  return m_pTarget;
354  }
355 
360  inline EdgeLabel* GetLabel()
361  {
362  return m_pLabel;
363  }
364 
369  inline void SetLabel(EdgeLabel* pLabel)
370  {
371  m_pLabel = pLabel;
372  }
373 
374  private:
378  }; // class Edge<T>
379 
383 
387  template<typename T>
388  class Visitor
389  {
390  public:
396  virtual kt_bool Visit(Vertex<T>* pVertex) = 0;
397  }; // Visitor<T>
398 
402 
403  template<typename T>
404  class Graph;
405 
409  template<typename T>
411  {
412  public:
418  : m_pGraph(pGraph)
419  {
420  }
421 
425  virtual ~GraphTraversal()
426  {
427  }
428 
429  public:
436  virtual List<T> Traverse(Vertex<T>* pStartVertex, Visitor<T>* pVisitor) = 0;
437 
438  protected:
443  }; // GraphTraversal<T>
444 
448 
452  template<typename T>
453  class Graph
454  {
455  public:
460 
465 
466  public:
471  {
472  }
473 
477  virtual ~Graph()
478  {
479  Clear();
480  }
481 
482  public:
487  inline void AddVertex(Vertex<T>* pVertex)
488  {
489  m_Vertices.Add(pVertex);
490  }
491 
496  inline void AddEdge(Edge<T>* pEdge)
497  {
498  m_Edges.Add(pEdge);
499  }
500 
504  void Clear()
505  {
506  karto_const_forEach(typename VertexList, &m_Vertices)
507  {
508  // delete each vertex
509  delete *iter;
510  }
511 
512  m_Vertices.Clear();
513 
514  karto_const_forEach(typename EdgeList, &m_Edges)
515  {
516  // delete each edge
517  delete *iter;
518  }
519 
520  m_Edges.Clear();
521  }
522 
527  inline const EdgeList& GetEdges() const
528  {
529  return m_Edges;
530  }
531 
536  inline const VertexList& GetVertices() const
537  {
538  return m_Vertices;
539  }
540 
541  protected:
545  VertexList m_Vertices;
546 
550  EdgeList m_Edges;
551  }; // Graph<T>
552 
556 
557  class OpenMapper;
558  class ScanMatcher;
559 
563  class KARTO_EXPORT MapperGraph : public Graph<LocalizedObjectPtr>
564  {
565  public:
571  MapperGraph(OpenMapper* pOpenMapper, kt_double rangeThreshold);
572 
576  virtual ~MapperGraph();
577 
578  public:
583  void AddVertex(LocalizedObject* pObject);
584 
593  Edge<LocalizedObjectPtr>* AddEdge(LocalizedObject* pSourceObject, LocalizedObject* pTargetObject, kt_bool& rIsNewEdge);
594 
599  void AddEdges(LocalizedObject* pObject);
600 
606  void AddEdges(LocalizedLaserScan* pScan, const Matrix3& rCovariance);
607 
614  kt_bool TryCloseLoop(LocalizedLaserScan* pScan, const Identifier& rSensorName);
615 
622  LocalizedLaserScanList FindNearLinkedScans(LocalizedLaserScan* pScan, kt_double maxDistance);
623 
629  LocalizedLaserScanList FindOverlappingScans(LocalizedLaserScan* pScan);
630 
636  {
637  return m_pLoopScanMatcher;
638  }
639 
647  void LinkChainToScan(const LocalizedLaserScanList& rChain, LocalizedLaserScan* pScan, const Pose2& rMean, const Matrix3& rCovariance);
648 
649  private:
656  {
657  return m_Vertices[pObject->GetUniqueId()];
658  }
659 
665  LocalizedLaserScan* GetClosestScanToPose(const LocalizedLaserScanList& rScans, const Pose2& rPose) const;
666 
674  void LinkObjects(LocalizedObject* pFromObject, LocalizedObject* pToObject, const Pose2& rMean, const Matrix3& rCovariance);
675 
682  void LinkNearChains(LocalizedLaserScan* pScan, Pose2List& rMeans, List<Matrix3>& rCovariances);
683 
689  List<LocalizedLaserScanList> FindNearChains(LocalizedLaserScan* pScan);
690 
697  Pose2 ComputeWeightedMean(const Pose2List& rMeans, const List<Matrix3>& rCovariances) const;
698 
707  LocalizedLaserScanList FindPossibleLoopClosure(LocalizedLaserScan* pScan, const Identifier& rSensorName, kt_int32u& rStartScanIndex);
708 
712  void CorrectPoses();
713 
714  private:
719 
724 
729  }; // MapperGraph
730 
734 
738  class ScanSolver : public Referenced
739  {
740  public:
745 
750  {
751  }
752 
753  protected:
754  //@cond EXCLUDE
758  virtual ~ScanSolver()
759  {
760  }
761  //@endcond
762 
763  public:
767  virtual void Compute() = 0;
768 
773  virtual const IdPoseVector& GetCorrections() const = 0;
774 
778  virtual void AddNode(Vertex<LocalizedObjectPtr>* /*pVertex*/)
779  {
780  }
781 
785  virtual void RemoveNode(kt_int32s /*id*/)
786  {
787  }
788 
792  virtual void AddConstraint(Edge<LocalizedObjectPtr>* /*pEdge*/)
793  {
794  }
795 
799  virtual void RemoveConstraint(kt_int32s /*sourceId*/, kt_int32s /*targetId*/)
800  {
801  }
802 
806  virtual void Clear() {};
807  }; // ScanSolver
808 
812 
816  class CorrelationGrid : public Grid<kt_int8u>
817  {
818  protected:
819  //@cond EXCLUDE
823  virtual ~CorrelationGrid()
824  {
825  delete [] m_pKernel;
826  }
827  //@endcond
828 
829  public:
838  static CorrelationGrid* CreateGrid(kt_int32s width, kt_int32s height, kt_double resolution, kt_double smearDeviation)
839  {
840  assert(resolution != 0.0);
841 
842  // +1 in case of roundoff
843  kt_int32u borderSize = GetHalfKernelSize(smearDeviation, resolution) + 1;
844 
845  CorrelationGrid* pGrid = new CorrelationGrid(width, height, borderSize, resolution, smearDeviation);
846 
847  return pGrid;
848  }
849 
856  virtual kt_int32s GridIndex(const Vector2i& rGrid, kt_bool boundaryCheck = true) const
857  {
858  kt_int32s x = rGrid.GetX() + m_Roi.GetX();
859  kt_int32s y = rGrid.GetY() + m_Roi.GetY();
860 
861  return Grid<kt_int8u>::GridIndex(Vector2i(x, y), boundaryCheck);
862  }
863 
868  inline const Rectangle2<kt_int32s>& GetROI() const
869  {
870  return m_Roi;
871  }
872 
877  inline void SetROI(const Rectangle2<kt_int32s>& roi)
878  {
879  m_Roi = roi;
880  }
881 
886  inline void SmearPoint(const Vector2i& rGridPoint)
887  {
888  assert(m_pKernel != NULL);
889 
890  int gridIndex = GridIndex(rGridPoint);
891  if (GetDataPointer()[gridIndex] != GridStates_Occupied)
892  {
893  return;
894  }
895 
896  kt_int32s halfKernel = m_KernelSize / 2;
897 
898  // apply kernel
899  for (kt_int32s j = -halfKernel; j <= halfKernel; j++)
900  {
901  kt_int8u* pGridAdr = GetDataPointer(Vector2i(rGridPoint.GetX(), rGridPoint.GetY() + j));
902 
903  kt_int32s kernelConstant = (halfKernel) + m_KernelSize * (j + halfKernel);
904 
905  // if a point is on the edge of the grid, there is no problem
906  // with running over the edge of allowable memory, because
907  // the grid has margins to compensate for the kernel size
908  SmearInternal(halfKernel, kernelConstant, pGridAdr);
909  }
910  }
911 
912  protected:
921  CorrelationGrid(kt_int32u width, kt_int32u height, kt_int32u borderSize, kt_double resolution, kt_double smearDeviation)
922  : Grid<kt_int8u>(width + borderSize * 2, height + borderSize * 2)
923  , m_SmearDeviation(smearDeviation)
924  , m_pKernel(NULL)
925  {
926  GetCoordinateConverter()->SetScale(1.0 / resolution);
927 
928  // setup region of interest
929  m_Roi = Rectangle2<kt_int32s>(borderSize, borderSize, width, height);
930 
931  // calculate kernel
932  CalculateKernel();
933  }
934 
938  virtual void CalculateKernel()
939  {
940  kt_double resolution = GetResolution();
941 
942  assert(resolution != 0.0);
943  assert(m_SmearDeviation != 0.0);
944 
945  // min and max distance deviation for smearing;
946  // will smear for two standard deviations, so deviation must be at least 1/2 of the resolution
947  const kt_double MIN_SMEAR_DISTANCE_DEVIATION = 0.5 * resolution;
948  const kt_double MAX_SMEAR_DISTANCE_DEVIATION = 10 * resolution;
949 
950  // check if given value too small or too big
951  if (!math::InRange(m_SmearDeviation, MIN_SMEAR_DISTANCE_DEVIATION, MAX_SMEAR_DISTANCE_DEVIATION))
952  {
953  StringBuilder error;
954  error << "Mapper Error: Smear deviation too small: Must be between " << MIN_SMEAR_DISTANCE_DEVIATION << " and " << MAX_SMEAR_DISTANCE_DEVIATION;
955  throw Exception(error.ToString());
956  }
957 
958  // NOTE: Currently assumes a two-dimensional kernel
959 
960  // +1 for center
961  m_KernelSize = 2 * GetHalfKernelSize(m_SmearDeviation, resolution) + 1;
962 
963  // allocate kernel
964  m_pKernel = new kt_int8u[m_KernelSize * m_KernelSize];
965  if (m_pKernel == NULL)
966  {
967  throw Exception("Unable to allocate memory for kernel!");
968  }
969 
970  // calculate kernel
971  kt_int32s halfKernel = m_KernelSize / 2;
972  for (kt_int32s i = -halfKernel; i <= halfKernel; i++)
973  {
974  for (kt_int32s j = -halfKernel; j <= halfKernel; j++)
975  {
976 #ifdef WIN32
977  kt_double distanceFromMean = _hypot(i * resolution, j * resolution);
978 #else
979  kt_double distanceFromMean = hypot(i * resolution, j * resolution);
980 #endif
981  kt_double z = exp(-0.5 * pow(distanceFromMean / m_SmearDeviation, 2));
982 
983  kt_int32u kernelValue = static_cast<kt_int32u>(math::Round(z * GridStates_Occupied));
984  assert(math::IsUpTo(kernelValue, static_cast<kt_int32u>(255)));
985 
986  int kernelArrayIndex = (i + halfKernel) + m_KernelSize * (j + halfKernel);
987  m_pKernel[kernelArrayIndex] = static_cast<kt_int8u>(kernelValue);
988  }
989  }
990  }
991 
999  static kt_int32s GetHalfKernelSize(kt_double smearDeviation, kt_double resolution)
1000  {
1001  assert(resolution != 0.0);
1002 
1003  return static_cast<kt_int32s>(math::Round(2.0 * smearDeviation / resolution));
1004  }
1005 
1006  private:
1007  // \todo 1/5/2011: was this separated from SmearPoint in preparation for optimization?
1008  inline void SmearInternal(kt_int32s halfKernel, kt_int32s kernelConstant, kt_int8u* pGridAdr)
1009  {
1010  kt_int8u kernelValue;
1011  kt_int32s kernelArrayIndex;
1012  kt_int32s i;
1013 
1014  for (i = -halfKernel; i <= halfKernel; i++)
1015  {
1016  kernelArrayIndex = i + kernelConstant;
1017 
1018  kernelValue = m_pKernel[kernelArrayIndex];
1019  if (kernelValue > pGridAdr[i])
1020  {
1021  // kernel value is greater, so set it to kernel value
1022  pGridAdr[i] = kernelValue;
1023  }
1024  }
1025  }
1026 
1032 
1033  // Size of one side of the kernel
1035 
1036  // Cached kernel for smearing
1038 
1039  // Region of interest
1041  }; // CorrelationGrid
1042 
1046 
1048  {
1049  public:
1051  Grid<kt_double>* pSearchSpaceProbs,
1052  GridIndexLookup<kt_int8u>* pGridLookup)
1053  : m_pCorrelationGrid(pCorrelationGrid)
1054  , m_pSearchSpaceProbs(pSearchSpaceProbs)
1055  , m_pGridLookup(pGridLookup)
1056  {
1057  }
1058 
1060  {
1061  delete m_pGridLookup;
1062  }
1063 
1067  };
1068 
1072 
1073  class ScanMatcherGridSetBank;
1074 
1079  {
1080  public:
1084  virtual ~ScanMatcher();
1085 
1086  public:
1096  static ScanMatcher* Create(OpenMapper* pOpenMapper, kt_double searchSize, kt_double resolution, kt_double smearDeviation, kt_double rangeThreshold);
1097 
1108  kt_double MatchScan(LocalizedLaserScan* pScan, const LocalizedLaserScanList& rBaseScans, Pose2& rMean, Matrix3& rCovariance,
1109  kt_bool doPenalize = true, kt_bool doRefineMatch = true);
1110 
1128  kt_double CorrelateScan(ScanMatcherGridSet* pScanMatcherGridSet, LocalizedLaserScan* pScan, const Pose2& rSearchCenter, const Vector2d& rSearchSpaceOffset, const Vector2d& rSearchSpaceResolution,
1129  kt_double searchAngleOffset, kt_double searchAngleResolution, kt_bool doPenalize, Pose2& rMean, Matrix3& rCovariance, kt_bool doingFineMatch);
1130 
1142  static void ComputePositionalCovariance(Grid<kt_double>* pSearchSpaceProbs, const Pose2& rBestPose, kt_double bestResponse, const Pose2& rSearchCenter,
1143  const Vector2d& rSearchSpaceOffset, const Vector2d& rSearchSpaceResolution,
1144  kt_double searchAngleResolution, Matrix3& rCovariance);
1145 
1156  static void ComputeAngularCovariance(ScanMatcherGridSet* pScanMatcherGridSet, const Pose2& rBestPose, kt_double bestResponse, const Pose2& rSearchCenter,
1157  kt_double searchAngleOffset, kt_double searchAngleResolution, Matrix3& rCovariance);
1158 
1165  CorrelationGrid* GetCorrelationGrid() const;
1166 
1173  Grid<kt_double>* GetSearchGrid() const;
1174 
1182  static kt_double GetResponse(ScanMatcherGridSet* pScanMatcherGridSet, kt_int32u angleIndex, kt_int32s gridPositionIndex);
1183 
1184  private:
1191  static void AddScans(CorrelationGrid* pCorrelationGrid, const LocalizedLaserScanList& rScans, const Vector2d& rViewPoint);
1192  static void AddScansNew(CorrelationGrid* pCorrelationGrid, const LocalizedLaserScanList& rScans, const Vector2d& rViewPoint);
1193 
1201  static void AddScan(CorrelationGrid* pCorrelationGrid, LocalizedLaserScan* pScan, const Vector2d& rViewPoint, kt_bool doSmear = true);
1202  static void AddScanNew(CorrelationGrid* pCorrelationGrid, const Vector2dList& rValidPoints, kt_bool doSmear = true);
1203 
1210  static Vector2dList FindValidPoints(LocalizedLaserScan* pScan, const Vector2d& rViewPoint);
1211 
1212  protected:
1216  ScanMatcher(OpenMapper* pOpenMapper)
1217  : m_pOpenMapper(pOpenMapper)
1218  , m_pScanMatcherGridSet(NULL)
1219  , m_pScanMatcherGridSetBank(NULL)
1220  {
1221  }
1222 
1223  private:
1225 
1228  }; // ScanMatcher
1229 
1233 
1234  class SensorDataManager;
1236 
1241  {
1242  public:
1248  MapperSensorManager(kt_int32u runningBufferMaximumSize, kt_double runningBufferMaximumDistance);
1249 
1253  virtual ~MapperSensorManager();
1254 
1255  public:
1261  void RegisterSensor(const Identifier& rSensorName);
1262 
1269  LocalizedObject* GetLocalizedObject(const Identifier& rSensorName, kt_int32s stateId);
1270 
1275  List<Identifier> GetSensorNames();
1276 
1282  LocalizedLaserScan* GetLastScan(const Identifier& rSensorName);
1283 
1288  void SetLastScan(LocalizedLaserScan* pScan);
1289 
1294  void ClearLastScan(const Identifier& rSensorName);
1295 
1301  LocalizedObject* GetLocalizedObject(kt_int32s uniqueId);
1302 
1307  void AddLocalizedObject(LocalizedObject* pObject);
1308 
1313  void AddRunningScan(LocalizedLaserScan* pScan);
1314 
1320  LocalizedLaserScanList& GetScans(const Identifier& rSensorName);
1321 
1328  kt_int32s GetScanIndex(LocalizedLaserScan* pScan);
1329 
1335  LocalizedLaserScanList& GetRunningScans(const Identifier& rSensorName);
1336 
1341  LocalizedLaserScanList GetAllScans();
1342 
1347  LocalizedObjectList GetAllObjects();
1348 
1352  void Clear();
1353 
1354  private:
1360  {
1361  return GetSensorDataManager(pObject->GetSensorIdentifier());
1362  }
1363 
1369  SensorDataManager* GetSensorDataManager(const Identifier& rSensorName);
1370 
1371  private:
1373  }; // MapperSensorManager
1374 
1378 
1532  {
1533  friend class MapperGraph;
1534  friend class ScanMatcher;
1535 
1536  public:
1541  OpenMapper(kt_bool multiThreaded = true);
1542 
1548  OpenMapper(const char* pName, kt_bool multiThreaded = true);
1549 
1550  public:
1557 
1564 
1569 
1575 
1576  protected:
1577  //@cond EXCLUDE
1581  virtual ~OpenMapper();
1582  //@endcond
1583 
1584  public:
1590  {
1591  return m_MultiThreaded;
1592  }
1593 
1599  void Initialize(kt_double rangeThreshold);
1600 
1605  void Reset();
1606 
1614  virtual kt_bool Process(Object* pObject);
1615 
1622  const LocalizedLaserScanList GetAllProcessedScans() const;
1623 
1630  const LocalizedObjectList GetAllProcessedObjects() const;
1631 
1636  ScanSolver* GetScanSolver() const;
1637 
1642  void SetScanSolver(ScanSolver* pSolver);
1643 
1648  virtual MapperGraph* GetGraph() const;
1649 
1654  ScanMatcher* GetSequentialScanMatcher() const;
1655 
1660  ScanMatcher* GetLoopScanMatcher() const;
1661 
1667  {
1668  return m_pMapperSensorManager;
1669  }
1670 
1677  inline kt_bool TryCloseLoop(LocalizedLaserScan* pScan, const Identifier& rSensorName)
1678  {
1679  return m_pGraph->TryCloseLoop(pScan, rSensorName);
1680  }
1681 
1682  protected:
1687  virtual void ScanMatched(LocalizedLaserScan* pScan) {};
1688 
1693  virtual void ScanMatchingEnd(LocalizedLaserScan* pScan) {};
1694 
1695  private:
1696  void InitializeParameters();
1697 
1705  kt_bool HasMovedEnough(LocalizedLaserScan* pScan, LocalizedLaserScan* pLastScan) const;
1706 
1707  public:
1709  // fire information for listeners!!
1710 
1715  {
1716  return m_Initialized;
1717  }
1718 
1719  private:
1720  // restrict the following functions
1721  OpenMapper(const OpenMapper&);
1722  const OpenMapper& operator=(const OpenMapper&);
1723 
1724  protected:
1729 
1730  private:
1733 
1735 
1737 
1739 
1741  // Parameters
1742  // NOTE: Maintain the descriptions to these parameters in the comment above the class!
1744 
1749 
1751  // scan matcher parameters
1752 
1756 
1761 
1764 
1766  // correlation parameters
1767 
1774 
1776  // loop correlation parameters
1777 
1781 
1783  // loop detection parameters
1784 
1790  };
1791 
1793 }
1794 
1795 #endif // __OpenKarto_Mapper_h__
CorrelationGrid(kt_int32u width, kt_int32u height, kt_int32u borderSize, kt_double resolution, kt_double smearDeviation)
Definition: OpenMapper.h:921
EdgeLabel * m_pLabel
Definition: OpenMapper.h:377
Vertex(T pObject)
Definition: OpenMapper.h:226
MapperSensorManager * GetMapperSensorManager() const
Definition: OpenMapper.h:1666
MapperGraph * m_pGraph
Definition: OpenMapper.h:1738
bool kt_bool
Definition: Types.h:145
GraphTraversal(Graph< T > *pGraph)
Definition: OpenMapper.h:417
Matrix3 m_Covariance
Definition: OpenMapper.h:203
Vertex< T > * m_pTarget
Definition: OpenMapper.h:376
EdgeLabel * GetLabel()
Definition: OpenMapper.h:360
List< Edge< T > * > EdgeList
Definition: OpenMapper.h:464
kt_double GetHeading() const
Definition: Geometry.h:2274
const VertexList & GetVertices() const
Definition: OpenMapper.h:536
Parameter< kt_double > * m_pLoopSearchSpaceResolution
Definition: OpenMapper.h:1779
List< Pair< kt_int32s, Pose2 > > IdPoseVector
Definition: OpenMapper.h:744
VertexList m_Vertices
Definition: OpenMapper.h:545
Parameter< kt_double > * m_pLoopSearchSpaceSmearDeviation
Definition: OpenMapper.h:1780
void AddEdge(Edge< T > *pEdge)
Definition: OpenMapper.h:496
virtual void Clear()
Definition: OpenMapper.h:806
SmartPointer< CorrelationGrid > m_pCorrelationGrid
Definition: OpenMapper.h:1064
virtual void AddNode(Vertex< LocalizedObjectPtr > *)
Definition: OpenMapper.h:778
virtual void RemoveNode(kt_int32s)
Definition: OpenMapper.h:785
Rectangle2< kt_int32s > m_Roi
Definition: OpenMapper.h:1040
const T & GetY() const
Definition: Geometry.h:369
#define KARTO_EXPORT
Definition: Macros.h:78
virtual void RemoveConstraint(kt_int32s, kt_int32s)
Definition: OpenMapper.h:799
Parameter< kt_double > * m_pMinimumTravelHeading
Definition: OpenMapper.h:1748
virtual ~GraphTraversal()
Definition: OpenMapper.h:425
Parameter< kt_double > * m_pLoopMatchMinimumResponseFine
Definition: OpenMapper.h:1789
T GetVertexObject() const
Definition: OpenMapper.h:251
Parameter< kt_double > * m_pMinimumDistancePenalty
Definition: OpenMapper.h:1758
Parameter< kt_double > * m_pLinkScanMaximumDistance
Definition: OpenMapper.h:1763
Parameter< kt_double > * m_pAngleVariancePenalty
Definition: OpenMapper.h:1759
void Update(const Pose2 &rPose1, const Pose2 &rPose2, const Matrix3 &rCovariance)
Definition: OpenMapper.h:147
Parameter< kt_double > * m_pLoopMatchMaximumVarianceCoarse
Definition: OpenMapper.h:1787
kt_bool IsUpTo(const T &value, const T &maximum)
Definition: Math.h:175
const Matrix3 & GetCovariance()
Definition: OpenMapper.h:194
void Clear()
Definition: OpenMapper.h:504
SensorDataManager * GetSensorDataManager(LocalizedObject *pObject)
Definition: OpenMapper.h:1359
virtual void Add(const T &rValue)
Definition: List.h:111
Pose2 TransformPose(const Pose2 &rSourcePose) const
Definition: PoseTransform.h:61
virtual ~Edge()
Definition: OpenMapper.h:325
Matrix3 Transpose() const
Definition: Geometry.h:2640
kt_double Round(kt_double value)
Definition: Math.h:114
Parameter< kt_double > * m_pMinimumTravelDistance
Definition: OpenMapper.h:1747
TFSIMD_FORCE_INLINE const tfScalar & y() const
kt_double m_SmearDeviation
Definition: OpenMapper.h:1031
Parameter< kt_double > * m_pLoopMatchMinimumResponseCoarse
Definition: OpenMapper.h:1788
SmartPointer< ScanMatcherGridSet > m_pScanMatcherGridSet
Definition: OpenMapper.h:1226
Parameter< kt_double > * m_pScanBufferMaximumScanDistance
Definition: OpenMapper.h:1754
Graph< T > * m_pGraph
Definition: OpenMapper.h:442
virtual kt_int32s GridIndex(const Vector2i &rGrid, kt_bool boundaryCheck=true) const
Definition: Grid.h:169
void SetROI(const Rectangle2< kt_int32s > &roi)
Definition: OpenMapper.h:877
List< Edge< T > * > m_Edges
Definition: OpenMapper.h:294
BasicEvent< EventArguments > ScansUpdated
Definition: OpenMapper.h:1574
ScanMatcherGridSet(CorrelationGrid *pCorrelationGrid, Grid< kt_double > *pSearchSpaceProbs, GridIndexLookup< kt_int8u > *pGridLookup)
Definition: OpenMapper.h:1050
const Rectangle2< kt_int32s > & GetROI() const
Definition: OpenMapper.h:868
Parameter< kt_bool > * m_pUseScanBarycenter
Definition: OpenMapper.h:1746
virtual void ScanMatchingEnd(LocalizedLaserScan *pScan)
Definition: OpenMapper.h:1693
const String & GetEventMessage() const
Definition: OpenMapper.h:74
uint8_t kt_int8u
Definition: Types.h:91
const T & GetX() const
Definition: Geometry.h:351
Parameter< kt_double > * m_pLinkMatchMinimumResponseFine
Definition: OpenMapper.h:1762
const Pose2 & GetPose2()
Definition: OpenMapper.h:176
List< Vertex< T > * > GetAdjacentVertices() const
Definition: OpenMapper.h:260
virtual void AddConstraint(Edge< LocalizedObjectPtr > *)
Definition: OpenMapper.h:792
Parameter< kt_int32u > * m_pScanBufferSize
Definition: OpenMapper.h:1753
const EdgeList & GetEdges() const
Definition: OpenMapper.h:527
MapperSensorManager * m_pMapperSensorManager
Definition: OpenMapper.h:1736
uint32_t kt_int32u
Definition: Types.h:111
const Identifier & GetSensorIdentifier() const
Definition: SensorData.h:141
Parameter< kt_double > * m_pMinimumAnglePenalty
Definition: OpenMapper.h:1760
ScanMatcher * GetLoopScanMatcher() const
Definition: OpenMapper.h:635
virtual void ScanMatched(LocalizedLaserScan *pScan)
Definition: OpenMapper.h:1687
kt_int32s GetUniqueId() const
Definition: SensorData.h:105
void SmearPoint(const Vector2i &rGridPoint)
Definition: OpenMapper.h:886
Parameter< kt_double > * m_pCoarseSearchAngleOffset
Definition: OpenMapper.h:1771
GridIndexLookup< kt_int8u > * m_pGridLookup
Definition: OpenMapper.h:1066
BasicEvent< MapperEventArguments > PreLoopClosed
Definition: OpenMapper.h:1563
void AddEdge(Edge< T > *pEdge)
Definition: OpenMapper.h:288
OpenMapper * m_pOpenMapper
Definition: OpenMapper.h:1224
ScanMatcher * m_pSequentialScanMatcher
Definition: OpenMapper.h:1734
SmartPointer< ScanSolver > m_pScanSolver
Definition: OpenMapper.h:1728
void SmearInternal(kt_int32s halfKernel, kt_int32s kernelConstant, kt_int8u *pGridAdr)
Definition: OpenMapper.h:1008
Parameter< kt_bool > * m_pUseScanMatching
Definition: OpenMapper.h:1745
virtual ~Vertex()
Definition: OpenMapper.h:234
TFSIMD_FORCE_INLINE const tfScalar & x() const
Parameter< kt_double > * m_pDistanceVariancePenalty
Definition: OpenMapper.h:1757
BasicEvent< MapperEventArguments > PostLoopClosed
Definition: OpenMapper.h:1568
List< Vertex< T > * > VertexList
Definition: OpenMapper.h:459
MapperSensorManagerPrivate * m_pMapperSensorManagerPrivate
Definition: OpenMapper.h:1372
const String & ToString() const
Pose2 m_PoseDifference
Definition: OpenMapper.h:202
virtual kt_int32s GridIndex(const Vector2i &rGrid, kt_bool boundaryCheck=true) const
Definition: OpenMapper.h:856
Vertex< T > * m_pSource
Definition: OpenMapper.h:375
int32_t kt_int32s
Definition: Types.h:106
TFSIMD_FORCE_INLINE const tfScalar & z() const
void AddVertex(Vertex< T > *pVertex)
Definition: OpenMapper.h:487
virtual ~Graph()
Definition: OpenMapper.h:477
static CorrelationGrid * CreateGrid(kt_int32s width, kt_int32s height, kt_double resolution, kt_double smearDeviation)
Definition: OpenMapper.h:838
ScanMatcherGridSetBank * m_pScanMatcherGridSetBank
Definition: OpenMapper.h:1227
Parameter< kt_double > * m_pCorrelationSearchSpaceResolution
Definition: OpenMapper.h:1769
kt_bool m_Initialized
Definition: OpenMapper.h:1731
kt_bool m_MultiThreaded
Definition: OpenMapper.h:1732
kt_bool TryCloseLoop(LocalizedLaserScan *pScan, const Identifier &rSensorName)
Definition: OpenMapper.h:1677
double kt_double
Definition: Types.h:160
Parameter< kt_double > * m_pCoarseAngleResolution
Definition: OpenMapper.h:1773
kt_bool InRange(const T &value, const T &a, const T &b)
Definition: Math.h:203
Parameter< kt_double > * m_pLoopSearchSpaceDimension
Definition: OpenMapper.h:1778
const Pose2 & GetPose1()
Definition: OpenMapper.h:167
Parameter< kt_double > * m_pCorrelationSearchSpaceSmearDeviation
Definition: OpenMapper.h:1770
virtual ~EdgeLabel()
Definition: OpenMapper.h:107
ScanMatcher * m_pLoopScanMatcher
Definition: OpenMapper.h:723
const List< Edge< T > * > & GetEdges() const
Definition: OpenMapper.h:242
void SetLabel(EdgeLabel *pLabel)
Definition: OpenMapper.h:369
SmartPointer< Grid< kt_double > > m_pSearchSpaceProbs
Definition: OpenMapper.h:1065
kt_bool IsMultiThreaded()
Definition: OpenMapper.h:1589
static kt_int32s GetHalfKernelSize(kt_double smearDeviation, kt_double resolution)
Definition: OpenMapper.h:999
Edge(Vertex< T > *pSource, Vertex< T > *pTarget)
Definition: OpenMapper.h:313
virtual ~LinkInfo()
Definition: OpenMapper.h:136
ScanMatcher(OpenMapper *pOpenMapper)
Definition: OpenMapper.h:1216
Definition: Any.cpp:20
Vertex< T > * GetSource() const
Definition: OpenMapper.h:342
Parameter< kt_double > * m_pFineSearchAngleOffset
Definition: OpenMapper.h:1772
Vertex< LocalizedObjectPtr > * GetVertex(LocalizedObject *pObject)
Definition: OpenMapper.h:655
Parameter< kt_bool > * m_pUseResponseExpansion
Definition: OpenMapper.h:1755
Parameter< kt_double > * m_pCorrelationSearchSpaceDimension
Definition: OpenMapper.h:1768
Vertex< T > * GetTarget() const
Definition: OpenMapper.h:351
Parameter< kt_int32u > * m_pLoopMatchMinimumChainSize
Definition: OpenMapper.h:1786
kt_bool IsInitialized()
Definition: OpenMapper.h:1714
EdgeList m_Edges
Definition: OpenMapper.h:550
OpenMapper * m_pOpenMapper
Definition: OpenMapper.h:718
Vector2< kt_int32s > Vector2i
Definition: Geometry.h:600
LinkInfo(const Pose2 &rPose1, const Pose2 &rPose2, const Matrix3 &rCovariance)
Definition: OpenMapper.h:128
MapperEventArguments(const String &rMessage)
Definition: OpenMapper.h:57
Parameter< kt_double > * m_pLoopSearchMaximumDistance
Definition: OpenMapper.h:1785
GraphTraversal< LocalizedObjectPtr > * m_pTraversal
Definition: OpenMapper.h:728
virtual void CalculateKernel()
Definition: OpenMapper.h:938
#define karto_const_forEach(listtype, list)
Definition: Macros.h:136
const Pose2 & GetPoseDifference()
Definition: OpenMapper.h:185
BasicEvent< MapperEventArguments > Message
Definition: OpenMapper.h:1556
void FromAxisAngle(kt_double x, kt_double y, kt_double z, const kt_double radians)
Definition: Geometry.h:2605


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Tue Nov 7 2017 06:02:36