octomap  1.9.7
octomap::AbstractOccupancyOcTree Class Referenceabstract

Interface class for all octree types that store occupancy. More...

+ Inheritance diagram for octomap::AbstractOccupancyOcTree:
+ Collaboration diagram for octomap::AbstractOccupancyOcTree:

Public Member Functions

 AbstractOccupancyOcTree ()
 
virtual void clear ()=0
 
virtual AbstractOcTreecreate () const =0
 virtual constructor: creates a new object of same type More...
 
virtual void expand ()=0
 
double getClampingThresMax () const
 
float getClampingThresMaxLog () const
 
double getClampingThresMin () const
 
float getClampingThresMinLog () const
 
virtual void getMetricMax (double &x, double &y, double &z) const =0
 
virtual void getMetricMax (double &x, double &y, double &z)=0
 
virtual void getMetricMin (double &x, double &y, double &z) const =0
 
virtual void getMetricMin (double &x, double &y, double &z)=0
 
virtual void getMetricSize (double &x, double &y, double &z)=0
 
double getOccupancyThres () const
 
float getOccupancyThresLog () const
 
double getProbHit () const
 
float getProbHitLog () const
 
double getProbMiss () const
 
float getProbMissLog () const
 
virtual double getResolution () const =0
 
virtual std::string getTreeType () const =0
 returns actual class name as string for identification More...
 
bool isNodeAtThreshold (const OcTreeNode &occupancyNode) const
 queries whether a node is at the clamping threshold according to the tree's parameter More...
 
bool isNodeAtThreshold (const OcTreeNode *occupancyNode) const
 queries whether a node is at the clamping threshold according to the tree's parameter More...
 
bool isNodeOccupied (const OcTreeNode &occupancyNode) const
 queries whether a node is occupied according to the tree's parameter for "occupancy" More...
 
bool isNodeOccupied (const OcTreeNode *occupancyNode) const
 queries whether a node is occupied according to the tree's parameter for "occupancy" More...
 
virtual size_t memoryUsage () const =0
 
virtual size_t memoryUsageNode () const =0
 
virtual void prune ()=0
 
bool readBinary (const std::string &filename)
 Reads OcTree from a binary file. More...
 
bool readBinary (std::istream &s)
 Reads an OcTree from an input stream. More...
 
virtual std::istream & readBinaryData (std::istream &s)=0
 Reads the actual data, implemented in OccupancyOcTreeBase::readBinaryData() More...
 
virtual std::istream & readData (std::istream &s)=0
 Read all nodes from the input stream (without file header), for this the tree needs to be already created. More...
 
void setClampingThresMax (double thresProb)
 sets the maximum threshold for occupancy clamping (sensor model) More...
 
void setClampingThresMin (double thresProb)
 sets the minimum threshold for occupancy clamping (sensor model) More...
 
void setOccupancyThres (double prob)
 sets the threshold for occupancy (sensor model) More...
 
void setProbHit (double prob)
 sets the probability for a "hit" (will be converted to logodds) - sensor model More...
 
void setProbMiss (double prob)
 sets the probability for a "miss" (will be converted to logodds) - sensor model More...
 
virtual void setResolution (double res)=0
 
virtual size_t size () const =0
 
virtual void toMaxLikelihood ()=0
 
virtual OcTreeNodeupdateNode (const OcTreeKey &key, bool occupied, bool lazy_eval=false)=0
 Integrate occupancy measurement. More...
 
virtual OcTreeNodeupdateNode (const OcTreeKey &key, float log_odds_update, bool lazy_eval=false)=0
 Manipulate log_odds value of voxel directly. More...
 
virtual OcTreeNodeupdateNode (const point3d &value, bool occupied, bool lazy_eval=false)=0
 Integrate occupancy measurement. More...
 
virtual OcTreeNodeupdateNode (const point3d &value, float log_odds_update, bool lazy_eval=false)=0
 Manipulate log_odds value of voxel directly. More...
 
bool write (const std::string &filename) const
 Write file header and complete tree to file (serialization) More...
 
bool write (std::ostream &s) const
 Write file header and complete tree to stream (serialization) More...
 
bool writeBinary (const std::string &filename)
 Writes OcTree to a binary file using writeBinary(). More...
 
bool writeBinary (std::ostream &s)
 Writes compressed maximum likelihood OcTree to a binary stream. More...
 
bool writeBinaryConst (const std::string &filename) const
 Writes OcTree to a binary file using writeBinaryConst(). More...
 
bool writeBinaryConst (std::ostream &s) const
 Writes the maximum likelihood OcTree to a binary stream (const variant). More...
 
