Main MRPT website > C++ reference for MRPT 1.9.9
CHMTSLAM_AA.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "hmtslam-precomp.h" // Precomp header
11 
12 #include <mrpt/utils/CTicTac.h>
13 #include <mrpt/random.h>
14 #include <mrpt/utils/CFileStream.h>
17 #include <mrpt/system/os.h>
18 
19 using namespace mrpt::slam;
20 using namespace mrpt::hmtslam;
21 using namespace mrpt::poses;
22 using namespace mrpt::obs;
23 using namespace mrpt::utils;
24 using namespace std;
25 
26 /*---------------------------------------------------------------
27 
28  areaAbstraction
29 
30  Area Abstraction (AA) process within HMT-SLAM
31 
32  ---------------------------------------------------------------*/
33 CHMTSLAM::TMessageLSLAMfromAA::Ptr CHMTSLAM::areaAbstraction(
34  CLocalMetricHypothesis* LMH, const TPoseIDList& newPoseIDs)
35 {
37 
38  ASSERT_(!newPoseIDs.empty());
39  ASSERT_(LMH);
40  CHMTSLAM* obj = LMH->m_parent.get();
41  ASSERT_(obj);
42 
43  // The output results:
46 
47  // Process msg:
48  THypothesisID LMH_ID = LMH->m_ID;
49  resMsg->hypothesisID = LMH_ID;
50 
51  for (TPoseIDList::const_iterator newID = newPoseIDs.begin();
52  newID != newPoseIDs.end(); ++newID)
53  {
54  // Add a new node to the graph:
55  obj->logFmt(
56  mrpt::utils::LVL_DEBUG, "[thread_AA] Processing new pose ID: %u\n",
57  static_cast<unsigned>(*newID));
58 
59  // Get SF & pose pdf for the new pose.
60  const CSensoryFrame* sf;
61  CPose3DPDFParticles::Ptr posePDF =
62  mrpt::make_aligned_shared<CPose3DPDFParticles>();
63 
64  {
65  // std::lock_guard<std::mutex> lock( LMH->m_lock ); // We are
66  // already within the LMH's lock!
67 
68  // SF:
70  LMH->m_SFs.find(*newID);
71  ASSERT_(itSFs != LMH->m_SFs.end());
72  sf = &itSFs->second;
73 
74  // Pose PDF:
75  LMH->getPoseParticles(*newID, *posePDF);
76  } // end of LMH's critical section lock
77 
78  {
79  std::lock_guard<std::mutex> locker(LMH->m_robotPosesGraph.lock);
80 
81  // Add to the graph partitioner:
83  obj->m_options.AA_options;
84 
85  unsigned int newIdx =
87  CSensoryFrame::Ptr(new CSensoryFrame(*sf)), posePDF);
88  LMH->m_robotPosesGraph.idx2pose[newIdx] = *newID;
89  } // end of critical section lock on "m_robotPosesGraph.lock"
90  } // end for each new ID
91 
92  vector<vector_uint> partitions;
93  {
94  std::lock_guard<std::mutex> locker(LMH->m_robotPosesGraph.lock);
95  // Recompute partitions:
97  .markAllNodesForReconsideration(); // We will have always small
98  // local maps.
100  }
101 
102  // Send result to LSLAM
103  resMsg->partitions.resize(partitions.size());
106  for (itDest = resMsg->partitions.begin(), itSrc = partitions.begin();
107  itSrc != partitions.end(); itSrc++, itDest++)
108  {
109  itDest->resize(itSrc->size());
112  for (it1 = itSrc->begin(), it2 = itDest->begin(); it1 != itSrc->end();
113  it1++, it2++)
114  *it2 = LMH->m_robotPosesGraph.idx2pose[*it1];
115  }
116 
117  resMsg->dumpToConsole();
118 
119  return resMsg;
120 
121  MRPT_END
122 }
123 
124 void CHMTSLAM::TMessageLSLAMfromAA::dumpToConsole() const
125 {
126  cout << format(
127  "Hypo ID: %i has %i partitions:\n", (int)hypothesisID,
128  (int)partitions.size());
129 
130  for (std::vector<TPoseIDList>::const_iterator it = partitions.begin();
131  it != partitions.end(); ++it)
132  {
133  printf_vector("%i", *it);
134  cout << endl;
135  }
136 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
THypothesisID m_ID
The unique ID of the hypothesis (Used for accessing mrpt::slam::CHierarchicalMHMap).
void markAllNodesForReconsideration()
Mark all nodes for reconsideration in the next call to "updatePartitions", instead of considering jus...
Classes related to the implementation of Hybrid Metric Topological (HMT) SLAM.
void updatePartitions(std::vector< vector_uint > &partitions)
This method executed only the neccesary part of the partition to take into account the lastest added ...
Scalar * iterator
Definition: eigen_plugins.h:26
std::shared_ptr< CPose3DPDFParticles > Ptr
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:27
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
An implementation of Hybrid Metric Topological SLAM (HMT-SLAM).
Definition: CHMTSLAM.h:65
int64_t THypothesisID
An integer number uniquely identifying each of the concurrent hypotheses for the robot topological pa...
std::map< uint32_t, TPoseID > idx2pose
For the poses in "partitioner".
#define MRPT_END
mrpt::utils::safe_ptr< CHMTSLAM > m_parent
For quick access to our parent object.
This namespace contains representation of robot actions and observations.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:19
mrpt::slam::CIncrementalMapPartitioner::TOptions options
std::shared_ptr< CSensoryFrame > Ptr
Definition: CSensoryFrame.h:56
This class is used in HMT-SLAM to represent each of the Local Metric Hypotheses (LMHs).
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
struct mrpt::hmtslam::CLocalMetricHypothesis::TRobotPosesPartitioning m_robotPosesGraph
std::vector< TPoseID > TPoseIDList
std::map< TPoseID, mrpt::obs::CSensoryFrame > m_SFs
The SF gathered at each robot pose.
#define MRPT_START
void printf_vector(const char *fmt, const std::vector< T > &V)
Prints a vector in the format [A,B,C,...] to std::cout, and the fmt string for each vector element...
Definition: printf_vector.h:56
#define ASSERT_(f)
unsigned int addMapFrame(const mrpt::obs::CSensoryFrame::Ptr &frame, const mrpt::poses::CPosePDF::Ptr &robotPose2D)
std::shared_ptr< TMessageLSLAMfromAA > Ptr
Definition: CHMTSLAM.h:97
void getPoseParticles(const TPoseID &poseID, mrpt::poses::CPose3DPDFParticles &outPDF) const
Returns the mean and covariance of each robot pose in this LMH, as computed from the set of particles...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019