octomap 1.9.8
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
42namespace octomap {
43
44 // node definition
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
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:
83
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
static void registerTreeType(AbstractOcTree *tree)
Definition: AbstractOcTree.cpp:205
void clearKeyRays()
Clear KeyRay vector to minimize unneeded memory.
Definition: OcTreeBaseImpl.h:120
double resolution
in meters
Definition: OcTreeBaseImpl.h:547
T value
stored data (payload)
Definition: OcTreeDataNode.h:128
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
Definition: OcTreeStamped.h:45
void copyData(const OcTreeNodeStamped &from)
Definition: OcTreeStamped.h:56
void updateOccupancyChildren()
Definition: OcTreeStamped.h:67
unsigned int getTimestamp() const
Definition: OcTreeStamped.h:62
void updateTimestamp()
Definition: OcTreeStamped.h:63
unsigned int timestamp
Definition: OcTreeStamped.h:73
OcTreeNodeStamped(const OcTreeNodeStamped &rhs)
Definition: OcTreeStamped.h:50
void setTimestamp(unsigned int t)
Definition: OcTreeStamped.h:64
bool operator==(const OcTreeNodeStamped &rhs) const
Definition: OcTreeStamped.h:52
OcTreeNodeStamped()
Definition: OcTreeStamped.h:48
Nodes to be used in OcTree.
Definition: OcTreeNode.h:55
float getMaxChildLogOdds() const
Definition: OcTreeNode.cpp:76
void setLogOdds(float l)
sets log odds occupancy of node
Definition: OcTreeNode.h:70
Static member object which ensures that this OcTree's prototype ends up in the classIDMapping only on...
Definition: OcTreeStamped.h:106
void ensureLinking()
Dummy function to ensure that MSVC does not drop the StaticMemberInitializer, causing this tree faili...
Definition: OcTreeStamped.h:119
StaticMemberInitializer()
Definition: OcTreeStamped.h:108
Definition: OcTreeStamped.h:78
std::string getTreeType() const
returns actual class name as string for identification
Definition: OcTreeStamped.h:88
unsigned int getLastUpdateTime()
Definition: OcTreeStamped.cpp:43
OcTreeStamped * create() const
virtual constructor: creates a new object of same type (Covariant return type requires an up-to-date ...
Definition: OcTreeStamped.h:86
void degradeOutdatedNodes(unsigned int time_thres)
Definition: OcTreeStamped.cpp:49
OcTreeStamped(double resolution)
Default constructor, sets resolution of leafs.
Definition: OcTreeStamped.cpp:38
void integrateMissNoTime(OcTreeNodeStamped *node) const
Definition: OcTreeStamped.cpp:66
static StaticMemberInitializer ocTreeStampedMemberInit
to ensure static initialization (only once)
Definition: OcTreeStamped.h:122
virtual void updateNodeLogOdds(OcTreeNodeStamped *node, const float &update) const
Definition: OcTreeStamped.cpp:61
Base implementation for Occupancy Octrees (e.g.
Definition: OccupancyOcTreeBase.h:69
Namespace the OctoMap library and visualization tools.