virtual std::ostream & writeBinaryData (std::ostream &s) const =0
 Writes the actual data, implemented in OccupancyOcTreeBase::writeBinaryData() More...
 
virtual std::ostream & writeData (std::ostream &s) const =0
 Write complete state of tree to stream (without file header) unmodified. Pruning the tree first produces smaller files (lossless compression) More...
 
virtual ~AbstractOccupancyOcTree ()
 

Static Public Member Functions

static AbstractOcTreecreateTree (const std::string id, double res)
 Creates a certain OcTree (factory pattern) More...
 
static AbstractOcTreeread (const std::string &filename)
 Read the file header, create the appropriate class and deserialize. More...
 
static AbstractOcTreeread (std::istream &s)
 Read the file header, create the appropriate class and deserialize. This creates a new octree which you need to delete yourself. More...
 

Protected Member Functions

bool readBinaryLegacyHeader (std::istream &s, unsigned int &size, double &res)
 Try to read the old binary format for conversion, will be removed in the future. More...
 

Static Protected Member Functions

static bool readHeader (std::istream &s, std::string &id, unsigned &size, double &res)
 
static void registerTreeType (AbstractOcTree *tree)
 

Protected Attributes

float clamping_thres_max
 
float clamping_thres_min
 
float occ_prob_thres_log
 
float prob_hit_log
 
float prob_miss_log
 

Static Protected Attributes

static const std::string binaryFileHeader = "# Octomap OcTree binary file"
 
static const std::string fileHeader = "# Octomap OcTree file"
 

Detailed Description

Interface class for all octree types that store occupancy.

This serves as a common base class e.g. for polymorphism and contains common code for reading and writing binary trees.

Constructor & Destructor Documentation

◆ AbstractOccupancyOcTree()

octomap::AbstractOccupancyOcTree::AbstractOccupancyOcTree ( )

◆ ~AbstractOccupancyOcTree()

virtual octomap::AbstractOccupancyOcTree::~AbstractOccupancyOcTree ( )
inlinevirtual

Member Function Documentation

◆ clear()

◆ create()

virtual AbstractOcTree* octomap::AbstractOcTree::create ( ) const
pure virtualinherited

virtual constructor: creates a new object of same type

Implemented in octomap::ColorOcTree, octomap::OcTreeStamped, octomap::OcTree, and octomap::OcTreeBase< NODE >.

◆ createTree()

AbstractOcTree * octomap::AbstractOcTree::createTree ( const std::string  id,
double  res 
)
staticinherited

Creates a certain OcTree (factory pattern)

Parameters
idunique ID of OcTree
resresolution of OcTree
Returns
pointer to newly created OcTree (empty). NULL if the ID is unknown!

References OCTOMAP_ERROR, and octomap::AbstractOcTree::setResolution().

Referenced by octomap::AbstractOcTree::read().

◆ expand()

◆ getClampingThresMax()

double octomap::AbstractOccupancyOcTree::getClampingThresMax ( ) const
inline
Returns
maximum threshold for occupancy clamping in the sensor model (probability)

References clamping_thres_max, and octomap::probability().

Referenced by main().

◆ getClampingThresMaxLog()

float octomap::AbstractOccupancyOcTree::getClampingThresMaxLog ( ) const
inline
Returns
maximum threshold for occupancy clamping in the sensor model (logodds)

References clamping_thres_max.

◆ getClampingThresMin()

double octomap::AbstractOccupancyOcTree::getClampingThresMin ( ) const
inline
Returns
minimum threshold for occupancy clamping in the sensor model (probability)

References clamping_thres_min, and octomap::probability().

Referenced by main().

◆ getClampingThresMinLog()

float octomap::AbstractOccupancyOcTree::getClampingThresMinLog ( ) const
inline
Returns
minimum threshold for occupancy clamping in the sensor model (logodds)

References clamping_thres_min.

◆ getMetricMax() [1/2]

◆ getMetricMax() [2/2]

◆ getMetricMin() [1/2]

◆ getMetricMin() [2/2]

◆ getMetricSize()

◆ getOccupancyThres()

double octomap::AbstractOccupancyOcTree::getOccupancyThres ( ) const
inline
Returns
threshold (probability) for occupancy - sensor model

References occ_prob_thres_log, and octomap::probability().

◆ getOccupancyThresLog()

float octomap::AbstractOccupancyOcTree::getOccupancyThresLog ( ) const
inline
Returns
threshold (logodds) for occupancy - sensor model

References occ_prob_thres_log.

◆ getProbHit()

double octomap::AbstractOccupancyOcTree::getProbHit ( ) const
inline
Returns
probability for a "hit" in the sensor model (probability)

