Main MRPT website > C++ reference
MRPT logo
CHMHMapNode.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CHMHMapNode_H
29 #define CHMHMapNode_H
30 
35 
39 
40 namespace mrpt
41 {
42  namespace hmtslam
43  {
44  using namespace mrpt::slam;
45 
48 
50 
51  /** A class for representing a node in a hierarchical, multi-hypothesis map.
52  * The node itself will be considered only if some given hypothesisID matchs its own ID.
53  * \note Create objects by invoking the class factory "::Create"
54  *
55  * \sa CHierarchicalMHMap,CHMHMapArc
56  * \ingroup mrpt_hmtslam_grp
57  */
58  class HMTSLAM_IMPEXP CHMHMapNode : public mrpt::utils::CSerializable
59  {
61  friend class HMTSLAM_IMPEXP CHierarchicalMHMapPartition;
62  friend class HMTSLAM_IMPEXP CHMHMapArc;
63 
64  // This must be added to any CSerializable derived class:
66 
67  public:
68  /** The type of the IDs of nodes.
69  */
70  typedef mrpt::utils::TNodeID TNodeID;
71 
72  /** The hypothesis IDs under which this node exists.
73  */
74  THypothesisIDSet m_hypotheses;
75 
76  protected:
77  /** An unique identifier for the node: it is randomly generated at construction or read from stream when loaded.
78  */
79  TNodeID m_ID;
80 
81  /** The list of all arcs from/to this node:
82  */
83  TArcList m_arcs;
84 
85  /** Event handler for arc destruction: It should be only called for arcs from/to this node, altought other case must be handled without effects.
86  * \note At *addition we use a smart pointer to assure all the implied guys use the same smrt. pnt., but at destructors the objects don't know anything but "this", thus the usage of plain pointers.
87  */
88  void onArcDestruction(CHMHMapArc *arc);
89 
90  /** Event handler for arc addition: It should be only called for arcs from/to this node, altought other cases have no effects.
91  */
92  void onArcAddition(CHMHMapArcPtr &arc);
93 
94  /** The hierarchical graph in which this object is into.
95  */
97 
98  private:
99  /** Private constructor (see ::Create class factory)
100  */
101  CHMHMapNode(
102  CHierarchicalMHMap *parent = NULL,
103  const THypothesisIDSet &hyps = THypothesisIDSet() );
104 
105  public:
106  /** Class factory
107  */
108  static CHMHMapNodePtr Create(
109  CHierarchicalMHMap *parent = NULL,
110  const THypothesisIDSet &hyps = THypothesisIDSet() );
111 
112  /** Destructor
113  */
114  virtual ~CHMHMapNode();
115 
116  /** The annotations of the node, see the general description of the class for possible properties and values.
117  */
118  utils::CMHPropertiesValuesList m_annotations;
119 
120  /** The type of the node, the possibilities are:
121  * - Place
122  * - Area
123  * - TopologicalMap
124  * - Object
125  */
126  utils::CTypeSelector m_nodeType;
127 
128  /** Reads the ID of the node (read-only property)
129  */
130  TNodeID getID() const;
131 
132  /** The label of the node, only for display it to the user.
133  */
134  std::string m_label;
135 
136  /** Returns the level of this node in the hierarchy of arcs "arcType_Belongs", where level=0 is the ground level, 1=its parents, etc.
137  */
138  unsigned int getLevelInTheHierarchy();
139 
140  /** Returns the number of arcs starting from/ending into this node.
141  */
142  unsigned int getRelatedArcsCount();
143 
144  /** Returns a list with the arcs from/to this node.
145  */
146  void getArcs( TArcList &out ) const
147  {
148  out = m_arcs;
149  }
150 
151  /** Returns a list with the arcs from/to this node existing in a given hypothesis ID.
152  */
153  void getArcs( TArcList &out, const THypothesisID &hyp_id ) const;
154 
155  /** Returns a list with the arcs from/to this node existing in a given hypothesis ID and of a given type.
156  */
157  void getArcs( TArcList &out, const char *arcType, const THypothesisID &hyp_id ) const;
158 
159  /** Check whether an arc exists towards the given area */
160  bool isNeighbor(const TNodeID &otherArea, const THypothesisID &hyp_id ) const;
161 
162  }; // End of class def.
163 
164 
165  /** A map between node IDs and nodes (used in HMT-SLAM).
166  * \sa CHMTSLAM
167  */
168  typedef std::map<CHMHMapNode::TNodeID,CHMHMapNodePtr> TNodeList;
170  typedef std::set<CHMHMapNode::TNodeID> TNodeIDSet;
171  typedef std::pair<CHMHMapNode::TNodeID,CHMHMapNode::TNodeID> TPairNodeIDs;
172 
173  } // End of namespace
174 } // End of namespace
175 
176 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013