OccupancyOcTreeBase.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_OCCUPANCY_OCTREE_BASE_H
35 #define OCTOMAP_OCCUPANCY_OCTREE_BASE_H
36 
37 
38 #include <list>
39 #include <stdlib.h>
40 #include <vector>
41 
42 #include "octomap_types.h"
43 #include "octomap_utils.h"
44 #include "OcTreeBaseImpl.h"
46 
47 
48 namespace octomap {
49 
68  template <class NODE>
69  class OccupancyOcTreeBase : public OcTreeBaseImpl<NODE,AbstractOccupancyOcTree> {
70 
71  public:
74  virtual ~OccupancyOcTreeBase();
75 
78 
96  virtual void insertPointCloud(const Pointcloud& scan, const octomap::point3d& sensor_origin,
97  double maxrange=-1., bool lazy_eval = false, bool discretize = false);
98 
117  virtual void insertPointCloud(const Pointcloud& scan, const point3d& sensor_origin, const pose6d& frame_origin,
118  double maxrange=-1., bool lazy_eval = false, bool discretize = false);
119 
132  virtual void insertPointCloud(const ScanNode& scan, double maxrange=-1., bool lazy_eval = false, bool discretize = false);
133 
135  OCTOMAP_DEPRECATED(virtual void insertScan(const Pointcloud& scan, const octomap::point3d& sensor_origin,
136  double maxrange=-1., bool pruning=true, bool lazy_eval = false))
137  {
138  this->insertPointCloud(scan, sensor_origin, maxrange, lazy_eval);
139  }
140 
142  OCTOMAP_DEPRECATED(virtual void insertScan(const Pointcloud& scan, const point3d& sensor_origin,
143  const pose6d& frame_origin, double maxrange=-1., bool pruning = true, bool lazy_eval = false))
144  {
145  this->insertPointCloud(scan, sensor_origin, frame_origin, maxrange, lazy_eval);
146  }
147 
149  OCTOMAP_DEPRECATED(virtual void insertScan(const ScanNode& scan, double maxrange=-1., bool pruning = true, bool lazy_eval = false)){
150  this->insertPointCloud(scan, maxrange, lazy_eval);
151  }
152 
154  OCTOMAP_DEPRECATED( virtual void insertScanNaive(const Pointcloud& scan, const point3d& sensor_origin, double maxrange, bool lazy_eval = false)){
155  this->insertPointCloudRays(scan, sensor_origin, maxrange, lazy_eval);
156  }
157 
170  virtual void insertPointCloudRays(const Pointcloud& scan, const point3d& sensor_origin, double maxrange = -1., bool lazy_eval = false);
171 
182  virtual NODE* setNodeValue(const OcTreeKey& key, float log_odds_value, bool lazy_eval = false);
183 
194  virtual NODE* setNodeValue(const point3d& value, float log_odds_value, bool lazy_eval = false);
195 
208  virtual NODE* setNodeValue(double x, double y, double z, float log_odds_value, bool lazy_eval = false);
209 
220  virtual NODE* updateNode(const OcTreeKey& key, float log_odds_update, bool lazy_eval = false);
221 
232  virtual NODE* updateNode(const point3d& value, float log_odds_update, bool lazy_eval = false);
233 
246  virtual NODE* updateNode(double x, double y, double z, float log_odds_update, bool lazy_eval = false);
247 
257  virtual NODE* updateNode(const OcTreeKey& key, bool occupied, bool lazy_eval = false);
258 
269  virtual NODE* updateNode(const point3d& value, bool occupied, bool lazy_eval = false);
270 
283  virtual NODE* updateNode(double x, double y, double z, bool occupied, bool lazy_eval = false);
284 
285 
291  virtual void toMaxLikelihood();
292 
306  virtual bool insertRay(const point3d& origin, const point3d& end, double maxrange=-1.0, bool lazy_eval = false);
307 
326  virtual bool castRay(const point3d& origin, const point3d& direction, point3d& end,
327  bool ignoreUnknownCells=false, double maxRange=-1.0) const;
328 
340  virtual bool getRayIntersection(const point3d& origin, const point3d& direction, const point3d& center,
341  point3d& intersection, double delta=0.0) const;
342 
353  bool getNormals(const point3d& point, std::vector<point3d>& normals, bool unknownStatus=true) const;
354 
355  //-- set BBX limit (limits tree updates to this bounding box)
356 
358  void useBBXLimit(bool enable) { use_bbx_limit = enable; }
359  bool bbxSet() const { return use_bbx_limit; }
361  void setBBXMin (point3d& min);
363  void setBBXMax (point3d& max);
365  point3d getBBXMin () const { return bbx_min; }
367  point3d getBBXMax () const { return bbx_max; }
368  point3d getBBXBounds () const;
369  point3d getBBXCenter () const;
371  bool inBBX(const point3d& p) const;
373  bool inBBX(const OcTreeKey& key) const;
374 
375  //-- change detection on occupancy:
377  void enableChangeDetection(bool enable) { use_change_detection = enable; }
380  void resetChangeDetection() { changed_keys.clear(); }
381 
387  KeyBoolMap::const_iterator changedKeysBegin() const {return changed_keys.begin();}
388 
390  KeyBoolMap::const_iterator changedKeysEnd() const {return changed_keys.end();}
391 
393  size_t numChangesDetected() const { return changed_keys.size(); }
394 
395 
407  void computeUpdate(const Pointcloud& scan, const octomap::point3d& origin,
408  KeySet& free_cells,
409  KeySet& occupied_cells,
410  double maxrange);
411 
412 
425  void computeDiscreteUpdate(const Pointcloud& scan, const octomap::point3d& origin,
426  KeySet& free_cells,
427  KeySet& occupied_cells,
428  double maxrange);
429 
430 
431  // -- I/O -----------------------------------------
432 
438  std::istream& readBinaryData(std::istream &s);
439 
447  std::istream& readBinaryNode(std::istream &s, NODE* node) const;
448 
460  std::ostream& writeBinaryNode(std::ostream &s, const NODE* node) const;
461 
466  std::ostream& writeBinaryData(std::ostream &s) const;
467 
468 
474  void updateInnerOccupancy();
475 
476 
478  virtual void integrateHit(NODE* occupancyNode) const;
480  virtual void integrateMiss(NODE* occupancyNode) const;
482  virtual void updateNodeLogOdds(NODE* occupancyNode, const float& update) const;
483 
485  virtual void nodeToMaxLikelihood(NODE* occupancyNode) const;
487  virtual void nodeToMaxLikelihood(NODE& occupancyNode) const;
488 
489  protected:
492  OccupancyOcTreeBase(double resolution, unsigned int tree_depth, unsigned int tree_max_val);
493 
498  inline bool integrateMissOnRay(const point3d& origin, const point3d& end, bool lazy_eval = false);
499 
500 
501  // recursive calls ----------------------------
502 
503  NODE* updateNodeRecurs(NODE* node, bool node_just_created, const OcTreeKey& key,
504  unsigned int depth, const float& log_odds_update, bool lazy_eval = false);
505 
506  NODE* setNodeValueRecurs(NODE* node, bool node_just_created, const OcTreeKey& key,
507  unsigned int depth, const float& log_odds_value, bool lazy_eval = false);
508 
509  void updateInnerOccupancyRecurs(NODE* node, unsigned int depth);
510 
511  void toMaxLikelihoodRecurs(NODE* node, unsigned int depth, unsigned int max_depth);
512 
513 
514  protected:
520 
524 
525 
526  };
527 
528 } // namespace
529 
530 #include "octomap/OccupancyOcTreeBase.hxx"
531 
532 #endif
void updateInnerOccupancyRecurs(NODE *node, unsigned int depth)
std::ostream & writeBinaryNode(std::ostream &s, const NODE *node) const
void computeDiscreteUpdate(const Pointcloud &scan, const octomap::point3d &origin, KeySet &free_cells, KeySet &occupied_cells, double maxrange)
const unsigned int tree_depth
Maximum tree depth is fixed to 16 currently.
virtual NODE * updateNode(const OcTreeKey &key, float log_odds_update, bool lazy_eval=false)
bool integrateMissOnRay(const point3d &origin, const point3d &end, bool lazy_eval=false)
size_t numChangesDetected() const
Number of changes since last reset.
std::istream & readBinaryData(std::istream &s)
unordered_ns::unordered_map< OcTreeKey, bool, OcTreeKey::KeyHash > KeyBoolMap
Definition: OcTreeKey.h:121
OCTOMAP_DEPRECATED(virtual void insertScanNaive(const Pointcloud &scan, const point3d &sensor_origin, double maxrange, bool lazy_eval=false))
virtual void integrateHit(NODE *occupancyNode) const
integrate a "hit" measurement according to the tree&#39;s sensor model
OccupancyOcTreeBase(double resolution)
Default constructor, sets resolution of leafs.
OCTOMAP_DEPRECATED(virtual void insertScan(const ScanNode &scan, double maxrange=-1., bool pruning=true, bool lazy_eval=false))
bool inBBX(const point3d &p) const
void setBBXMax(point3d &max)
sets the maximum for a query bounding box to use
std::ostream & writeBinaryData(std::ostream &s) const
virtual NODE * setNodeValue(const OcTreeKey &key, float log_odds_value, bool lazy_eval=false)
OCTOMAP_DEPRECATED(virtual void insertScan(const Pointcloud &scan, const octomap::point3d &sensor_origin, double maxrange=-1., bool pruning=true, bool lazy_eval=false))
virtual void insertPointCloud(const Pointcloud &scan, const octomap::point3d &sensor_origin, double maxrange=-1., bool lazy_eval=false, bool discretize=false)
virtual bool insertRay(const point3d &origin, const point3d &end, double maxrange=-1.0, bool lazy_eval=false)
virtual bool castRay(const point3d &origin, const point3d &direction, point3d &end, bool ignoreUnknownCells=false, double maxRange=-1.0) const
std::istream & readBinaryNode(std::istream &s, NODE *node) const
virtual void updateNodeLogOdds(NODE *occupancyNode, const float &update) const
update logodds value of node by adding to the current value.
bool use_bbx_limit
use bounding box for queries (needs to be set)?
virtual void nodeToMaxLikelihood(NODE *occupancyNode) const
converts the node to the maximum likelihood value according to the tree&#39;s parameter for "occupancy" ...
OCTOMAP_DEPRECATED(virtual void insertScan(const Pointcloud &scan, const point3d &sensor_origin, const pose6d &frame_origin, double maxrange=-1., bool pruning=true, bool lazy_eval=false))
virtual void insertPointCloudRays(const Pointcloud &scan, const point3d &sensor_origin, double maxrange=-1., bool lazy_eval=false)
unordered_ns::unordered_set< OcTreeKey, OcTreeKey::KeyHash > KeySet
Definition: OcTreeKey.h:114
NODE * setNodeValueRecurs(NODE *node, bool node_just_created, const OcTreeKey &key, unsigned int depth, const float &log_odds_value, bool lazy_eval=false)
This class represents a tree-dimensional pose of an object.
Definition: Pose6D.h:49
point3d getBBXCenter() const
bool getNormals(const point3d &point, std::vector< point3d > &normals, bool unknownStatus=true) const
void useBBXLimit(bool enable)
use or ignore BBX limit (default: ignore)
NODE * updateNodeRecurs(NODE *node, bool node_just_created, const OcTreeKey &key, unsigned int depth, const float &log_odds_update, bool lazy_eval=false)
This class represents a three-dimensional vector.
Definition: Vector3.h:50
void setBBXMin(point3d &min)
sets the minimum for a query bounding box to use
virtual void toMaxLikelihood()
KeyBoolMap::const_iterator changedKeysBegin() const
void computeUpdate(const Pointcloud &scan, const octomap::point3d &origin, KeySet &free_cells, KeySet &occupied_cells, double maxrange)
KeyBoolMap changed_keys
Set of leaf keys (lowest level) which changed since last resetChangeDetection.
void resetChangeDetection()
Reset the set of changed keys. Call this after you obtained all changed nodes.
virtual bool getRayIntersection(const point3d &origin, const point3d &direction, const point3d &center, point3d &intersection, double delta=0.0) const
void enableChangeDetection(bool enable)
track or ignore changes while inserting scans (default: ignore)
void toMaxLikelihoodRecurs(NODE *node, unsigned int depth, unsigned int max_depth)
point3d getBBXBounds() const
virtual void integrateMiss(NODE *occupancyNode) const
integrate a "miss" measurement according to the tree&#39;s sensor model
KeyBoolMap::const_iterator changedKeysEnd() const
Iterator to traverse all keys of changed nodes.


octomap
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Fri Mar 25 2016 03:52:54