References prob_hit_log, and octomap::probability().

Referenced by main().

◆ getProbHitLog()

float octomap::AbstractOccupancyOcTree::getProbHitLog ( ) const
inline
Returns
probability for a "hit" in the sensor model (logodds)

References prob_hit_log.

◆ getProbMiss()

double octomap::AbstractOccupancyOcTree::getProbMiss ( ) const
inline
Returns
probability for a "miss" in the sensor model (probability)

References prob_miss_log, and octomap::probability().

Referenced by main().

◆ getProbMissLog()

float octomap::AbstractOccupancyOcTree::getProbMissLog ( ) const
inline
Returns
probability for a "miss" in the sensor model (logodds)

References prob_miss_log.

◆ getResolution()

virtual double octomap::AbstractOcTree::getResolution ( ) const
pure virtualinherited

◆ getTreeType()

virtual std::string octomap::AbstractOcTree::getTreeType ( ) const
pure virtualinherited

◆ isNodeAtThreshold() [1/2]

bool octomap::AbstractOccupancyOcTree::isNodeAtThreshold ( const OcTreeNode occupancyNode) const
inline

queries whether a node is at the clamping threshold according to the tree's parameter

References octomap::OcTreeNode::getLogOdds().

◆ isNodeAtThreshold() [2/2]

bool octomap::AbstractOccupancyOcTree::isNodeAtThreshold ( const OcTreeNode occupancyNode) const
inline

queries whether a node is at the clamping threshold according to the tree's parameter

References octomap::OcTreeNode::getLogOdds().

Referenced by calcThresholdedNodes().

◆ isNodeOccupied() [1/2]

bool octomap::AbstractOccupancyOcTree::isNodeOccupied ( const OcTreeNode occupancyNode) const
inline

queries whether a node is occupied according to the tree's parameter for "occupancy"

References octomap::OcTreeNode::getLogOdds().

◆ isNodeOccupied() [2/2]

bool octomap::AbstractOccupancyOcTree::isNodeOccupied ( const OcTreeNode occupancyNode) const
inline

queries whether a node is occupied according to the tree's parameter for "occupancy"

References octomap::OcTreeNode::getLogOdds().

Referenced by octomap::OcTreeStamped::degradeOutdatedNodes(), getLeafNodesRecurs(), main(), and printChanges().

◆ memoryUsage()

virtual size_t octomap::AbstractOcTree::memoryUsage ( ) const
pure virtualinherited

◆ memoryUsageNode()

virtual size_t octomap::AbstractOcTree::memoryUsageNode ( ) const
pure virtualinherited

◆ prune()

◆ read() [1/2]

AbstractOcTree * octomap::AbstractOcTree::read ( const std::string &  filename)
staticinherited

Read the file header, create the appropriate class and deserialize.

This creates a new octree which you need to delete yourself. If you expect or requre a specific kind of octree, use dynamic_cast afterwards:

AbstractOcTree* tree = AbstractOcTree::read("filename.ot");
OcTree* octree = dynamic_cast<OcTree*>(tree);

References OCTOMAP_ERROR_STR.

◆ read() [2/2]

AbstractOcTree * octomap::AbstractOcTree::read ( std::istream &  s)
staticinherited

Read the file header, create the appropriate class and deserialize. This creates a new octree which you need to delete yourself.

References octomap::AbstractOcTree::createTree(), octomap::AbstractOcTree::fileHeader, OCTOMAP_DEBUG_STR, OCTOMAP_ERROR_STR, octomap::AbstractOcTree::readData(), octomap::AbstractOcTree::readHeader(), and octomap::AbstractOcTree::size().

◆ readBinary() [1/2]

bool octomap::AbstractOccupancyOcTree::readBinary ( const std::string &  filename)

Reads OcTree from a binary file.

Existing nodes of the tree are deleted before the tree is read.

Returns
success of operation

References OCTOMAP_ERROR_STR, and readBinary().

◆ readBinary() [2/2]

bool octomap::AbstractOccupancyOcTree::readBinary ( std::istream &  s)

◆ readBinaryData()

virtual std::istream& octomap::AbstractOccupancyOcTree::readBinaryData ( std::istream &  s)
pure virtual

◆ readBinaryLegacyHeader()

bool octomap::AbstractOccupancyOcTree::readBinaryLegacyHeader ( std::istream &  s,
unsigned int &  size,
double &  res 
)
protected

Try to read the old binary format for conversion, will be removed in the future.

References octomap::AbstractOcTree::clear(), OCTOMAP_ERROR, OCTOMAP_ERROR_STR, OCTOMAP_WARNING_STR, and octomap::AbstractOcTree::size().

