Main MRPT website > C++ reference for MRPT 1.4.0
OcTreeStamped.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, 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 #ifndef OCTOMAP_OCTREE_STAMPED_H
10 #define OCTOMAP_OCTREE_STAMPED_H
11 
12 // $Id: OcTreeStamped.h 397 2012-08-02 13:34:36Z ahornung $
13 
14 /**
15  * OctoMap:
16  * A probabilistic, flexible, and compact 3D mapping library for robotic systems.
17  * @author K. M. Wurm, A. Hornung, University of Freiburg, Copyright (C) 2009-2011
18  * @see http://octomap.sourceforge.net/
19  * License: New BSD License
20  */
21 
22 /*
23  * Copyright (c) 2009-2011, K. M. Wurm, A. Hornung, University of Freiburg
24  * All rights reserved.
25  *
26  * Redistribution and use in source and binary forms, with or without
27  * modification, are permitted provided that the following conditions are met:
28  *
29  * * Redistributions of source code must retain the above copyright
30  * notice, this list of conditions and the following disclaimer.
31  * * Redistributions in binary form must reproduce the above copyright
32  * notice, this list of conditions and the following disclaimer in the
33  * documentation and/or other materials provided with the distribution.
34  * * Neither the name of the University of Freiburg nor the names of its
35  * contributors may be used to endorse or promote products derived from
36  * this software without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
42  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
43  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
44  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49  */
50 
53 #include <ctime>
54 
55 namespace octomap {
56 
57  // node definition
58  class OcTreeNodeStamped : public OcTreeNode {
59 
60  public:
62 
64 
65  bool operator==(const OcTreeNodeStamped& rhs) const{
66  return (rhs.value == value && rhs.timestamp == timestamp);
67  }
68 
69  // children
70  inline OcTreeNodeStamped* getChild(unsigned int i) {
71  return static_cast<OcTreeNodeStamped*> (OcTreeNode::getChild(i));
72  }
73  inline const OcTreeNodeStamped* getChild(unsigned int i) const {
74  return static_cast<const OcTreeNodeStamped*> (OcTreeNode::getChild(i));
75  }
76 
77  bool createChild(unsigned int i) {
78  if (children == NULL) allocChildren();
79  children[i] = new OcTreeNodeStamped();
80  return true;
81  }
82 
83  // timestamp
84  inline unsigned int getTimestamp() const { return timestamp; }
85  inline void updateTimestamp() { timestamp = (unsigned int) time(NULL);}
86  inline void setTimestamp(unsigned int timestamp) {this->timestamp = timestamp; }
87 
88  // update occupancy and timesteps of inner nodes
89  inline void updateOccupancyChildren() {
90  this->setLogOdds(this->getMaxChildLogOdds()); // conservative
92  }
93 
94  protected:
95  unsigned int timestamp;
96  };
97 
98 
99  // tree definition
100  class OcTreeStamped : public OccupancyOcTreeBase <OcTreeNodeStamped> {
101 
102  public:
103  /// Default constructor, sets resolution of leafs
104  OcTreeStamped(double resolution) : OccupancyOcTreeBase<OcTreeNodeStamped>(resolution) {};
105 
106  /// virtual constructor: creates a new object of same type
107  /// (Covariant return type requires an up-to-date compiler)
108  OcTreeStamped* create() const {return new OcTreeStamped(resolution); }
109 
110  std::string getTreeType() const {return "OcTreeStamped";}
111 
112  //! \return timestamp of last update
113  unsigned int getLastUpdateTime();
114 
115  void degradeOutdatedNodes(unsigned int time_thres);
116 
117  virtual void updateNodeLogOdds(OcTreeNodeStamped* node, const float& update) const;
118  void integrateMissNoTime(OcTreeNodeStamped* node) const;
119 
120  protected:
121  /**
122  * Static member object which ensures that this OcTree's prototype
123  * ends up in the classIDMapping only once
124  */
126  public:
128  OcTreeStamped* tree = new OcTreeStamped(0.1);
130  }
131  };
132  /// to ensure static initialization (only once)
134 
135  };
136 
137 } // end namespace
138 
139 #endif
Base implementation for Occupancy Octrees (e.g.
Static member object which ensures that this OcTree&#39;s prototype ends up in the classIDMapping only on...
OctoMap: A probabilistic, flexible, and compact 3D mapping library for robotic systems.
std::string getTreeType() const
returns actual class name as string for identification
OcTreeNodeStamped(const OcTreeNodeStamped &rhs)
Definition: OcTreeStamped.h:63
OcTreeDataNode< float > ** children
pointer to array of children, may be NULL
bool operator==(const OcTreeNodeStamped &rhs) const
Definition: OcTreeStamped.h:65
float getMaxChildLogOdds() const
void setTimestamp(unsigned int timestamp)
Definition: OcTreeStamped.h:86
OcTreeNodeStamped * getChild(unsigned int i)
Definition: OcTreeStamped.h:70
OcTreeNode * getChild(unsigned int i)
Definition: OcTreeNode.h:76
T value
stored data (payload)
static void registerTreeType(AbstractOcTree *tree)
bool createChild(unsigned int i)
Definition: OcTreeStamped.h:77
unsigned int getTimestamp() const
Definition: OcTreeStamped.h:84
OcTreeStamped * create() const
virtual constructor: creates a new object of same type (Covariant return type requires an up-to-date ...
Nodes to be used in OcTree.
Definition: OcTreeNode.h:67
const OcTreeNodeStamped * getChild(unsigned int i) const
Definition: OcTreeStamped.h:73
OcTreeStamped(double resolution)
Default constructor, sets resolution of leafs.
static StaticMemberInitializer ocTreeStampedMemberInit
to ensure static initialization (only once)
void setLogOdds(float l)
sets log odds occupancy of node
Definition: OcTreeNode.h:91



Page generated by Doxygen 1.8.11 for MRPT 1.4.0 SVN: at Mon Aug 15 11:50:21 UTC 2016