Main MRPT website > C++ reference for MRPT 1.4.0
OcTreeNode.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_NODE_H
10 #define OCTOMAP_OCTREE_NODE_H
11 
12 // $Id: OcTreeNode.h 315 2011-10-17 15:06:59Z 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 
51 #include "octomap_types.h"
52 #include "octomap_utils.h"
53 #include "OcTreeDataNode.h"
54 #include <limits>
55 #include <mrpt/maps/link_pragmas.h> // For DLL export within mrpt-maps via the MAPS_IMPEXP macro
56 
57 namespace octomap {
58 
59  /**
60  * Nodes to be used in OcTree. They represent 3d occupancy grid cells.
61  * "value" stores their log-odds occupancy.
62  *
63  * Hint: If a class is derived from OcTreeNode, you have to implement (at least)
64  * createChild, getChild, and getChild const. See OcTreeNodeLabeled for an example.
65  *
66  */
67  class MAPS_IMPEXP OcTreeNode : public OcTreeDataNode<float> {
68 
69  public:
70  OcTreeNode();
71  ~OcTreeNode();
72 
73  bool createChild(unsigned int i);
74 
75  // overloaded, so that the return type is correct:
76  inline OcTreeNode* getChild(unsigned int i) {
77  return static_cast<OcTreeNode*> (OcTreeDataNode<float>::getChild(i));
78  }
79  inline const OcTreeNode* getChild(unsigned int i) const {
80  return static_cast<const OcTreeNode*> (OcTreeDataNode<float>::getChild(i));
81  }
82 
83  // -- node occupancy ----------------------------
84 
85  /// \return occupancy probability of node
86  inline double getOccupancy() const { return probability(value); }
87 
88  /// \return log odds representation of occupancy probability of node
89  inline float getLogOdds() const{ return value; }
90  /// sets log odds occupancy of node
91  inline void setLogOdds(float l) { value = l; }
92 
93  /**
94  * @return mean of all children's occupancy probabilities, in log odds
95  */
96  double getMeanChildLogOdds() const;
97 
98  /**
99  * @return maximum of children's occupancy probabilities, in log odds
100  */
101  float getMaxChildLogOdds() const;
102 
103  /// update this node's occupancy according to its children's maximum occupancy
104  inline void updateOccupancyChildren() {
105  this->setLogOdds(this->getMaxChildLogOdds()); // conservative
106  }
107 
108  /// adds p to the node's logOdds value (with no boundary / threshold checking!)
109  void addValue(const float& p);
110 
111 
112  protected:
113  // "value" stores log odds occupancy probability
114  };
115 
116 } // end namespace
117 
118 #endif
void updateOccupancyChildren()
update this node&#39;s occupancy according to its children&#39;s maximum occupancy
Definition: OcTreeNode.h:104
OctoMap: A probabilistic, flexible, and compact 3D mapping library for robotic systems.
double probability(double logodds)
compute probability from logodds:
Definition: octomap_utils.h:61
double getOccupancy() const
Definition: OcTreeNode.h:86
float getLogOdds() const
Definition: OcTreeNode.h:89
OcTreeNode * getChild(unsigned int i)
Definition: OcTreeNode.h:76
Nodes to be used in OcTree.
Definition: OcTreeNode.h:67
Basic node in the OcTree that can hold arbitrary data of type T in value.
const OcTreeNode * getChild(unsigned int i) const
Definition: OcTreeNode.h:79
void setLogOdds(float l)
sets log odds occupancy of node
Definition: OcTreeNode.h:91
OcTreeDataNode< T > * getChild(unsigned int i)



Page generated by Doxygen 1.8.11 for MRPT 1.4.0 SVN: at Sun Aug 14 23:58:29 UTC 2016