Referenced by readBinary().

◆ readData()

virtual std::istream& octomap::AbstractOcTree::readData ( std::istream &  s)
pure virtualinherited

◆ readHeader()

bool octomap::AbstractOcTree::readHeader ( std::istream &  s,
std::string &  id,
unsigned &  size,
double &  res 
)
staticprotectedinherited

◆ registerTreeType()

◆ setClampingThresMax()

void octomap::AbstractOccupancyOcTree::setClampingThresMax ( double  thresProb)
inline

sets the maximum threshold for occupancy clamping (sensor model)

References clamping_thres_max, and octomap::logodds().

Referenced by AbstractOccupancyOcTree(), and main().

◆ setClampingThresMin()

void octomap::AbstractOccupancyOcTree::setClampingThresMin ( double  thresProb)
inline

sets the minimum threshold for occupancy clamping (sensor model)

References clamping_thres_min, and octomap::logodds().

Referenced by AbstractOccupancyOcTree(), and main().

◆ setOccupancyThres()

void octomap::AbstractOccupancyOcTree::setOccupancyThres ( double  prob)
inline

sets the threshold for occupancy (sensor model)

References octomap::logodds(), and occ_prob_thres_log.

Referenced by AbstractOccupancyOcTree().

◆ setProbHit()

void octomap::AbstractOccupancyOcTree::setProbHit ( double  prob)
inline

sets the probability for a "hit" (will be converted to logodds) - sensor model

References octomap::logodds(), and prob_hit_log.

Referenced by AbstractOccupancyOcTree(), and main().

◆ setProbMiss()

void octomap::AbstractOccupancyOcTree::setProbMiss ( double  prob)
inline

sets the probability for a "miss" (will be converted to logodds) - sensor model

References octomap::logodds(), and prob_miss_log.

Referenced by AbstractOccupancyOcTree(), and main().

◆ setResolution()

◆ size()

virtual size_t octomap::AbstractOcTree::size ( ) const
pure virtualinherited

◆ toMaxLikelihood()

◆ updateNode() [1/4]

virtual OcTreeNode* octomap::AbstractOccupancyOcTree::updateNode ( const OcTreeKey key,
bool  occupied,
bool  lazy_eval = false 
)
pure virtual

Integrate occupancy measurement.

Parameters
keyof the NODE that is to be updated
occupiedtrue if the node was measured occupied, else false
lazy_evalwhether update of inner nodes is omitted after the update (default: false). This speeds up the insertion, but you need to call updateInnerOccupancy() when done.
Returns
pointer to the updated NODE

Implemented in octomap::OccupancyOcTreeBase< NODE >, octomap::OccupancyOcTreeBase< ColorOcTreeNode >, octomap::OccupancyOcTreeBase< OcTreeNode >, and octomap::OccupancyOcTreeBase< OcTreeNodeStamped >.

◆ updateNode() [2/4]

virtual OcTreeNode* octomap::AbstractOccupancyOcTree::updateNode ( const OcTreeKey key,
float  log_odds_update,
bool  lazy_eval = false 
)
pure virtual

Manipulate log_odds value of voxel directly.

Parameters
keyof the NODE that is to be updated
log_odds_updatevalue to be added (+) to log_odds value of node
lazy_evalwhether update of inner nodes is omitted after the update (default: false). This speeds up the insertion, but you need to call updateInnerOccupancy() when done.
Returns
pointer to the updated NODE

Implemented in octomap::OccupancyOcTreeBase< NODE >, octomap::OccupancyOcTreeBase< ColorOcTreeNode >, octomap::OccupancyOcTreeBase< OcTreeNode >, and octomap::OccupancyOcTreeBase< OcTreeNodeStamped >.

◆ updateNode() [3/4]

virtual OcTreeNode* octomap::AbstractOccupancyOcTree::updateNode ( const point3d value,
bool  occupied,
bool  lazy_eval = false 
)
pure virtual

Integrate occupancy measurement.

Looks up the OcTreeKey corresponding to the coordinate and then calls udpateNode() with it.

Parameters
value3d coordinate of the NODE that is to be updated
occupiedtrue if the node was measured occupied, else false
lazy_evalwhether update of inner nodes is omitted after the update (default: false). This speeds up the insertion, but you need to call updateInnerOccupancy() when done.
Returns
pointer to the updated NODE

Implemented in octomap::OccupancyOcTreeBase< NODE >, octomap::OccupancyOcTreeBase< ColorOcTreeNode >, octomap::OccupancyOcTreeBase< OcTreeNode >, and octomap::OccupancyOcTreeBase< OcTreeNodeStamped >.

