octomap  1.9.7
OcTreeStamped.h
Go to the documentation of this file.
1 /*
2  * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3  * https://octomap.github.io/
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  void copyData(const OcTreeNodeStamped& from){
58  timestamp = from.getTimestamp();
59  }
60 
61  // timestamp
62  inline unsigned int getTimestamp() const { return timestamp; }
63  inline void updateTimestamp() { timestamp = (unsigned int) time(NULL);}
64  inline void setTimestamp(unsigned int t) {timestamp = t; }
65 
66  // update occupancy and timesteps of inner nodes
67  inline void updateOccupancyChildren() {
68  this->setLogOdds(this->getMaxChildLogOdds()); // conservative
70  }
71 
72  protected:
73  unsigned int timestamp;
74  };
75 
76 
77  // tree definition
78  class OcTreeStamped : public OccupancyOcTreeBase <OcTreeNodeStamped> {
79 
80  public:
82  OcTreeStamped(double resolution);
83 
86  OcTreeStamped* create() const {return new OcTreeStamped(resolution); }
87 
88  std::string getTreeType() const {return "OcTreeStamped";}
89 
91  unsigned int getLastUpdateTime();
92 
93  void degradeOutdatedNodes(unsigned int time_thres);
94 
95  virtual void updateNodeLogOdds(OcTreeNodeStamped* node, const float& update) const;
96  void integrateMissNoTime(OcTreeNodeStamped* node) const;
97 
98  protected:
107  public:
109  OcTreeStamped* tree = new OcTreeStamped(0.1);
110  tree->clearKeyRays();
112  }
113 
119  void ensureLinking() {};
120  };
123 
124  };
125 
126 } // end namespace
127 
128 #endif
octomap::OcTreeStamped::StaticMemberInitializer::ensureLinking
void ensureLinking()
Dummy function to ensure that MSVC does not drop the StaticMemberInitializer, causing this tree faili...
Definition: OcTreeStamped.h:119
octomap::OcTreeStamped::OcTreeStamped
OcTreeStamped(double resolution)
Default constructor, sets resolution of leafs.
Definition: OcTreeStamped.cpp:38
octomap::OcTreeNodeStamped::timestamp
unsigned int timestamp
Definition: OcTreeStamped.h:73
octomap::OcTreeNodeStamped::updateOccupancyChildren
void updateOccupancyChildren()
Definition: OcTreeStamped.h:67
octomap::OccupancyOcTreeBase
Base implementation for Occupancy Octrees (e.g.
Definition: OccupancyOcTreeBase.h:69
octomap::OcTreeStamped::StaticMemberInitializer::StaticMemberInitializer
StaticMemberInitializer()
Definition: OcTreeStamped.h:108
octomap::OcTreeStamped::getTreeType
std::string getTreeType() const
returns actual class name as string for identification
Definition: OcTreeStamped.h:88
octomap::OcTreeStamped::StaticMemberInitializer
Static member object which ensures that this OcTree's prototype ends up in the classIDMapping only on...
Definition: OcTreeStamped.h:106
octomap::OcTreeDataNode::value
T value
stored data (payload)
Definition: OcTreeDataNode.h:128
octomap::OcTreeStamped::getLastUpdateTime
unsigned int getLastUpdateTime()
Definition: OcTreeStamped.cpp:43
octomap::OcTreeNode::getMaxChildLogOdds
float getMaxChildLogOdds() const
Definition: OcTreeNode.cpp:76
octomap::OcTreeNodeStamped::updateTimestamp
void updateTimestamp()
Definition: OcTreeStamped.h:63
octomap::OcTreeNodeStamped
Definition: OcTreeStamped.h:45
octomap::OcTreeNode
Nodes to be used in OcTree.
Definition: OcTreeNode.h:55
octomap::OcTreeNodeStamped::copyData
void copyData(const OcTreeNodeStamped &from)
Definition: OcTreeStamped.h:56
octomap::OcTreeDataNode< float >::copyData
void copyData(const OcTreeDataNode &from)
Copy the payload (data in "value") from rhs into this node Opposed to copy ctor, this does not clone ...
Definition: OcTreeDataNode.hxx:73
octomap::OcTreeStamped::ocTreeStampedMemberInit
static StaticMemberInitializer ocTreeStampedMemberInit
to ensure static initialization (only once)
Definition: OcTreeStamped.h:122
OcTreeNode.h
octomap::OcTreeNodeStamped::OcTreeNodeStamped
OcTreeNodeStamped()
Definition: OcTreeStamped.h:48
octomap::AbstractOcTree::registerTreeType
static void registerTreeType(AbstractOcTree *tree)
Definition: AbstractOcTree.cpp:205
OccupancyOcTreeBase.h
octomap::OcTreeNode::setLogOdds
void setLogOdds(float l)
sets log odds occupancy of node
Definition: OcTreeNode.h:70
octomap::OcTreeNodeStamped::getTimestamp
unsigned int getTimestamp() const
Definition: OcTreeStamped.h:62
octomap::OcTreeStamped::degradeOutdatedNodes
void degradeOutdatedNodes(unsigned int time_thres)
Definition: OcTreeStamped.cpp:49
octomap::OcTreeNodeStamped::operator==
bool operator==(const OcTreeNodeStamped &rhs) const
Definition: OcTreeStamped.h:52
octomap
Tables used by the Marching Cubes Algorithm The tables are from Paul Bourke's web page http://paulbou...
octomap::OcTreeNodeStamped::setTimestamp
void setTimestamp(unsigned int t)
Definition: OcTreeStamped.h:64
octomap::OcTreeStamped::integrateMissNoTime
void integrateMissNoTime(OcTreeNodeStamped *node) const
Definition: OcTreeStamped.cpp:66
octomap::OcTreeStamped::updateNodeLogOdds
virtual void updateNodeLogOdds(OcTreeNodeStamped *node, const float &update) const
update logodds value of node by adding to the current value.
Definition: OcTreeStamped.cpp:61
octomap::OcTreeBaseImpl< OcTreeNodeStamped, AbstractOccupancyOcTree >::resolution
double resolution
in meters
Definition: OcTreeBaseImpl.h:547
octomap::OcTreeBaseImpl::clearKeyRays
void clearKeyRays()
Clear KeyRay vector to minimize unneeded memory.
Definition: OcTreeBaseImpl.h:120
octomap::OcTreeNodeStamped::OcTreeNodeStamped
OcTreeNodeStamped(const OcTreeNodeStamped &rhs)
Definition: OcTreeStamped.h:50
octomap::OcTreeStamped::create
OcTreeStamped * create() const
virtual constructor: creates a new object of same type (Covariant return type requires an up-to-date ...
Definition: OcTreeStamped.h:86
octomap::OcTreeStamped
Definition: OcTreeStamped.h:78