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://www.mrpt.org/                                |
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                   * \ingroup mrpt_hmtslam_grp
00057                  */
00058                 class HMTSLAM_IMPEXP CHMHMapNode : public mrpt::utils::CSerializable
00059                 {
00060                         friend class HMTSLAM_IMPEXP CHierarchicalMHMap;
00061                         friend class HMTSLAM_IMPEXP CHierarchicalMHMapPartition;
00062                         friend class HMTSLAM_IMPEXP CHMHMapArc;
00063 
00064                         // This must be added to any CSerializable derived class:
00065                         DEFINE_SERIALIZABLE( CHMHMapNode )
00066 
00067                 public:
00068                         /** The type of the IDs of nodes.
00069                           */
00070                         typedef mrpt::utils::TNodeID  TNodeID;
00071 
00072                         /** The hypothesis IDs under which this node exists.
00073                           */
00074                         THypothesisIDSet                m_hypotheses;
00075 
00076                 protected:
00077                         /** An unique identifier for the node: it is randomly generated at construction or read from stream when loaded.
00078                           */
00079                         TNodeID                                 m_ID;
00080 
00081                         /** The list of all arcs from/to this node:
00082                           */
00083                         TArcList                                m_arcs;
00084 
00085                         /** Event handler for arc destruction: It should be only called for arcs from/to this node, altought other case must be handled without effects.
00086                           * \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.
00087                           */
00088                         void  onArcDestruction(CHMHMapArc *arc);
00089 
00090                         /** Event handler for arc addition: It should be only called for arcs from/to this node, altought other cases have no effects.
00091                           */
00092                         void  onArcAddition(CHMHMapArcPtr &arc);
00093 
00094                         /** The hierarchical graph in which this object is into.
00095                           */
00096                         safe_ptr<CHierarchicalMHMap>    m_parent;
00097 
00098                 private:
00099                         /** Private constructor (see ::Create class factory)
00100                           */
00101                         CHMHMapNode(
00102                                 CHierarchicalMHMap              *parent = NULL,
00103                                 const THypothesisIDSet  &hyps = THypothesisIDSet() );
00104 
00105                 public:
00106                         /** Class factory
00107                           */
00108                         static CHMHMapNodePtr Create(
00109                                 CHierarchicalMHMap              *parent = NULL,
00110                                 const THypothesisIDSet  &hyps = THypothesisIDSet() );
00111 
00112                         /** Destructor
00113                          */
00114                         virtual ~CHMHMapNode();
00115 
00116                         /** The annotations of the node, see the general description of the class for possible properties and values.
00117                           */
00118                         utils::CMHPropertiesValuesList  m_annotations;
00119 
00120                         /** The type of the node, the possibilities are:
00121                           *             - Place
00122                           *             - Area
00123                           *             - TopologicalMap
00124                           *             - Object
00125                           */
00126                         utils::CTypeSelector                    m_nodeType;
00127 
00128                         /** Reads the ID of the node (read-only property)
00129                           */
00130                         TNodeID getID() const;
00131 
00132                         /** The label of the node, only for display it to the user.
00133                           */
00134                         std::string             m_label;
00135 
00136                         /** Returns the level of this node in the hierarchy of arcs "arcType_Belongs", where level=0 is the ground level, 1=its parents, etc.
00137                           */
00138                         unsigned int getLevelInTheHierarchy();
00139 
00140                         /** Returns the number of arcs starting from/ending into this node.
00141                           */
00142                         unsigned int getRelatedArcsCount();
00143 
00144                         /** Returns a list with the arcs from/to this node.
00145                           */
00146                         void getArcs( TArcList &out ) const
00147                         {
00148                                 out = m_arcs;
00149                         }
00150 
00151                         /** Returns a list with the arcs from/to this node existing in a given hypothesis ID.
00152                           */
00153                         void getArcs( TArcList &out, const THypothesisID &hyp_id ) const;
00154 
00155                         /** Returns a list with the arcs from/to this node existing in a given hypothesis ID and of a given type.
00156                           */
00157                         void getArcs( TArcList &out, const char *arcType, const THypothesisID &hyp_id ) const;
00158 
00159                         /** Check whether an arc exists towards the given area */
00160                         bool isNeighbor(const TNodeID &otherArea, const THypothesisID &hyp_id ) const;
00161 
00162                 }; // End of class def.
00163 
00164 
00165                 /** A map between node IDs and nodes (used in HMT-SLAM).
00166                   * \sa CHMTSLAM
00167                   */
00168                 typedef std::map<CHMHMapNode::TNodeID,CHMHMapNodePtr>  TNodeList;
00169                 typedef list_searchable<CHMHMapNode::TNodeID> TNodeIDList;
00170                 typedef std::set<CHMHMapNode::TNodeID> TNodeIDSet;
00171                 typedef std::pair<CHMHMapNode::TNodeID,CHMHMapNode::TNodeID>  TPairNodeIDs;
00172 
00173         } // End of namespace
00174 } // End of namespace
00175 
00176 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011