◆ updateNode() [4/4]

virtual OcTreeNode* octomap::AbstractOccupancyOcTree::updateNode ( const point3d value,
float  log_odds_update,
bool  lazy_eval = false 
)
pure virtual

Manipulate log_odds value of voxel directly.

Looks up the OcTreeKey corresponding to the coordinate and then calls udpateNode() with it.

Parameters
value3d coordinate of the NODE that is to be updated
log_odds_updatevalue to be added (+) to log_odds value of node
lazy_evalwhether update of inner nodes is omitted after the update (default: false). This speeds up the insertion, but you need to call updateInnerOccupancy() when done.
Returns
pointer to the updated NODE

Implemented in octomap::OccupancyOcTreeBase< NODE >, octomap::OccupancyOcTreeBase< ColorOcTreeNode >, octomap::OccupancyOcTreeBase< OcTreeNode >, and octomap::OccupancyOcTreeBase< OcTreeNodeStamped >.

◆ write() [1/2]

bool octomap::AbstractOcTree::write ( const std::string &  filename) const
inherited

Write file header and complete tree to file (serialization)

References OCTOMAP_ERROR_STR.

Referenced by main().

◆ write() [2/2]

bool octomap::AbstractOcTree::write ( std::ostream &  s) const
inherited

◆ writeBinary() [1/2]

bool octomap::AbstractOccupancyOcTree::writeBinary ( const std::string &  filename)

Writes OcTree to a binary file using writeBinary().

The OcTree is first converted to the maximum likelihood estimate and pruned.

Returns
success of operation

References OCTOMAP_ERROR_STR.

Referenced by main().

◆ writeBinary() [2/2]

bool octomap::AbstractOccupancyOcTree::writeBinary ( std::ostream &  s)

Writes compressed maximum likelihood OcTree to a binary stream.

The OcTree is first converted to the maximum likelihood estimate and pruned for maximum compression.

Returns
success of operation

References octomap::AbstractOcTree::prune(), toMaxLikelihood(), and writeBinaryConst().

◆ writeBinaryConst() [1/2]

bool octomap::AbstractOccupancyOcTree::writeBinaryConst ( const std::string &  filename) const

Writes OcTree to a binary file using writeBinaryConst().

The OcTree is not changed, in particular not pruned first. Files will be smaller when the tree is pruned first or by using writeBinary() instead.

Returns
success of operation

References OCTOMAP_ERROR_STR.

Referenced by writeBinary().

◆ writeBinaryConst() [2/2]

bool octomap::AbstractOccupancyOcTree::writeBinaryConst ( std::ostream &  s) const

Writes the maximum likelihood OcTree to a binary stream (const variant).

Files will be smaller when the tree is pruned first or by using writeBinary() instead.

Returns
success of operation

References binaryFileHeader, octomap::AbstractOcTree::getResolution(), octomap::AbstractOcTree::getTreeType(), OCTOMAP_DEBUG, OCTOMAP_WARNING_STR, octomap::AbstractOcTree::size(), and writeBinaryData().

◆ writeBinaryData()

virtual std::ostream& octomap::AbstractOccupancyOcTree::writeBinaryData ( std::ostream &  s) const
pure virtual

◆ writeData()

virtual std::ostream& octomap::AbstractOcTree::writeData ( std::ostream &  s) const
pure virtualinherited

Field Documentation

◆ binaryFileHeader

const std::string octomap::AbstractOccupancyOcTree::binaryFileHeader = "# Octomap OcTree binary file"
staticprotected

Referenced by readBinary(), and writeBinaryConst().

◆ clamping_thres_max

float octomap::AbstractOccupancyOcTree::clamping_thres_max
protected

◆ clamping_thres_min

float octomap::AbstractOccupancyOcTree::clamping_thres_min
protected

◆ fileHeader

const std::string octomap::AbstractOcTree::fileHeader = "# Octomap OcTree file"
staticprotectedinherited

◆ occ_prob_thres_log

float octomap::AbstractOccupancyOcTree::occ_prob_thres_log
protected

◆ prob_hit_log

float octomap::AbstractOccupancyOcTree::prob_hit_log
protected

◆ prob_miss_log


The documentation for this class was generated from the following files:
octomap::AbstractOcTree::AbstractOcTree
AbstractOcTree()
Definition: AbstractOcTree.cpp:41
octomap::AbstractOcTree::read
static AbstractOcTree * read(const std::string &filename)
Read the file header, create the appropriate class and deserialize.
Definition: AbstractOcTree.cpp:74