00001 /* 00002 * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees 00003 * http://octomap.github.com/ 00004 * 00005 * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg 00006 * All rights reserved. 00007 * License: New BSD 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the distribution. 00017 * * Neither the name of the University of Freiburg nor the names of its 00018 * contributors may be used to endorse or promote products derived from 00019 * this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00031 * POSSIBILITY OF SUCH DAMAGE. 00032 */ 00033 00034 #ifndef OCTOMAP_OCTREE_NODE_H 00035 #define OCTOMAP_OCTREE_NODE_H 00036 00037 #include "octomap_types.h" 00038 #include "octomap_utils.h" 00039 #include "OcTreeDataNode.h" 00040 #include <limits> 00041 00042 namespace octomap { 00043 00052 class OcTreeNode : public OcTreeDataNode<float> { 00053 00054 public: 00055 OcTreeNode(); 00056 ~OcTreeNode(); 00057 00058 bool createChild(unsigned int i); 00059 00060 // overloaded, so that the return type is correct: 00061 inline OcTreeNode* getChild(unsigned int i) { 00062 return static_cast<OcTreeNode*> (OcTreeDataNode<float>::getChild(i)); 00063 } 00064 inline const OcTreeNode* getChild(unsigned int i) const { 00065 return static_cast<const OcTreeNode*> (OcTreeDataNode<float>::getChild(i)); 00066 } 00067 00068 // -- node occupancy ---------------------------- 00069 00071 inline double getOccupancy() const { return probability(value); } 00072 00074 inline float getLogOdds() const{ return value; } 00076 inline void setLogOdds(float l) { value = l; } 00077 00081 double getMeanChildLogOdds() const; 00082 00086 float getMaxChildLogOdds() const; 00087 00089 inline void updateOccupancyChildren() { 00090 this->setLogOdds(this->getMaxChildLogOdds()); // conservative 00091 } 00092 00094 void addValue(const float& p); 00095 00096 00097 protected: 00098 // "value" stores log odds occupancy probability 00099 }; 00100 00101 } // end namespace 00102 00103 #endif