OcTreeStamped.h
Go to the documentation of this file.
1 /*
2  * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3  * http://octomap.github.com/
4  *
5  * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6  * All rights reserved.
7  * License: New BSD
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  * * Neither the name of the University of Freiburg nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef OCTOMAP_OCTREE_STAMPED_H
35 #define OCTOMAP_OCTREE_STAMPED_H
36 
37 
38 #include <octomap/OcTreeNode.h>
40 #include <ctime>
41 
42 namespace octomap {
43 
44  // node definition
45  class OcTreeNodeStamped : public OcTreeNode {
46 
47  public:
49 
51 
52  bool operator==(const OcTreeNodeStamped& rhs) const{
53  return (rhs.value == value && rhs.timestamp == timestamp);
54  }
55 
56  // children
57  inline OcTreeNodeStamped* getChild(unsigned int i) {
58  return static_cast<OcTreeNodeStamped*> (OcTreeNode::getChild(i));
59  }
60  inline const OcTreeNodeStamped* getChild(unsigned int i) const {
61  return static_cast<const OcTreeNodeStamped*> (OcTreeNode::getChild(i));
62  }
63 
64  bool createChild(unsigned int i) {
65  if (children == NULL) allocChildren();
66  children[i] = new OcTreeNodeStamped();
67  return true;
68  }
69 
70  // timestamp
71  inline unsigned int getTimestamp() const { return timestamp; }
72  inline void updateTimestamp() { timestamp = (unsigned int) time(NULL);}
73  inline void setTimestamp(unsigned int timestamp) {this->timestamp = timestamp; }
74 
75  // update occupancy and timesteps of inner nodes
76  inline void updateOccupancyChildren() {
77  this->setLogOdds(this->getMaxChildLogOdds()); // conservative
79  }
80 
81  protected:
82  unsigned int timestamp;
83  };
84 
85 
86  // tree definition
87  class OcTreeStamped : public OccupancyOcTreeBase <OcTreeNodeStamped> {
88 
89  public:
91  OcTreeStamped(double resolution);
92 
95  OcTreeStamped* create() const {return new OcTreeStamped(resolution); }
96 
97  std::string getTreeType() const {return "OcTreeStamped";}
98 
100  unsigned int getLastUpdateTime();
101 
102  void degradeOutdatedNodes(unsigned int time_thres);
103 
104  virtual void updateNodeLogOdds(OcTreeNodeStamped* node, const float& update) const;
105  void integrateMissNoTime(OcTreeNodeStamped* node) const;
106 
107  protected:
116  public:
118  OcTreeStamped* tree = new OcTreeStamped(0.1);
120  }
121 
127  void ensureLinking() {};
128  };
131 
132  };
133 
134 } // end namespace
135 
136 #endif
static void registerTreeType(AbstractOcTree *tree)
T value
stored data (payload)
OcTreeNode * getChild(unsigned int i)
Definition: OcTreeNode.h:64
float getMaxChildLogOdds() const
Definition: OcTreeNode.cpp:82
static StaticMemberInitializer ocTreeStampedMemberInit
to ensure static initialization (only once)
bool createChild(unsigned int i)
Definition: OcTreeStamped.h:64
unsigned int getTimestamp() const
Definition: OcTreeStamped.h:71
void setLogOdds(float l)
sets log odds occupancy of node
Definition: OcTreeNode.h:79
OcTreeNodeStamped * getChild(unsigned int i)
Definition: OcTreeStamped.h:57
OcTreeDataNode< float > ** children
pointer to array of children, may be NULL
void setTimestamp(unsigned int timestamp)
Definition: OcTreeStamped.h:73
std::string getTreeType() const
returns actual class name as string for identification
Definition: OcTreeStamped.h:97
bool operator==(const OcTreeNodeStamped &rhs) const
Definition: OcTreeStamped.h:52
OcTreeNodeStamped(const OcTreeNodeStamped &rhs)
Definition: OcTreeStamped.h:50
OcTreeStamped * create() const
Definition: OcTreeStamped.h:95
const OcTreeNodeStamped * getChild(unsigned int i) const
Definition: OcTreeStamped.h:60


octomap
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Mon Jun 10 2019 14:00:13