diff --git a/CMakeLists.txt b/CMakeLists.txt index 00bb66b9..7ca3efce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/include/octomap/OccupancyOcTreeBase.h b/include/octomap/OccupancyOcTreeBase.h index 5b6d2157..35761604 100644 --- a/include/octomap/OccupancyOcTreeBase.h +++ b/include/octomap/OccupancyOcTreeBase.h @@ -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); @@ -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) @@ -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; diff --git a/include/octomap/OccupancyOcTreeBase.hxx b/include/octomap/OccupancyOcTreeBase.hxx index ccf3a165..8d70de95 100644 --- a/include/octomap/OccupancyOcTreeBase.hxx +++ b/include/octomap/OccupancyOcTreeBase.hxx @@ -45,7 +45,7 @@ namespace octomap { template OccupancyOcTreeBase::OccupancyOcTreeBase(double _resolution) - : OcTreeBase(_resolution), use_bbx_limit(false) + : OcTreeBase(_resolution), use_bbx_limit(false), use_change_detection(false) { // some sane default values: setOccupancyThres(0.5); // = 0.0 in logodds @@ -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 NODE* OccupancyOcTreeBase::updateNodeRecurs(NODE* node, bool node_just_created, const OcTreeKey& key, unsigned int depth, @@ -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; } diff --git a/octomap.dox b/octomap.dox.in similarity index 99% rename from octomap.dox rename to octomap.dox.in index ac74ebc0..583a1c4d 100644 --- a/octomap.dox +++ b/octomap.dox.in @@ -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.