Main MRPT website > C++ reference
MRPT logo

CHMHMapNode.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef CHMHMapNode_H
00029 #define CHMHMapNode_H
00030 
00031 #include <mrpt/utils/safe_pointers.h>
00032 #include <mrpt/utils/stl_extensions.h>
00033 #include <mrpt/slam/CSensoryFrame.h>
00034 #include <mrpt/hmtslam/HMT_SLAM_common.h>
00035 
00036 #include <mrpt/utils/CSerializable.h>
00037 #include <mrpt/utils/CMHPropertiesValuesList.h>
00038 #include <mrpt/utils/CTypeSelector.h>
00039 
00040 namespace mrpt
00041 {
00042         namespace hmtslam
00043         {
00044                 using namespace mrpt::slam;
00045 
00046                 class HMTSLAM_IMPEXP CHierarchicalMHMap;
00047                 class HMTSLAM_IMPEXP CHMHMapArc;
00048 
00049                 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CHMHMapNode,mrpt::utils::CSerializable, HMTSLAM_IMPEXP )
00050 
00051                 /** A class for representing a node in a hierarchical, multi-hypothesis map.
00052                  *   The node itself will be considered only if some given hypothesisID matchs its own ID.
00053                  * \note Create objects by invoking the class factory "::Create"
00054                  *
00055                  * \sa CHierarchicalMHMap,CHMHMapArc
00056                  */
00057                 class HMTSLAM_IMPEXP CHMHMapNode : public mrpt::utils::CSerializable
00058                 {
00059                         friend class HMTSLAM_IMPEXP CHierarchicalMHMap;
00060                         friend class HMTSLAM_IMPEXP CHierarchicalMHMapPartition;
00061                         friend class HMTSLAM_IMPEXP CHMHMapArc;
00062 
00063                         // This must be added to any CSerializable derived class:
00064                         DEFINE_SERIALIZABLE( CHMHMapNode )
00065 
00066                 public:
00067                         /** The type of the IDs of nodes.
00068                           */
00069                         typedef mrpt::utils::TNodeID  TNodeID;
00070 
00071                         /** The hypothesis IDs under which this node exists.
00072                           */
00073                         THypothesisIDSet                m_hypotheses;
00074 
00075                 protected:
00076                         /** An unique identifier for the node: it is randomly generated at construction or read from stream when loaded.
00077                           */
00078                         TNodeID                                 m_ID;
00079 
00080                         /** The list of all arcs from/to this node:
00081                           */
00082                         TArcList                                m_arcs;
00083 
00084                         /** Event handler for arc destruction: It should be only called for arcs from/to this node, altought other case must be handled without effects.
00085                           * \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.
00086                           */
00087                         void  onArcDestruction(CHMHMapArc *arc);
00088 
00089                         /** Event handler for arc addition: It should be only called for arcs from/to this node, altought other cases have no effects.
00090                           */
00091                         void  onArcAddition(CHMHMapArcPtr &arc);
00092 
00093                         /** The hierarchical graph in which this object is into.
00094                           */
00095                         safe_ptr<CHierarchicalMHMap>    m_parent;
00096 
00097                 private:
00098                         /** Private constructor (see ::Create class factory)
00099                           */
00100                         CHMHMapNode(
00101                                 CHierarchicalMHMap              *parent = NULL,
00102                                 const THypothesisIDSet  &hyps = THypothesisIDSet() );
00103 
00104                 public:
00105                         /** Class factory
00106                           */
00107                         static CHMHMapNodePtr Create(
00108                                 CHierarchicalMHMap              *parent = NULL,
00109                                 const THypothesisIDSet  &hyps = THypothesisIDSet() );
00110 
00111                         /** Destructor
00112                          */
00113                         virtual ~CHMHMapNode();
00114 
00115                         /** The annotations of the node, see the general description of the class for possible properties and values.
00116                           */
00117                         utils::CMHPropertiesValuesList  m_annotations;
00118 
00119                         /** The type of the node, the possibilities are:
00120                           *             - Place
00121                           *             - Area
00122                           *             - TopologicalMap
00123                           *             - Object
00124                           */
00125                         utils::CTypeSelector                    m_nodeType;
00126 
00127                         /** Reads the ID of the node (read-only property)
00128                           */
00129                         TNodeID getID() const;
00130 
00131                         /** The label of the node, only for display it to the user.
00132                           */
00133                         std::string             m_label;
00134 
00135                         /** Returns the level of this node in the hierarchy of arcs "arcType_Belongs", where level=0 is the ground level, 1=its parents, etc.
00136                           */
00137                         unsigned int getLevelInTheHierarchy();
00138 
00139                         /** Returns the number of arcs starting from/ending into this node.
00140                           */
00141                         unsigned int getRelatedArcsCount();
00142 
00143                         /** Returns a list with the arcs from/to this node.
00144                           */
00145                         void getArcs( TArcList &out ) const
00146                         {
00147                                 out = m_arcs;
00148                         }
00149 
00150                         /** Returns a list with the arcs from/to this node existing in a given hypothesis ID.
00151                           */
00152                         void getArcs( TArcList &out, const THypothesisID &hyp_id ) const;
00153 
00154                         /** Returns a list with the arcs from/to this node existing in a given hypothesis ID and of a given type.
00155                           */
00156                         void getArcs( TArcList &out, const char *arcType, const THypothesisID &hyp_id ) const;
00157 
00158                         /** Check whether an arc exists towards the given area */
00159                         bool isNeighbor(const TNodeID &otherArea, const THypothesisID &hyp_id ) const;
00160 
00161                 }; // End of class def.
00162 
00163 
00164                 /** A map between node IDs and nodes (used in HMT-SLAM).
00165                   * \sa CHMTSLAM
00166                   */
00167                 typedef std::map<CHMHMapNode::TNodeID,CHMHMapNodePtr>  TNodeList;
00168                 typedef list_searchable<CHMHMapNode::TNodeID> TNodeIDList;
00169                 typedef std::set<CHMHMapNode::TNodeID> TNodeIDSet;
00170                 typedef std::pair<CHMHMapNode::TNodeID,CHMHMapNode::TNodeID>  TPairNodeIDs;
00171 
00172         } // End of namespace
00173 } // End of namespace
00174 
00175 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:16:28 UTC 2011