Skip to content

Commit

Permalink
- "make dist" target to build source packages
Browse files Browse the repository at this point in the history
- change detection in OccupancyOcTreeBase
  • Loading branch information
Armin Hornung committed Jul 27, 2011
1 parent 837116a commit a8957f6
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,23 @@ install_pkg_config_file(octomap
# Documentation
FIND_PACKAGE(Doxygen)
IF(DOXYGEN_FOUND)
ADD_CUSTOM_TARGET(docs ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/octomap.dox
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/octomap.dox.in ${CMAKE_CURRENT_BINARY_DIR}/octomap.dox @ONLY)
ADD_CUSTOM_TARGET(docs ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/octomap.dox
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating documentation (Doxygen)...")
ENDIF(DOXYGEN_FOUND)

# make package release from source
SET(OCTOMAP_PKG_NAME "${PROJECT_NAME}-${OCTOMAP_VERSION}.tar.gz")
ADD_CUSTOM_TARGET(dist
rm -rf "${CMAKE_BINARY_DIR}/dist" "${CMAKE_BINARY_DIR}/${OCTOMAP_PKG_NAME}"
COMMAND mkdir "${CMAKE_BINARY_DIR}/dist"
COMMAND svn export --force -q "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/dist/${PROJECT_NAME}"
COMMAND tar -czf "${CMAKE_BINARY_DIR}/${OCTOMAP_PKG_NAME}" -C "${CMAKE_BINARY_DIR}/dist" --exclude=".hidden" "${PROJECT_NAME}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)


# Build viewer if available:
INCLUDE(CMakeModules/BuildGLViewer.cmake)

Expand Down
14 changes: 12 additions & 2 deletions include/octomap/OccupancyOcTreeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ namespace octomap {
//-- set BBX limit (limits tree updates to this bounding box

/// use or ignore BBX limit (default: ignore)
void useBBXLimit(bool limit) { use_bbx_limit = limit; }
void useBBXLimit(bool enable) { use_bbx_limit = enable; }
bool bbxSet() const { return use_bbx_limit; }
/// sets the minimum for a query bounding box to use
void setBBXMin (point3d& min);
Expand All @@ -279,6 +279,15 @@ namespace octomap {
/// @return true if key is in the currently set bounding box
bool inBBX(const OcTreeKey& key) const;

//-- change detection on occupancy:
/// track or ignore changes while inserting scans (default: ignore)
void enableChangeDetection(bool enable) { use_change_detection = enable; }
/// Reset the set of changed keys. Call this after you obtained all changed nodes.
void resetChangeSet(){changedKeys.clear();}

KeySet::const_iterator changedKeysBegin() {return changedKeys.begin();}
KeySet::const_iterator changedKeysEnd() {return changedKeys.end();}

//-- parameters for occupancy and sensor model:

/// sets the threshold for occupancy (sensor model)
Expand Down Expand Up @@ -430,13 +439,14 @@ namespace octomap {


protected:
bool use_change_detection;
bool use_bbx_limit; ///< use bounding box for queries (needs to be set)?
point3d bbx_min;
point3d bbx_max;
OcTreeKey bbx_min_key;
OcTreeKey bbx_max_key;

bool use_change_detection;
KeySet changedKeys;
// occupancy parameters of tree, stored in logodds:
float clampingThresMin;
float clampingThresMax;
Expand Down
30 changes: 26 additions & 4 deletions include/octomap/OccupancyOcTreeBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace octomap {

template <class NODE>
OccupancyOcTreeBase<NODE>::OccupancyOcTreeBase(double _resolution)
: OcTreeBase<NODE>(_resolution), use_bbx_limit(false)
: OcTreeBase<NODE>(_resolution), use_bbx_limit(false), use_change_detection(false)
{
// some sane default values:
setOccupancyThres(0.5); // = 0.0 in logodds
Expand Down Expand Up @@ -235,7 +235,7 @@ namespace octomap {
return updateNodeRecurs(this->itsRoot, false, key, 0, log_odds_update, dirty);
}


// TODO: use only one update function (log odds, change "occupied" flag into LO before update)
template <class NODE>
NODE* OccupancyOcTreeBase<NODE>::updateNodeRecurs(NODE* node, bool node_just_created,
const OcTreeKey& key, unsigned int depth,
Expand Down Expand Up @@ -279,8 +279,30 @@ namespace octomap {

// at last level, update node, end of recursion
else {
if (occupied) integrateHit(node);
else integrateMiss(node);
if (use_change_detection){
bool occBefore = isNodeOccupied(node);

if (occupied)
integrateHit(node);
else
integrateMiss(node);

if (occBefore != isNodeOccupied(node)){ // occupancy changed, track it
KeySet::iterator it = changedKeys.find(key);
if(it == changedKeys.end()){
changedKeys.insert(key);
} else{
changedKeys.erase(it);
}
}
} else{


if (occupied)
integrateHit(node);
else
integrateMiss(node);
}

return node;
}
Expand Down
2 changes: 1 addition & 1 deletion octomap.dox → octomap.dox.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PROJECT_NAME = "octomap"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER =
PROJECT_NUMBER = @OCTOMAP_VERSION@

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Expand Down

0 comments on commit a8957f6

Please sign in to comment.