From 082493135cd2c546fe37f1cc3806af80ba2c161c Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Tue, 29 Dec 2015 22:32:20 +0100 Subject: [PATCH 01/17] Extending hint for deriving node classes (#93) --- octomap/include/octomap/OcTreeNode.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/octomap/include/octomap/OcTreeNode.h b/octomap/include/octomap/OcTreeNode.h index 2be7c1df..4236765d 100644 --- a/octomap/include/octomap/OcTreeNode.h +++ b/octomap/include/octomap/OcTreeNode.h @@ -45,8 +45,11 @@ namespace octomap { * Nodes to be used in OcTree. They represent 3d occupancy grid cells. * "value" stores their log-odds occupancy. * - * Hint: If a class is derived from OcTreeNode, you have to implement (at least) - * createChild, getChild, and getChild const. See OcTreeNodeLabeled for an example. + * Note: If you derive a class (directly or indirectly) from OcTreeNode or + * OcTreeDataNode, you have to implement (at least) the following functions: + * createChild(), getChild(), getChild() const, expandNode() to avoid slicing + * errors and memory-related bugs. + * See ColorOcTreeNode in ColorOcTree.h for an example. * */ class OcTreeNode : public OcTreeDataNode { From d2f89479ac258bbea9dd43e827bc42af35fe68b0 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Tue, 29 Dec 2015 22:35:37 +0100 Subject: [PATCH 02/17] Extending hint for deriving node classes (#93) --- octomap/include/octomap/OcTreeDataNode.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/octomap/include/octomap/OcTreeDataNode.h b/octomap/include/octomap/OcTreeDataNode.h index 8ff6c530..ea208acd 100644 --- a/octomap/include/octomap/OcTreeDataNode.h +++ b/octomap/include/octomap/OcTreeDataNode.h @@ -51,7 +51,12 @@ namespace octomap { * This is the base class for nodes used in an OcTree. The used implementation * for occupancy mapping is in OcTreeNode.# * \tparam T data to be stored in the node (e.g. a float for probabilities) - * + * + * Note: If you derive a class (directly or indirectly) from OcTreeDataNode, + * you have to implement (at least) the following functions to avoid slicing + * errors and memory-related bugs: + * createChild(), getChild(), getChild() const, expandNode() + * See ColorOcTreeNode in ColorOcTree.h for an example. */ template class OcTreeDataNode: public AbstractOcTreeNode { From 214636d5098b3bf078679f23ad96c349f4b5c1b2 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Wed, 30 Dec 2015 21:40:58 +0100 Subject: [PATCH 03/17] Fixing #82: Enable uninstall target for complete project, not only octomap Also suppresses a CMake warning during uninstall --- octomap/CMakeLists.txt | 1 - octomap/CMakeModules/CMakeUninstall.cmake.in | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/octomap/CMakeLists.txt b/octomap/CMakeLists.txt index 026bf5a5..4c228330 100644 --- a/octomap/CMakeLists.txt +++ b/octomap/CMakeLists.txt @@ -69,7 +69,6 @@ configure_file( add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) - # Export the package for use from the build-tree # (this registers the build-tree with a global CMake-registry) export(PACKAGE octomap) diff --git a/octomap/CMakeModules/CMakeUninstall.cmake.in b/octomap/CMakeModules/CMakeUninstall.cmake.in index c6d80941..af4c1499 100644 --- a/octomap/CMakeModules/CMakeUninstall.cmake.in +++ b/octomap/CMakeModules/CMakeUninstall.cmake.in @@ -1,8 +1,11 @@ -if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") -endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +# Ignore empty list items. +cmake_policy(SET CMP0007 OLD) -file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +if (NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"") +endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") list(REVERSE files) foreach (file ${files}) From f5718066958fc81bec41b2a9d52fdb48f0108620 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Sat, 2 Jan 2016 15:18:08 +0100 Subject: [PATCH 04/17] Fixing #47: Exported CMake library paths for Windows Removes the Debug/Release path prefix and changes the exported library files to .lib --- dynamicEDT3D/CMakeLists.txt | 18 ++++++++++++++++ dynamicEDT3D/dynamicEDT3DConfig.cmake.in | 2 +- octomap/CMakeLists.txt | 27 +++++++++++++++++++----- octomap/octomap-config.cmake.in | 9 ++++---- octovis/CMakeLists.txt | 19 +++++++++++++++++ octovis/octovis-config.cmake.in | 2 +- 6 files changed, 65 insertions(+), 12 deletions(-) diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt index cfc312ed..82e66f45 100644 --- a/dynamicEDT3D/CMakeLists.txt +++ b/dynamicEDT3D/CMakeLists.txt @@ -25,6 +25,13 @@ SET( BASE_DIR ${CMAKE_SOURCE_DIR} ) SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BASE_DIR}/lib ) SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BASE_DIR}/lib ) SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BASE_DIR}/bin ) +# output dirs for multi-config builds (MSVC) +foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) + STRING( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) + SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/lib ) + SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/lib ) + SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/bin ) +endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include") INCLUDE_DIRECTORIES(${INCLUDE_DIRS}) @@ -73,6 +80,17 @@ export(PACKAGE dynamicEDT3D) # Create a dynamicEDT3DConfig.cmake file for the use from the build tree set(DYNAMICEDT3D_INCLUDE_DIRS "${INCLUDE_DIRS}") set(DYNAMICEDT3D_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +# Set library names as absolute paths +# Windows, spec. MSVC requires the .lib suffix for imported libs +IF(WIN32) + set(DYNAMICEDT3D_LIBRARIES + "@DYNAMICEDT3D_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@dynamicedt3d@CMAKE_IMPORT_LIBRARY_SUFFIX@" + ) +ELSE() + set(DYNAMICEDT3D_LIBRARIES + "@DYNAMICEDT3D_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@dynamicedt3d@CMAKE_SHARED_LIBRARY_SUFFIX@" + ) +ENDIF() # not used right now (export depends?) #set(DYNEDT3D_CMAKE_DIR "${PROJECT_BINARY_DIR}") configure_file(dynamicEDT3DConfig.cmake.in diff --git a/dynamicEDT3D/dynamicEDT3DConfig.cmake.in b/dynamicEDT3D/dynamicEDT3DConfig.cmake.in index b6a7d231..a21b2a89 100644 --- a/dynamicEDT3D/dynamicEDT3DConfig.cmake.in +++ b/dynamicEDT3D/dynamicEDT3DConfig.cmake.in @@ -21,5 +21,5 @@ set(DYNAMICEDT3D_LIBRARY_DIRS "@DYNAMICEDT3D_LIB_DIR@") # include("@FOOBAR_CMAKE_DIR@/FooBarLibraryDepends.cmake") set(DYNAMICEDT3D_LIBRARIES - "@DYNAMICEDT3D_LIB_DIR@/libdynamicedt3d@CMAKE_SHARED_LIBRARY_SUFFIX@" + @DYNAMICEDT3D_LIBRARIES@ ) diff --git a/octomap/CMakeLists.txt b/octomap/CMakeLists.txt index 4c228330..472f4b5f 100644 --- a/octomap/CMakeLists.txt +++ b/octomap/CMakeLists.txt @@ -35,6 +35,13 @@ SET( BASE_DIR ${CMAKE_SOURCE_DIR} ) SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BASE_DIR}/lib ) SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BASE_DIR}/lib ) SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BASE_DIR}/bin ) +# output dirs for multi-config builds (MSVC) +foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) + STRING( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) + SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/lib ) + SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/lib ) + SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/bin ) +endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include") INCLUDE_DIRECTORIES(${INCLUDE_DIRS}) @@ -76,6 +83,20 @@ export(PACKAGE octomap) # Create a octomap-config.cmake file for the use from the build tree set(OCTOMAP_INCLUDE_DIRS "${INCLUDE_DIRS}") set(OCTOMAP_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +# Set library names as absolute paths +# Windows, spec. MSVC requires the .lib suffix for imported libs +IF(WIN32) + set(OCTOMAP_LIBRARIES + "@OCTOMAP_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octomap@CMAKE_IMPORT_LIBRARY_SUFFIX@" + "@OCTOMAP_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octomath@CMAKE_IMPORT_LIBRARY_SUFFIX@" + ) +ELSE() + set(OCTOMAP_LIBRARIES + "@OCTOMAP_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octomap@CMAKE_SHARED_LIBRARY_SUFFIX@" + "@OCTOMAP_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octomath@CMAKE_SHARED_LIBRARY_SUFFIX@" + ) +ENDIF() + # not used right now (export depends?) #set(OCTOMAP_CMAKE_DIR "${PROJECT_BINARY_DIR}") configure_file(octomap-config.cmake.in @@ -83,11 +104,7 @@ configure_file(octomap-config.cmake.in configure_file(octomap-config-version.cmake.in "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-config-version.cmake" @ONLY) -# Install the export set for use with the install-tree -#install(EXPORT FooBarLibraryDepends DESTINATION -# "${INSTALL_DATA_DIR}/FooBar/CMake" -# COMPONENT dev) - + # Create a octomap-config.cmake file for the use from the install tree # and install it set(OCTOMAP_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include") diff --git a/octomap/octomap-config.cmake.in b/octomap/octomap-config.cmake.in index c93fd902..dc3a133e 100644 --- a/octomap/octomap-config.cmake.in +++ b/octomap/octomap-config.cmake.in @@ -27,8 +27,7 @@ set(OCTOMAP_INCLUDE_DIRS "@OCTOMAP_INCLUDE_DIRS@") set(OCTOMAP_LIBRARY_DIRS "@OCTOMAP_LIB_DIR@") -# Set library names as absolute paths: -set(OCTOMAP_LIBRARIES - "@OCTOMAP_LIB_DIR@/liboctomap@CMAKE_SHARED_LIBRARY_SUFFIX@" - "@OCTOMAP_LIB_DIR@/liboctomath@CMAKE_SHARED_LIBRARY_SUFFIX@" -) \ No newline at end of file +# Set library names +set(OCTOMAP_LIBRARIES + @OCTOMAP_LIBRARIES@ +) diff --git a/octovis/CMakeLists.txt b/octovis/CMakeLists.txt index db70854c..9f8f9caf 100644 --- a/octovis/CMakeLists.txt +++ b/octovis/CMakeLists.txt @@ -22,6 +22,13 @@ SET( BASE_DIR ${CMAKE_SOURCE_DIR} ) SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BASE_DIR}/lib ) SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BASE_DIR}/lib ) SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BASE_DIR}/bin ) +# output dirs for multi-config builds (MSVC) +foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) + STRING( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) + SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/lib ) + SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/lib ) + SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/bin ) +endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) # We need the main octomap library to link against (same version as octovis) # Look at parent directory by default, in case the complete distribution @@ -79,6 +86,18 @@ IF(BUILD_VIEWER) # Create an octovis-config.cmake file for the use from the build tree set(OCTOVIS_INCLUDE_DIR "${INCLUDE_DIRS}") set(OCTOVIS_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + # Set library names as absolute paths + # Windows, spec. MSVC requires the .lib suffix for imported libs + IF(WIN32) + set(OCTOVIS_LIBRARIES + "@OCTOVIS_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octovis@CMAKE_IMPORT_LIBRARY_SUFFIX@" + ) + ELSE() + set(OCTOVIS_LIBRARIES + "@OCTOVIS_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octovis@CMAKE_SHARED_LIBRARY_SUFFIX@" + ) + ENDIF() + # not used right now (export depends?) #set(OCTOMAP_CMAKE_DIR "${PROJECT_BINARY_DIR}") configure_file(octovis-config.cmake.in diff --git a/octovis/octovis-config.cmake.in b/octovis/octovis-config.cmake.in index b278a669..60930f4a 100644 --- a/octovis/octovis-config.cmake.in +++ b/octovis/octovis-config.cmake.in @@ -13,5 +13,5 @@ set(OCTOVIS_LIBRARY_DIRS "@QGLViewer_LIBRARY_DIR@" "@OCTOVIS_LIB_DIR@") set(OCTOVIS_LIBRARIES "@QGLViewer_LIBRARIES@" "@QT_LIBRARIES@" - "@OCTOVIS_LIB_DIR@/liboctovis@CMAKE_SHARED_LIBRARY_SUFFIX@" + @OCTOVIS_LIBRARIES@ ) From a8426d71e1b1826ffb345db8239ed2579edaa5c2 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Sat, 2 Jan 2016 23:39:02 +0100 Subject: [PATCH 05/17] Fixing generated CMake configs for paths with blanks after previous commit --- dynamicEDT3D/CMakeLists.txt | 8 ++++---- dynamicEDT3D/dynamicEDT3DConfig.cmake.in | 4 +--- octomap/CMakeLists.txt | 16 ++++++++++------ octomap/octomap-config.cmake.in | 3 ++- octovis/CMakeLists.txt | 8 ++++---- octovis/octovis-config.cmake.in | 2 +- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt index 82e66f45..d71c998a 100644 --- a/dynamicEDT3D/CMakeLists.txt +++ b/dynamicEDT3D/CMakeLists.txt @@ -83,12 +83,12 @@ set(DYNAMICEDT3D_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") # Set library names as absolute paths # Windows, spec. MSVC requires the .lib suffix for imported libs IF(WIN32) - set(DYNAMICEDT3D_LIBRARIES - "@DYNAMICEDT3D_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@dynamicedt3d@CMAKE_IMPORT_LIBRARY_SUFFIX@" + set(DYNAMICEDT3D_LIBRARY + @DYNAMICEDT3D_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@dynamicedt3d@CMAKE_IMPORT_LIBRARY_SUFFIX@ ) ELSE() - set(DYNAMICEDT3D_LIBRARIES - "@DYNAMICEDT3D_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@dynamicedt3d@CMAKE_SHARED_LIBRARY_SUFFIX@" + set(DYNAMICEDT3D_LIBRARY + @DYNAMICEDT3D_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@dynamicedt3d@CMAKE_SHARED_LIBRARY_SUFFIX@ ) ENDIF() # not used right now (export depends?) diff --git a/dynamicEDT3D/dynamicEDT3DConfig.cmake.in b/dynamicEDT3D/dynamicEDT3DConfig.cmake.in index a21b2a89..cc5fb4e5 100644 --- a/dynamicEDT3D/dynamicEDT3DConfig.cmake.in +++ b/dynamicEDT3D/dynamicEDT3DConfig.cmake.in @@ -20,6 +20,4 @@ set(DYNAMICEDT3D_LIBRARY_DIRS "@DYNAMICEDT3D_LIB_DIR@") # Our library dependencies (contains definitions for IMPORTED targets) # include("@FOOBAR_CMAKE_DIR@/FooBarLibraryDepends.cmake") -set(DYNAMICEDT3D_LIBRARIES - @DYNAMICEDT3D_LIBRARIES@ -) +set(DYNAMICEDT3D_LIBRARIES "@DYNAMICEDT3D_LIBRARY@") diff --git a/octomap/CMakeLists.txt b/octomap/CMakeLists.txt index 472f4b5f..db4b8928 100644 --- a/octomap/CMakeLists.txt +++ b/octomap/CMakeLists.txt @@ -86,14 +86,18 @@ set(OCTOMAP_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") # Set library names as absolute paths # Windows, spec. MSVC requires the .lib suffix for imported libs IF(WIN32) - set(OCTOMAP_LIBRARIES - "@OCTOMAP_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octomap@CMAKE_IMPORT_LIBRARY_SUFFIX@" - "@OCTOMAP_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octomath@CMAKE_IMPORT_LIBRARY_SUFFIX@" + set(OCTOMAP_LIBRARY + @OCTOMAP_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octomap@CMAKE_IMPORT_LIBRARY_SUFFIX@ + ) + set(OCTOMATH_LIBRARY + @OCTOMAP_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octomath@CMAKE_IMPORT_LIBRARY_SUFFIX@ ) ELSE() - set(OCTOMAP_LIBRARIES - "@OCTOMAP_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octomap@CMAKE_SHARED_LIBRARY_SUFFIX@" - "@OCTOMAP_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octomath@CMAKE_SHARED_LIBRARY_SUFFIX@" + set(OCTOMAP_LIBRARY + @OCTOMAP_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octomap@CMAKE_SHARED_LIBRARY_SUFFIX@ + ) + set(OCTOMATH_LIBRARY + @OCTOMAP_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octomath@CMAKE_SHARED_LIBRARY_SUFFIX@ ) ENDIF() diff --git a/octomap/octomap-config.cmake.in b/octomap/octomap-config.cmake.in index dc3a133e..9dd1f96a 100644 --- a/octomap/octomap-config.cmake.in +++ b/octomap/octomap-config.cmake.in @@ -29,5 +29,6 @@ set(OCTOMAP_LIBRARY_DIRS "@OCTOMAP_LIB_DIR@") # Set library names set(OCTOMAP_LIBRARIES - @OCTOMAP_LIBRARIES@ + "@OCTOMAP_LIBRARY@" + "@OCTOMATH_LIBRARY@" ) diff --git a/octovis/CMakeLists.txt b/octovis/CMakeLists.txt index 9f8f9caf..e3871807 100644 --- a/octovis/CMakeLists.txt +++ b/octovis/CMakeLists.txt @@ -89,12 +89,12 @@ IF(BUILD_VIEWER) # Set library names as absolute paths # Windows, spec. MSVC requires the .lib suffix for imported libs IF(WIN32) - set(OCTOVIS_LIBRARIES - "@OCTOVIS_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octovis@CMAKE_IMPORT_LIBRARY_SUFFIX@" + set(OCTOVIS_LIBRARY + @OCTOVIS_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octovis@CMAKE_IMPORT_LIBRARY_SUFFIX@ ) ELSE() - set(OCTOVIS_LIBRARIES - "@OCTOVIS_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octovis@CMAKE_SHARED_LIBRARY_SUFFIX@" + set(OCTOVIS_LIBRARY + @OCTOVIS_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octovis@CMAKE_SHARED_LIBRARY_SUFFIX@ ) ENDIF() diff --git a/octovis/octovis-config.cmake.in b/octovis/octovis-config.cmake.in index 60930f4a..3f7cc6ae 100644 --- a/octovis/octovis-config.cmake.in +++ b/octovis/octovis-config.cmake.in @@ -13,5 +13,5 @@ set(OCTOVIS_LIBRARY_DIRS "@QGLViewer_LIBRARY_DIR@" "@OCTOVIS_LIB_DIR@") set(OCTOVIS_LIBRARIES "@QGLViewer_LIBRARIES@" "@QT_LIBRARIES@" - @OCTOVIS_LIBRARIES@ + "@OCTOVIS_LIBRARY@" ) From 1a9cbb69d4ccceb73bcd9aa56979d296ddfa0a97 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Mon, 4 Jan 2016 13:38:17 +0100 Subject: [PATCH 06/17] size_t for size types instead of unsigned int Improved portability and fewer warning with MSVC (#100) --- octomap/include/octomap/OcTreeKey.h | 4 ++-- octomap/include/octomap/ScanGraph.h | 4 ++-- octomap/src/Pointcloud.cpp | 4 ++-- octomap/src/ScanGraph.cpp | 16 ++++++++-------- octomap/src/eval_octree_accuracy.cpp | 12 ++++++------ octomap/src/graph2tree.cpp | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/octomap/include/octomap/OcTreeKey.h b/octomap/include/octomap/OcTreeKey.h index ec5ab7dc..56269fdc 100644 --- a/octomap/include/octomap/OcTreeKey.h +++ b/octomap/include/octomap/OcTreeKey.h @@ -137,8 +137,8 @@ namespace octomap { end_of_ray++; } - unsigned int size() const { return end_of_ray - ray.begin(); } - unsigned int sizeMax() const { return 100000; } + size_t size() const { return end_of_ray - ray.begin(); } + size_t sizeMax() const { return 100000; } typedef std::vector::iterator iterator; typedef std::vector::const_iterator const_iterator; diff --git a/octomap/include/octomap/ScanGraph.h b/octomap/include/octomap/ScanGraph.h index 81970fd8..07c74360 100644 --- a/octomap/include/octomap/ScanGraph.h +++ b/octomap/include/octomap/ScanGraph.h @@ -177,8 +177,8 @@ namespace octomap { const_iterator begin() const { return nodes.begin(); } const_iterator end() const { return nodes.end(); } - unsigned int size() const { return nodes.size(); } - unsigned int getNumPoints(unsigned int max_id = -1) const; + size_t size() const { return nodes.size(); } + size_t getNumPoints(unsigned int max_id = -1) const; typedef std::vector::iterator edge_iterator; typedef std::vector::const_iterator const_edge_iterator; diff --git a/octomap/src/Pointcloud.cpp b/octomap/src/Pointcloud.cpp index bb6215c6..b78ca554 100644 --- a/octomap/src/Pointcloud.cpp +++ b/octomap/src/Pointcloud.cpp @@ -310,8 +310,8 @@ namespace octomap { std::ostream& Pointcloud::writeBinary(std::ostream &s) const { - unsigned int pc_size = this->size(); - OCTOMAP_DEBUG("Writing %d points to binary file...", pc_size); + size_t pc_size = this->size(); + OCTOMAP_DEBUG("Writing %lu points to binary file...", (unsigned long)pc_size); s.write((char*)&pc_size, sizeof(pc_size)); for (Pointcloud::const_iterator it = this->begin(); it != this->end(); it++) { diff --git a/octomap/src/ScanGraph.cpp b/octomap/src/ScanGraph.cpp index 52234513..64b4bf35 100644 --- a/octomap/src/ScanGraph.cpp +++ b/octomap/src/ScanGraph.cpp @@ -174,7 +174,7 @@ namespace octomap { ScanNode* ScanGraph::addNode(Pointcloud* scan, pose6d pose) { if (scan != 0) { - nodes.push_back(new ScanNode(scan, pose, nodes.size())); + nodes.push_back(new ScanNode(scan, pose, unsigned int(nodes.size()))); return nodes.back(); } else { @@ -326,8 +326,8 @@ namespace octomap { // file structure: n | node_1 | ... | node_n | m | edge_1 | ... | edge_m // write nodes --------------------------------- - unsigned int graph_size = this->size(); - if (graph_size) OCTOMAP_DEBUG("writing %d nodes to binary file...\n", graph_size); + size_t graph_size = this->size(); + if (graph_size) OCTOMAP_DEBUG("writing %lu nodes to binary file...\n", (unsigned long)graph_size); s.write((char*)&graph_size, sizeof(graph_size)); for (ScanGraph::const_iterator it = this->begin(); it != this->end(); it++) { @@ -337,8 +337,8 @@ namespace octomap { if (graph_size) OCTOMAP_DEBUG("done.\n"); // write edges --------------------------------- - unsigned int num_edges = this->edges.size(); - if (num_edges) OCTOMAP_DEBUG("writing %d edges to binary file...\n", num_edges); + size_t num_edges = this->edges.size(); + if (num_edges) OCTOMAP_DEBUG("writing %lu edges to binary file...\n", (unsigned long)num_edges); s.write((char*)&num_edges, sizeof(num_edges)); for (ScanGraph::const_edge_iterator it = this->edges_begin(); it != this->edges_end(); it++) { @@ -537,7 +537,7 @@ namespace octomap { std::ostream& ScanGraph::writeNodePosesASCII(std::ostream &s) const { - OCTOMAP_DEBUG("Writing %d node poses to ASCII file...\n", this->size()); + OCTOMAP_DEBUG("Writing %lu node poses to ASCII file...\n", (unsigned long) this->size()); for (ScanGraph::const_iterator it = this->begin(); it != this->end(); it++) { (*it)->writePoseASCII(s); @@ -603,8 +603,8 @@ namespace octomap { } } - unsigned int ScanGraph::getNumPoints(unsigned int max_id) const { - unsigned int retval = 0; + size_t ScanGraph::getNumPoints(unsigned int max_id) const { + size_t retval = 0; for (ScanGraph::const_iterator it = this->begin(); it != this->end(); it++) { retval += (*it)->scan->size(); diff --git a/octomap/src/eval_octree_accuracy.cpp b/octomap/src/eval_octree_accuracy.cpp index 5e1ed0a5..eddcf7ed 100644 --- a/octomap/src/eval_octree_accuracy.cpp +++ b/octomap/src/eval_octree_accuracy.cpp @@ -90,7 +90,7 @@ int main(int argc, char** argv) { if (!graph->readBinary(graphFilename)) exit(2); - unsigned int num_points_in_graph = 0; + size_t num_points_in_graph = 0; if (max_scan_no > 0) { num_points_in_graph = graph->getNumPoints(max_scan_no-1); cout << "\n Data points in graph up to scan " << max_scan_no << ": " << num_points_in_graph << endl; @@ -103,7 +103,7 @@ int main(int argc, char** argv) { cout << "\nCreating tree\n===========================\n"; OcTree* tree = new OcTree(res); - unsigned int numScans = graph->size(); + size_t numScans = graph->size(); unsigned int currentScan = 1; for (ScanGraph::iterator scan_it = graph->begin(); scan_it != graph->end(); scan_it++) { @@ -125,10 +125,10 @@ int main(int argc, char** argv) { cout << "\nEvaluating scans\n===========================\n"; currentScan = 1; - unsigned num_points = 0; - unsigned num_voxels_correct = 0; - unsigned num_voxels_wrong = 0; - unsigned num_voxels_unknown = 0; + size_t num_points = 0; + size_t num_voxels_correct = 0; + size_t num_voxels_wrong = 0; + size_t num_voxels_unknown = 0; for (ScanGraph::iterator scan_it = graph->begin(); scan_it != graph->end(); scan_it++) { diff --git a/octomap/src/graph2tree.cpp b/octomap/src/graph2tree.cpp index ac361faf..90df1905 100644 --- a/octomap/src/graph2tree.cpp +++ b/octomap/src/graph2tree.cpp @@ -198,7 +198,7 @@ int main(int argc, char** argv) { if (!graph->readBinary(graphFilename)) exit(2); - unsigned int num_points_in_graph = 0; + size_t num_points_in_graph = 0; if (max_scan_no > 0) { num_points_in_graph = graph->getNumPoints(max_scan_no-1); cout << "\n Data points in graph up to scan " << max_scan_no << ": " << num_points_in_graph << endl; @@ -243,8 +243,8 @@ int main(int argc, char** argv) { gettimeofday(&start, NULL); // start timer - unsigned int numScans = graph->size(); - unsigned int currentScan = 1; + size_t numScans = graph->size(); + size_t currentScan = 1; for (ScanGraph::iterator scan_it = graph->begin(); scan_it != graph->end(); scan_it++) { if (max_scan_no > 0) cout << "("< Date: Mon, 4 Jan 2016 13:40:32 +0100 Subject: [PATCH 07/17] Fixing occupancy type to double in MapCollection Fewer warnings with MSVC (#100) --- octomap/include/octomap/MapCollection.h | 2 +- octomap/include/octomap/MapCollection.hxx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/octomap/include/octomap/MapCollection.h b/octomap/include/octomap/MapCollection.h index 95390da0..d75a8c74 100644 --- a/octomap/include/octomap/MapCollection.h +++ b/octomap/include/octomap/MapCollection.h @@ -56,7 +56,7 @@ namespace octomap { bool isOccupied(const point3d& p) const; bool isOccupied(float x, float y, float z) const; - float getOccupancy(const point3d& p); + double getOccupancy(const point3d& p); bool castRay(const point3d& origin, const point3d& direction, point3d& end, bool ignoreUnknownCells=false, double maxRange=-1.0) const; diff --git a/octomap/include/octomap/MapCollection.hxx b/octomap/include/octomap/MapCollection.hxx index 9a86d269..403745e3 100644 --- a/octomap/include/octomap/MapCollection.hxx +++ b/octomap/include/octomap/MapCollection.hxx @@ -168,14 +168,14 @@ namespace octomap { template - float MapCollection::getOccupancy(const point3d& p) { - float max_occ_val = 0; + double MapCollection::getOccupancy(const point3d& p) { + double max_occ_val = 0; bool is_unknown = true; for (const_iterator it = this->begin(); it != this->end(); ++it) { point3d ptrans = (*it)->getOrigin().inv().transform(p); typename MAPNODE::TreeType::NodeType* n = (*it)->getMap()->search(ptrans); if (n) { - float occ = n->getOccupancy(); + double occ = n->getOccupancy(); if (occ > max_occ_val) max_occ_val = occ; is_unknown = false; } From 73172a86542ad8b5ce3100289260015a6fbe5bb0 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Mon, 4 Jan 2016 13:43:37 +0100 Subject: [PATCH 08/17] Explicit casts to float, fixes #100 Affects OccupancyOcTreeBase::getRayIntersection(...) and point3d initializations in tests and examples --- octomap/include/octomap/OcTreeBaseImpl.hxx | 2 +- .../include/octomap/OccupancyOcTreeBase.hxx | 26 +++++++++---------- octomap/src/intersection_example.cpp | 12 ++++----- octomap/src/normals_example.cpp | 8 +++--- octomap/src/testing/test_changedkeys.cpp | 8 +++--- octomap/src/testing/test_io.cpp | 6 ++--- octomap/src/testing/test_iterators.cpp | 6 ++--- octomap/src/testing/test_mapcollection.cpp | 2 +- octomap/src/testing/test_pruning.cpp | 24 ++++++++--------- octomap/src/testing/test_raycasting.cpp | 8 +++--- 10 files changed, 51 insertions(+), 51 deletions(-) diff --git a/octomap/include/octomap/OcTreeBaseImpl.hxx b/octomap/include/octomap/OcTreeBaseImpl.hxx index 85240430..37e06ef6 100644 --- a/octomap/include/octomap/OcTreeBaseImpl.hxx +++ b/octomap/include/octomap/OcTreeBaseImpl.hxx @@ -672,7 +672,7 @@ namespace octomap { // Note: this can be larger than the adressable memory // - size_t may not be enough to hold it! - return ((size_x/resolution) * (size_y/resolution) * (size_z/resolution) + return (unsigned long long)((size_x/resolution) * (size_y/resolution) * (size_z/resolution) * sizeof(root->getValue())); } diff --git a/octomap/include/octomap/OccupancyOcTreeBase.hxx b/octomap/include/octomap/OccupancyOcTreeBase.hxx index 14f9e4e7..91e49972 100644 --- a/octomap/include/octomap/OccupancyOcTreeBase.hxx +++ b/octomap/include/octomap/OccupancyOcTreeBase.hxx @@ -777,12 +777,12 @@ namespace octomap { octomap::point3d normalZ(0, 0, 1); // One point on each plane, let them be the center for simplicity - octomap::point3d pointXNeg(center(0) - this->resolution / 2.0, center(1), center(2)); - octomap::point3d pointXPos(center(0) + this->resolution / 2.0, center(1), center(2)); - octomap::point3d pointYNeg(center(0), center(1) - this->resolution / 2.0, center(2)); - octomap::point3d pointYPos(center(0), center(1) + this->resolution / 2.0, center(2)); - octomap::point3d pointZNeg(center(0), center(1), center(2) - this->resolution / 2.0); - octomap::point3d pointZPos(center(0), center(1), center(2) + this->resolution / 2.0); + octomap::point3d pointXNeg(center(0) - float(this->resolution / 2.0), center(1), center(2)); + octomap::point3d pointXPos(center(0) + float(this->resolution / 2.0), center(1), center(2)); + octomap::point3d pointYNeg(center(0), center(1) - float(this->resolution / 2.0), center(2)); + octomap::point3d pointYPos(center(0), center(1) + float(this->resolution / 2.0), center(2)); + octomap::point3d pointZNeg(center(0), center(1), center(2) - float(this->resolution / 2.0)); + octomap::point3d pointZPos(center(0), center(1), center(2) + float(this->resolution / 2.0)); double lineDotNormal = 0.0; double d = 0.0; @@ -796,7 +796,7 @@ namespace octomap { // if yes keep only the closest (smallest distance to sensor origin). if((lineDotNormal = normalX.dot(direction))){ d = (pointXNeg - origin).dot(normalX) / lineDotNormal; - intersect = direction * d + origin; + intersect = direction * float(d) + origin; if(!(intersect(1) < (pointYNeg(1) - 1e-6) || intersect(1) > (pointYPos(1) + 1e-6) || intersect(2) < (pointZNeg(2) - 1e-6) || intersect(2) > (pointZPos(2) + 1e-6))){ outD = std::min(outD, d); @@ -804,7 +804,7 @@ namespace octomap { } d = (pointXPos - origin).dot(normalX) / lineDotNormal; - intersect = direction * d + origin; + intersect = direction * float(d) + origin; if(!(intersect(1) < (pointYNeg(1) - 1e-6) || intersect(1) > (pointYPos(1) + 1e-6) || intersect(2) < (pointZNeg(2) - 1e-6) || intersect(2) > (pointZPos(2) + 1e-6))){ outD = std::min(outD, d); @@ -814,7 +814,7 @@ namespace octomap { if((lineDotNormal = normalY.dot(direction))){ d = (pointYNeg - origin).dot(normalY) / lineDotNormal; - intersect = direction * d + origin; + intersect = direction * float(d) + origin; if(!(intersect(0) < (pointXNeg(0) - 1e-6) || intersect(0) > (pointXPos(0) + 1e-6) || intersect(2) < (pointZNeg(2) - 1e-6) || intersect(2) > (pointZPos(2) + 1e-6))){ outD = std::min(outD, d); @@ -822,7 +822,7 @@ namespace octomap { } d = (pointYPos - origin).dot(normalY) / lineDotNormal; - intersect = direction * d + origin; + intersect = direction * float(d) + origin; if(!(intersect(0) < (pointXNeg(0) - 1e-6) || intersect(0) > (pointXPos(0) + 1e-6) || intersect(2) < (pointZNeg(2) - 1e-6) || intersect(2) > (pointZPos(2) + 1e-6))){ outD = std::min(outD, d); @@ -832,7 +832,7 @@ namespace octomap { if((lineDotNormal = normalZ.dot(direction))){ d = (pointZNeg - origin).dot(normalZ) / lineDotNormal; - intersect = direction * d + origin; + intersect = direction * float(d) + origin; if(!(intersect(0) < (pointXNeg(0) - 1e-6) || intersect(0) > (pointXPos(0) + 1e-6) || intersect(1) < (pointYNeg(1) - 1e-6) || intersect(1) > (pointYPos(1) + 1e-6))){ outD = std::min(outD, d); @@ -840,7 +840,7 @@ namespace octomap { } d = (pointZPos - origin).dot(normalZ) / lineDotNormal; - intersect = direction * d + origin; + intersect = direction * float(d) + origin; if(!(intersect(0) < (pointXNeg(0) - 1e-6) || intersect(0) > (pointXPos(0) + 1e-6) || intersect(1) < (pointYNeg(1) - 1e-6) || intersect(1) > (pointYPos(1) + 1e-6))){ outD = std::min(outD, d); @@ -851,7 +851,7 @@ namespace octomap { // Substract (add) a fraction to ensure no ambiguity on the starting voxel // Don't start on a bondary. if(found) - intersection = direction * (outD + delta) + origin; + intersection = direction * float(outD + delta) + origin; return found; } diff --git a/octomap/src/intersection_example.cpp b/octomap/src/intersection_example.cpp index e79ccdbe..fb453cad 100644 --- a/octomap/src/intersection_example.cpp +++ b/octomap/src/intersection_example.cpp @@ -48,9 +48,9 @@ int main(int argc, char** argv) { // insert some measurements of free cells - for (float x = -2; x <= 0; x += 0.02) { - for (float y = -2; y <= 0; y += 0.02) { - for (float z = -2; z <= 0; z += 0.02) { + for (float x = -2; x <= 0; x += 0.02f) { + for (float y = -2; y <= 0; y += 0.02f) { + for (float z = -2; z <= 0; z += 0.02f) { point3d endpoint(x, y, z); tree.updateNode(endpoint, false); // integrate 'free' measurement } @@ -58,9 +58,9 @@ int main(int argc, char** argv) { } // insert some measurements of occupied cells (twice as much) - for (float x = -1; x <= 0; x += 0.01) { - for (float y = -1; y <= 0; y += 0.01) { - for (float z = -1; z <= 0; z += 0.01) { + for (float x = -1; x <= 0; x += 0.01f) { + for (float y = -1; y <= 0; y += 0.01f) { + for (float z = -1; z <= 0; z += 0.01f) { point3d endpoint(x, y, z); tree.updateNode(endpoint, true); // integrate 'occupied' measurement } diff --git a/octomap/src/normals_example.cpp b/octomap/src/normals_example.cpp index 20eee0da..e7484830 100644 --- a/octomap/src/normals_example.cpp +++ b/octomap/src/normals_example.cpp @@ -85,9 +85,9 @@ int main(int argc, char** argv) { point3d query; OcTreeNode* result = NULL; - for(float z = -0.6; z < -0.21; z += 0.1){ - for(float y = -0.6; y < -0.21; y += 0.1){ - for(float x = -0.6; x < -0.21; x += 0.1){ + for(float z = -0.6f; z < -0.21f; z += 0.1f){ + for(float y = -0.6f; y < -0.21f; y += 0.1f){ + for(float x = -0.6f; x < -0.21f; x += 0.1f){ query = point3d(x, y, z); result = tree.search(query); print_query_info(query, result); @@ -95,7 +95,7 @@ int main(int argc, char** argv) { } } - query = point3d(-0.5, -0.4, -0.4); + query = point3d(-0.5f, -0.4f, -0.4f); result = tree.search(query); vector normals; diff --git a/octomap/src/testing/test_changedkeys.cpp b/octomap/src/testing/test_changedkeys.cpp index 20499879..c3d51b3f 100644 --- a/octomap/src/testing/test_changedkeys.cpp +++ b/octomap/src/testing/test_changedkeys.cpp @@ -61,13 +61,13 @@ int main(int argc, char** argv) { OcTree tree (0.05); tree.enableChangeDetection(true); - point3d origin (0.01, 0.01, 0.02); - point3d point_on_surface (4.01,0.01,0.01); + point3d origin (0.01f, 0.01f, 0.02f); + point3d point_on_surface (4.01f,0.01f,0.01f); tree.insertRay(origin, point_on_surface); printChanges(tree); - tree.updateNode(point3d(2.01, 0.01, 0.01), 2.0f); + tree.updateNode(point3d(2.01f, 0.01f, 0.01f), 2.0f); printChanges(tree); - tree.updateNode(point3d(2.01, 0.01, 0.01), -2.0f); + tree.updateNode(point3d(2.01f, 0.01f, 0.01f), -2.0f); printChanges(tree); cout << "generating spherical scan at " << origin << " ..." << endl; diff --git a/octomap/src/testing/test_io.cpp b/octomap/src/testing/test_io.cpp index afbbc147..a5625736 100644 --- a/octomap/src/testing/test_io.cpp +++ b/octomap/src/testing/test_io.cpp @@ -95,7 +95,7 @@ int main(int argc, char** argv) { EXPECT_TRUE(tree == *readTreeOt); // sanity test for "==": flip one node, compare again - point3d coord(0.1, 0.1, 0.1); + point3d coord(0.1f, 0.1f, 0.1f); node = readTreeOt->search(coord); if (node && readTreeOt->isNodeOccupied(node)) readTreeOt->updateNode(coord, false); @@ -113,8 +113,8 @@ int main(int argc, char** argv) { ColorOcTreeNode::Color color_red(255, 0, 0); colorNode->setColor(color_red); colorTree.setNodeColor(0.0, 0.0, 0.0, 255, 0, 0); - colorTree.updateNode(point3d(0.1, 0.1, 0.1), true); - colorTree.setNodeColor(0.1, 0.1, 0.1, 0, 0, 255); + colorTree.updateNode(point3d(0.1f, 0.1f, 0.1f), true); + colorTree.setNodeColor(0.1f, 0.1f, 0.1f, 0, 0, 255); EXPECT_TRUE(colorTree.write(filenameColor)); readTreeAbstract = AbstractOcTree::read(filenameColor); diff --git a/octomap/src/testing/test_iterators.cpp b/octomap/src/testing/test_iterators.cpp index 76a3118a..a2b77c19 100644 --- a/octomap/src/testing/test_iterators.cpp +++ b/octomap/src/testing/test_iterators.cpp @@ -44,7 +44,7 @@ void getLeafNodesRecurs(std::list& voxels, if ((depth <= max_depth) && (node != NULL) ) { if (node->hasChildren() && (depth != max_depth)) { - double center_offset = tree_center(0) / pow( 2., (double) depth+1); + float center_offset = float(tree_center(0) / pow( 2., (double) depth+1)); point3d search_center; for (unsigned int i=0; i<8; i++) { @@ -129,10 +129,10 @@ void boundingBoxTest(OcTree* tree){ OcTreeKey bbxMinKey, bbxMaxKey; double temp_x,temp_y,temp_z; tree->getMetricMin(temp_x,temp_y,temp_z); - octomap::point3d bbxMin(temp_x,temp_y,temp_z); + octomap::point3d bbxMin = octomap::point3d(float(temp_x), float(temp_y), float(temp_z)); tree->getMetricMax(temp_x,temp_y,temp_z); - octomap::point3d bbxMax(temp_x,temp_y,temp_z); + octomap::point3d bbxMax = octomap::point3d(float(temp_x), float(temp_y), float(temp_z)); EXPECT_TRUE(tree->coordToKeyChecked(bbxMin, bbxMinKey)); EXPECT_TRUE(tree->coordToKeyChecked(bbxMax, bbxMaxKey)); diff --git a/octomap/src/testing/test_mapcollection.cpp b/octomap/src/testing/test_mapcollection.cpp index 9a73e4ec..f88227b0 100644 --- a/octomap/src/testing/test_mapcollection.cpp +++ b/octomap/src/testing/test_mapcollection.cpp @@ -69,7 +69,7 @@ int main(int argc, char** argv) { query.push_back(point3d(0,0,0)); query.push_back(point3d(2,0,0)); query.push_back(point3d(2,0,2)); - query.push_back(point3d(1.99,0,0)); + query.push_back(point3d(1.99f,0.0f,0.0f)); query.push_back(point3d(0,0,3)); query.push_back(point3d(3,7,13.5)); query.push_back(point3d(0,-1,-1)); diff --git a/octomap/src/testing/test_pruning.cpp b/octomap/src/testing/test_pruning.cpp index 4a07ef72..b6409b77 100644 --- a/octomap/src/testing/test_pruning.cpp +++ b/octomap/src/testing/test_pruning.cpp @@ -7,10 +7,10 @@ using namespace octomap; using namespace octomath; int main(int argc, char** argv) { - double res = 0.01; + float res = 0.01f; OcTree tree(res); - point3d singlePt(-0.05, -0.02, 1.0); + point3d singlePt(-0.05f, -0.02f, 1.0f); OcTreeKey singleKey; tree.coordToKeyChecked(singlePt, singleKey); OcTreeNode* singleNode = tree.updateNode(singleKey, true); @@ -125,9 +125,9 @@ int main(int argc, char** argv) { //tree.write("pruning_test_out1.ot"); // now test larger volume pruning: - for (float x=0.005; x <= 0.32; x+=res){ - for (float y=0.005; y <= 0.32; y+=res){ - for (float z=0.005; z <= 0.32; z+=res){ + for (float x=0.005f; x <= 0.32f; x+=res){ + for (float y=0.005f; y <= 0.32f; y+=res){ + for (float z=0.005f; z <= 0.32f; z+=res){ OcTreeNode* node = tree.updateNode(point3d(x,y,z), true); EXPECT_TRUE(node); EXPECT_TRUE(tree.isNodeOccupied(node)); @@ -146,9 +146,9 @@ int main(int argc, char** argv) { tree.prune(); EXPECT_EQ(27, tree.size()); // test expansion: - for (float x=0.005; x <= 0.32; x+=res){ - for (float y=0.005; y <= 0.32; y+=res){ - for (float z=0.005; z <= 0.32; z+=res){ + for (float x=0.005f; x <= 0.32f; x+=res){ + for (float y=0.005f; y <= 0.32f; y+=res){ + for (float z=0.005f; z <= 0.32f; z+=res){ OcTreeNode* node = tree.search(point3d(x,y,z)); EXPECT_TRUE(node); EXPECT_TRUE(tree.isNodeOccupied(node)); @@ -156,13 +156,13 @@ int main(int argc, char** argv) { } } - tree.coordToKeyChecked(point3d(0.1, 0.1, 0.1), singleKey); + tree.coordToKeyChecked(point3d(0.1f, 0.1f, 0.1f), singleKey); EXPECT_TRUE(tree.updateNode(singleKey, true)); - for (float x=0.005; x <= 0.32; x+=res){ - for (float y=0.005; y <= 0.32; y+=res){ - for (float z=0.005; z <= 0.32; z+=res){ + for (float x=0.005f; x <= 0.32f; x+=res){ + for (float y=0.005f; y <= 0.32f; y+=res){ + for (float z=0.005f; z <= 0.32f; z+=res){ OcTreeNode* node = tree.search(point3d(x,y,z)); EXPECT_TRUE(node); EXPECT_TRUE(tree.isNodeOccupied(node)); diff --git a/octomap/src/testing/test_raycasting.cpp b/octomap/src/testing/test_raycasting.cpp index 2d6ab713..3ce1bd7a 100644 --- a/octomap/src/testing/test_raycasting.cpp +++ b/octomap/src/testing/test_raycasting.cpp @@ -117,9 +117,9 @@ int main(int argc, char** argv) { double res_2 = res/2.0; OcTree cubeTree(res); // fill a cube with "free", end is "occupied": - for (float x=-0.95; x <= 1.0; x+=res){ - for (float y=-0.95; y <= 1.0; y+=res){ - for (float z=-0.95; z <= 1.0; z+=res){ + for (float x=-0.95f; x <= 1.0f; x+=float(res)){ + for (float y=-0.95f; y <= 1.0f; y+= float(res)){ + for (float z=-0.95f; z <= 1.0f; z+= float(res)){ if (x < 0.9){ EXPECT_TRUE(cubeTree.updateNode(point3d(x,y,z), false)); } else{ @@ -150,7 +150,7 @@ int main(int argc, char** argv) { EXPECT_NEAR(1.0, (origin - end).norm(), res_2); // hit bottom: - origin = point3d(res_2, res_2, 0.5f); + origin = point3d(float(res_2), float(res_2), 0.5f); direction = point3d(0.0, 0.0, -1.0f); EXPECT_TRUE(cubeTree.castRay(origin, direction, end, false)); EXPECT_TRUE(cubeTree.isNodeOccupied(cubeTree.search(end))); From 079219499d19ce38dd4090e28ab7d1bdf143432f Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Mon, 4 Jan 2016 13:56:36 +0100 Subject: [PATCH 09/17] Extending Windows compilation instructions --- octomap/README.md | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/octomap/README.md b/octomap/README.md index a27c3d23..b6795518 100644 --- a/octomap/README.md +++ b/octomap/README.md @@ -121,7 +121,8 @@ The octomap library and tools can be compiled and used under Windows although this has not been tested in-depth. Feedback is welcome. -To compile the library you need cmake (http://www.cmake.org). +To compile the library you need cmake (http://www.cmake.org) +and either MinGW or Visual Studio. ### MinGW ### @@ -129,30 +130,39 @@ To compile the library you need cmake (http://www.cmake.org). 2. Install C++ compiler and add MingGW/bin to your system PATH 3. Start the cmake-gui and set the code directory to the library root (e.g. `/octomap`) -4. Set the build directory to, e.g., `/octomap/build`. -5. Press "Generate", select the appropriate generator, "MinGW Makefiles". +4. Create and set the build directory to, e.g., `/octomap/build`. +5. Press "Configure" then "Generate", select the appropriate generator, "MinGW Makefiles". 6. Start a command shell and "make" the project: octomap> cd build octomap/build> mingw32-make.exe -You can run the unit tests using ctest on the command prompt: +As verification, you can run the unit tests using ctest on the +command prompt: octomap/build> ctest.exe -### Microsoft Visual Studio 2010 ### +### Microsoft Visual Studio (2013 or later recommended) ### -1. Start the cmake-gui and set the code directory to the - library root (e.g. `/octomap`) -2. Set the build directory to, e.g., /octomap/build. -3. Press "Generate", select the appropriate generator, e.g. "Visual Studio 10". - This generates a solution file octomap.sln -4. Load this file and build the project +Last tested with MSVC 2013 and 2015 (Community Edition). + +1. Start the cmake-gui and set the source code directory to the + library root (e.g. `\octomap`) +2. Create a build directory and set it in CMake ("Where to build the + binaries"), e.g. `\octomap\build`. +3. Press "Configure" then "Generate", select the appropriate generator, e.g. "Visual Studio 2015". + This generates a solution file `octomap.sln` in the build directory. +4. Load this file and build the project `ALL_BUILD` in Visual Studio. +Instead of building the complete distribution (octomap, octovis, and dynamicEDT3D) +you can only build octomap by proceeding as described above but in the `octomap` +subdirectory. This can help you getting started when there are problems with +octovis and Qt4. -You can run the unit tests using ctest on the command prompt: +As verification, you can run the unit tests in Visual Studio by building the +`RUN_TESTS` project or by using ctest on the command prompt: octomap/build> ctest.exe -C Release From 2e8f6462ebd7a00379e8c1d39a00c03773723059 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Mon, 4 Jan 2016 14:20:44 +0100 Subject: [PATCH 10/17] Fixing introduced errors with casts in ScanGraph.cpp --- octomap/src/ScanGraph.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/octomap/src/ScanGraph.cpp b/octomap/src/ScanGraph.cpp index 64b4bf35..922fd142 100644 --- a/octomap/src/ScanGraph.cpp +++ b/octomap/src/ScanGraph.cpp @@ -174,7 +174,7 @@ namespace octomap { ScanNode* ScanGraph::addNode(Pointcloud* scan, pose6d pose) { if (scan != 0) { - nodes.push_back(new ScanNode(scan, pose, unsigned int(nodes.size()))); + nodes.push_back(new ScanNode(scan, pose, (unsigned int) nodes.size())); return nodes.back(); } else { @@ -326,8 +326,9 @@ namespace octomap { // file structure: n | node_1 | ... | node_n | m | edge_1 | ... | edge_m // write nodes --------------------------------- - size_t graph_size = this->size(); - if (graph_size) OCTOMAP_DEBUG("writing %lu nodes to binary file...\n", (unsigned long)graph_size); + // note: size is always an unsigned int! + unsigned int graph_size = (unsigned int) this->size(); + if (graph_size) OCTOMAP_DEBUG("writing %u nodes to binary file...\n", graph_size); s.write((char*)&graph_size, sizeof(graph_size)); for (ScanGraph::const_iterator it = this->begin(); it != this->end(); it++) { @@ -337,8 +338,8 @@ namespace octomap { if (graph_size) OCTOMAP_DEBUG("done.\n"); // write edges --------------------------------- - size_t num_edges = this->edges.size(); - if (num_edges) OCTOMAP_DEBUG("writing %lu edges to binary file...\n", (unsigned long)num_edges); + unsigned int num_edges = (unsigned int) this->edges.size(); + if (num_edges) OCTOMAP_DEBUG("writing %u edges to binary file...\n", num_edges); s.write((char*)&num_edges, sizeof(num_edges)); for (ScanGraph::const_edge_iterator it = this->edges_begin(); it != this->edges_end(); it++) { From fd99e56611571389447d5cdd7f5574298655ba0e Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Mon, 4 Jan 2016 19:43:54 +0100 Subject: [PATCH 11/17] Improved compatibility with CMake 3.1, CMP0053 warning (followup on #47) --- dynamicEDT3D/CMakeLists.txt | 4 ++-- octomap/CMakeLists.txt | 8 ++++---- octovis/CMakeLists.txt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt index d71c998a..c40271f0 100644 --- a/dynamicEDT3D/CMakeLists.txt +++ b/dynamicEDT3D/CMakeLists.txt @@ -84,11 +84,11 @@ set(DYNAMICEDT3D_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") # Windows, spec. MSVC requires the .lib suffix for imported libs IF(WIN32) set(DYNAMICEDT3D_LIBRARY - @DYNAMICEDT3D_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@dynamicedt3d@CMAKE_IMPORT_LIBRARY_SUFFIX@ + "${DYNAMICEDT3D_LIB_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}dynamicedt3d${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) ELSE() set(DYNAMICEDT3D_LIBRARY - @DYNAMICEDT3D_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@dynamicedt3d@CMAKE_SHARED_LIBRARY_SUFFIX@ + "${DYNAMICEDT3D_LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}dynamicedt3d${CMAKE_SHARED_LIBRARY_SUFFIX}" ) ENDIF() # not used right now (export depends?) diff --git a/octomap/CMakeLists.txt b/octomap/CMakeLists.txt index db4b8928..9a601a7d 100644 --- a/octomap/CMakeLists.txt +++ b/octomap/CMakeLists.txt @@ -87,17 +87,17 @@ set(OCTOMAP_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") # Windows, spec. MSVC requires the .lib suffix for imported libs IF(WIN32) set(OCTOMAP_LIBRARY - @OCTOMAP_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octomap@CMAKE_IMPORT_LIBRARY_SUFFIX@ + "${OCTOMAP_LIB_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}octomap${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) set(OCTOMATH_LIBRARY - @OCTOMAP_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octomath@CMAKE_IMPORT_LIBRARY_SUFFIX@ + "${OCTOMAP_LIB_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}octomath${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) ELSE() set(OCTOMAP_LIBRARY - @OCTOMAP_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octomap@CMAKE_SHARED_LIBRARY_SUFFIX@ + "${OCTOMAP_LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}octomap${CMAKE_SHARED_LIBRARY_SUFFIX}" ) set(OCTOMATH_LIBRARY - @OCTOMAP_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octomath@CMAKE_SHARED_LIBRARY_SUFFIX@ + "${OCTOMAP_LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}octomath${CMAKE_SHARED_LIBRARY_SUFFIX}" ) ENDIF() diff --git a/octovis/CMakeLists.txt b/octovis/CMakeLists.txt index e3871807..40b19fe3 100644 --- a/octovis/CMakeLists.txt +++ b/octovis/CMakeLists.txt @@ -90,11 +90,11 @@ IF(BUILD_VIEWER) # Windows, spec. MSVC requires the .lib suffix for imported libs IF(WIN32) set(OCTOVIS_LIBRARY - @OCTOVIS_LIB_DIR@/@CMAKE_IMPORT_LIBRARY_PREFIX@octovis@CMAKE_IMPORT_LIBRARY_SUFFIX@ + "${OCTOVIS_LIB_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}octovis${CMAKE_IMPORT_LIBRARY_SUFFIX}" ) ELSE() set(OCTOVIS_LIBRARY - @OCTOVIS_LIB_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@octovis@CMAKE_SHARED_LIBRARY_SUFFIX@ + "${OCTOVIS_LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}octovis${CMAKE_SHARED_LIBRARY_SUFFIX}" ) ENDIF() From 7f9c4fbb73703f9bd3550f851d5125bd2f0c63cf Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Tue, 5 Jan 2016 12:43:10 +0100 Subject: [PATCH 12/17] Proposed fixes for IO factory class registry with MSVC (#51) Explicitly calling a dummy function from c'tor ensures that MSVC does not optimize the StaticMemberInitializer away. Extended and verified test_io to read / write OcTree, ColorOcTree and OcTreeStamped. --- octomap/include/octomap/ColorOcTree.h | 9 ++- octomap/include/octomap/CountingOcTree.h | 9 ++- octomap/include/octomap/OcTree.h | 10 +++- octomap/include/octomap/OcTreeStamped.h | 9 ++- octomap/src/ColorOcTree.cpp | 4 ++ octomap/src/CountingOcTree.cpp | 5 +- octomap/src/OcTree.cpp | 5 ++ octomap/src/OcTreeStamped.cpp | 5 ++ octomap/src/testing/test_io.cpp | 76 ++++++++++++++++-------- 9 files changed, 103 insertions(+), 29 deletions(-) diff --git a/octomap/include/octomap/ColorOcTree.h b/octomap/include/octomap/ColorOcTree.h index 9830a116..94ee4e84 100644 --- a/octomap/include/octomap/ColorOcTree.h +++ b/octomap/include/octomap/ColorOcTree.h @@ -117,7 +117,7 @@ namespace octomap { public: /// Default constructor, sets resolution of leafs - ColorOcTree(double resolution) : OccupancyOcTreeBase(resolution) {}; + ColorOcTree(double resolution); /// virtual constructor: creates a new object of same type /// (Covariant return type requires an up-to-date compiler) @@ -180,6 +180,13 @@ namespace octomap { ColorOcTree* tree = new ColorOcTree(0.1); AbstractOcTree::registerTreeType(tree); } + + /** + * Dummy function to ensure that MSVC does not drop the + * StaticMemberInitializer, causing this tree failing to register. + * Needs to be called from the constructor of this octree. + */ + void ensureLinking() {}; }; /// static member to ensure static initialization (only once) static StaticMemberInitializer colorOcTreeMemberInit; diff --git a/octomap/include/octomap/CountingOcTree.h b/octomap/include/octomap/CountingOcTree.h index 9524ed95..2f34a27c 100644 --- a/octomap/include/octomap/CountingOcTree.h +++ b/octomap/include/octomap/CountingOcTree.h @@ -89,7 +89,7 @@ namespace octomap { public: /// Default constructor, sets resolution of leafs - CountingOcTree(double resolution) : OcTreeBase(resolution) {}; + CountingOcTree(double resolution); virtual CountingOcTreeNode* updateNode(const point3d& value); CountingOcTreeNode* updateNode(const OcTreeKey& k); void getCentersMinHits(point3d_list& node_centers, unsigned int min_hits) const; @@ -112,6 +112,13 @@ namespace octomap { CountingOcTree* tree = new CountingOcTree(0.1); AbstractOcTree::registerTreeType(tree); } + + /** + * Dummy function to ensure that MSVC does not drop the + * StaticMemberInitializer, causing this tree failing to register. + * Needs to be called from the constructor of this octree. + */ + void ensureLinking() {}; }; /// static member to ensure static initialization (only once) static StaticMemberInitializer countingOcTreeMemberInit; diff --git a/octomap/include/octomap/OcTree.h b/octomap/include/octomap/OcTree.h index 9bb96174..fa318b5f 100644 --- a/octomap/include/octomap/OcTree.h +++ b/octomap/include/octomap/OcTree.h @@ -50,7 +50,7 @@ namespace octomap { public: /// Default constructor, sets resolution of leafs - OcTree(double resolution) : OccupancyOcTreeBase(resolution) {}; + OcTree(double resolution); /** * Reads an OcTree from a binary file @@ -79,7 +79,15 @@ namespace octomap { OcTree* tree = new OcTree(0.1); AbstractOcTree::registerTreeType(tree); } + + /** + * Dummy function to ensure that MSVC does not drop the + * StaticMemberInitializer, causing this tree failing to register. + * Needs to be called from the constructor of this octree. + */ + void ensureLinking() {}; }; + /// to ensure static initialization (only once) static StaticMemberInitializer ocTreeMemberInit; }; diff --git a/octomap/include/octomap/OcTreeStamped.h b/octomap/include/octomap/OcTreeStamped.h index 278a1791..21f4db1c 100644 --- a/octomap/include/octomap/OcTreeStamped.h +++ b/octomap/include/octomap/OcTreeStamped.h @@ -88,7 +88,7 @@ namespace octomap { public: /// Default constructor, sets resolution of leafs - OcTreeStamped(double resolution) : OccupancyOcTreeBase(resolution) {}; + OcTreeStamped(double resolution); /// virtual constructor: creates a new object of same type /// (Covariant return type requires an up-to-date compiler) @@ -115,6 +115,13 @@ namespace octomap { OcTreeStamped* tree = new OcTreeStamped(0.1); AbstractOcTree::registerTreeType(tree); } + + /** + * Dummy function to ensure that MSVC does not drop the + * StaticMemberInitializer, causing this tree failing to register. + * Needs to be called from the constructor of this octree. + */ + void ensureLinking() {}; }; /// to ensure static initialization (only once) static StaticMemberInitializer ocTreeStampedMemberInit; diff --git a/octomap/src/ColorOcTree.cpp b/octomap/src/ColorOcTree.cpp index 86d95b33..274fbc42 100644 --- a/octomap/src/ColorOcTree.cpp +++ b/octomap/src/ColorOcTree.cpp @@ -130,6 +130,10 @@ namespace octomap { } // tree implementation -------------------------------------- + ColorOcTree::ColorOcTree(double resolution) + : OccupancyOcTreeBase(resolution) { + colorOcTreeMemberInit.ensureLinking(); + }; ColorOcTreeNode* ColorOcTree::setNodeColor(const OcTreeKey& key, const unsigned char& r, diff --git a/octomap/src/CountingOcTree.cpp b/octomap/src/CountingOcTree.cpp index 7b147625..b3694456 100644 --- a/octomap/src/CountingOcTree.cpp +++ b/octomap/src/CountingOcTree.cpp @@ -70,7 +70,10 @@ namespace octomap { /// implementation of CountingOcTree -------------------------------------- - + CountingOcTree::CountingOcTree(double resolution) + : OcTreeBase(resolution) { + countingOcTreeMemberInit.ensureLinking(); + } CountingOcTreeNode* CountingOcTree::updateNode(const point3d& value) { diff --git a/octomap/src/OcTree.cpp b/octomap/src/OcTree.cpp index 5e4c01c6..a5172fdc 100644 --- a/octomap/src/OcTree.cpp +++ b/octomap/src/OcTree.cpp @@ -36,6 +36,11 @@ namespace octomap { + OcTree::OcTree(double resolution) + : OccupancyOcTreeBase(resolution) { + ocTreeMemberInit.ensureLinking(); + }; + OcTree::OcTree(std::string _filename) : OccupancyOcTreeBase (0.1) { // resolution will be set according to tree file readBinary(_filename); diff --git a/octomap/src/OcTreeStamped.cpp b/octomap/src/OcTreeStamped.cpp index a49e1ec5..88a89e3a 100644 --- a/octomap/src/OcTreeStamped.cpp +++ b/octomap/src/OcTreeStamped.cpp @@ -35,6 +35,11 @@ namespace octomap { + OcTreeStamped::OcTreeStamped(double resolution) + : OccupancyOcTreeBase(resolution) { + ocTreeStampedMemberInit.ensureLinking(); + } + unsigned int OcTreeStamped::getLastUpdateTime() { // this value is updated whenever inner nodes are // updated using updateOccupancyChildren() diff --git a/octomap/src/testing/test_io.cpp b/octomap/src/testing/test_io.cpp index a5625736..3b43219c 100644 --- a/octomap/src/testing/test_io.cpp +++ b/octomap/src/testing/test_io.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "testing.h" @@ -32,10 +33,8 @@ int main(int argc, char** argv) { EXPECT_EQ(emptyReadTree.size(), 0); EXPECT_TRUE(emptyTree == emptyReadTree); - - string filename = string(argv[1]); - + string filenameOt = "test_io_file.ot"; string filenameBtOut = "test_io_file.bt"; string filenameBtCopyOut = "test_io_file_copy.bt"; @@ -104,28 +103,57 @@ int main(int argc, char** argv) { EXPECT_FALSE(tree == *readTreeOt); - // simple test for tree headers (color) - double res = 0.02; - std::string filenameColor = "test_io_color_file.ot"; - ColorOcTree colorTree(res); - EXPECT_EQ(colorTree.getTreeType(), "ColorOcTree"); - ColorOcTreeNode* colorNode = colorTree.updateNode(point3d(0.0, 0.0, 0.0), true); - ColorOcTreeNode::Color color_red(255, 0, 0); - colorNode->setColor(color_red); - colorTree.setNodeColor(0.0, 0.0, 0.0, 255, 0, 0); - colorTree.updateNode(point3d(0.1f, 0.1f, 0.1f), true); - colorTree.setNodeColor(0.1f, 0.1f, 0.1f, 0, 0, 255); - - EXPECT_TRUE(colorTree.write(filenameColor)); - readTreeAbstract = AbstractOcTree::read(filenameColor); + // Test for tree headers and IO factory registry (color) + { + double res = 0.02; + std::string filenameColor = "test_io_color_file.ot"; + ColorOcTree colorTree(res); + EXPECT_EQ(colorTree.getTreeType(), "ColorOcTree"); + ColorOcTreeNode* colorNode = colorTree.updateNode(point3d(0.0, 0.0, 0.0), true); + ColorOcTreeNode::Color color_red(255, 0, 0); + colorNode->setColor(color_red); + colorTree.setNodeColor(0.0, 0.0, 0.0, 255, 0, 0); + colorTree.updateNode(point3d(0.1f, 0.1f, 0.1f), true); + colorTree.setNodeColor(0.1f, 0.1f, 0.1f, 0, 0, 255); + + EXPECT_TRUE(colorTree.write(filenameColor)); + readTreeAbstract = AbstractOcTree::read(filenameColor); + EXPECT_TRUE(readTreeAbstract); + EXPECT_EQ(colorTree.getTreeType(), readTreeAbstract->getTreeType()); + ColorOcTree* readColorTree = dynamic_cast(readTreeAbstract); + EXPECT_TRUE(readColorTree); + EXPECT_TRUE(colorTree == *readColorTree); + colorNode = colorTree.search(0.0, 0.0, 0.0); + EXPECT_TRUE(colorNode); + EXPECT_EQ(colorNode->getColor(), color_red); + delete readColorTree; + } + + // Test for tree headers and IO factory registry (stamped) + double res = 0.05; + std::string filenameStamped = "test_io_stamped_file.ot"; + OcTreeStamped stampedTree(res); + EXPECT_EQ(stampedTree.getTreeType(), "OcTreeStamped"); + // TODO: add / modify some stamped nodes + //ColorOcTreeNode* colorNode = colorTree.updateNode(point3d(0.0, 0.0, 0.0), true); + //ColorOcTreeNode::Color color_red(255, 0, 0); + //colorNode->setColor(color_red); + //colorTree.setNodeColor(0.0, 0.0, 0.0, 255, 0, 0); + //colorTree.updateNode(point3d(0.1f, 0.1f, 0.1f), true); + //colorTree.setNodeColor(0.1f, 0.1f, 0.1f, 0, 0, 255); + + EXPECT_TRUE(stampedTree.write(filenameStamped)); + readTreeAbstract = NULL; + readTreeAbstract = AbstractOcTree::read(filenameStamped); EXPECT_TRUE(readTreeAbstract); - EXPECT_EQ(colorTree.getTreeType(), readTreeAbstract->getTreeType()); - ColorOcTree* readColorTree = dynamic_cast(readTreeAbstract); - EXPECT_TRUE(readColorTree); - EXPECT_TRUE(colorTree == *readColorTree); - colorNode = colorTree.search(0.0, 0.0, 0.0); - EXPECT_TRUE(colorNode); - EXPECT_EQ(colorNode->getColor(), color_red); + EXPECT_EQ(stampedTree.getTreeType(), readTreeAbstract->getTreeType()); + OcTreeStamped* readStampedTree = dynamic_cast(readTreeAbstract); + EXPECT_TRUE(readStampedTree); + EXPECT_TRUE(stampedTree == *readStampedTree); + //colorNode = colorTree.search(0.0, 0.0, 0.0); + //EXPECT_TRUE(colorNode); + //EXPECT_EQ(colorNode->getColor(), color_red); + From 2f6fa98ba30312fe201c2b7fb7d6b4d8cf4af494 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Wed, 6 Jan 2016 21:19:09 +0100 Subject: [PATCH 13/17] Fixing ColorOcTree.cpp line endings --- octomap/src/ColorOcTree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/octomap/src/ColorOcTree.cpp b/octomap/src/ColorOcTree.cpp index 86d95b33..efd190de 100644 --- a/octomap/src/ColorOcTree.cpp +++ b/octomap/src/ColorOcTree.cpp @@ -206,8 +206,8 @@ namespace octomap { void ColorOcTree::writeColorHistogram(std::string filename) { -#ifdef _MSC_VER - fprintf(stderr, "The color histogram uses gnuplot, this is not supported under windows.\n"); +#ifdef _MSC_VER + fprintf(stderr, "The color histogram uses gnuplot, this is not supported under windows.\n"); #else // build RGB histogram std::vector histogram_r (256,0); From cb0da5288f323df094000b01d02d42944c323e5a Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Sun, 10 Jan 2016 13:28:04 +0100 Subject: [PATCH 14/17] Adding valgrind memcheck suppression file with known ("wanted") leaks due to StaticMemberInitializer. Big chunk "still reachable" remains due to KeyRay, needs to be investigated. --- octomap/valgrind_memcheck.supp | 107 +++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 octomap/valgrind_memcheck.supp diff --git a/octomap/valgrind_memcheck.supp b/octomap/valgrind_memcheck.supp new file mode 100644 index 00000000..69593d0b --- /dev/null +++ b/octomap/valgrind_memcheck.supp @@ -0,0 +1,107 @@ +{ + static_member_init_std_string + Memcheck:Leak + match-leak-kinds: possible + fun:_Znwm + fun:_ZNSs4_Rep9_S_createEmmRKSaIcE + fun:_ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag + fun:_ZNSsC1EPKcRKSaIcE + fun:_ZNK7octomap*getTreeTypeEv + fun:_ZN7octomap14AbstractOcTree16registerTreeTypeEPS0_ + fun:_ZN7octomap*StaticMemberInitializerC1Ev + fun:_Z41__static_initialization_and_destruction_0ii + fun:_GLOBAL__sub_I_*.cpp + fun:call_init.part.0 + fun:call_init + fun:_dl_init + obj:/lib/x86_64-linux-gnu/ld-2.19.so +} +{ + static_member_init_class_id_mapping + Memcheck:Leak + match-leak-kinds: reachable + fun:_Znwm + ... + fun:_ZN7octomap*StaticMemberInitializerC1Ev + fun:_Z41__static_initialization_and_destruction_0ii + fun:_GLOBAL__sub_I_*.cpp + fun:call_init.part.0 + fun:call_init + fun:_dl_init + obj:/lib/x86_64-linux-gnu/ld-2.19.so +} + +{ + static_member_init_hash_tree + Memcheck:Leak + match-leak-kinds: reachable + fun:_Znwm + fun:_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsPN7octomap14AbstractOcTreeEEEE8allocateEmPKv + fun:_ZNSt8_Rb_treeISsSt4pairIKSsPN7octomap14AbstractOcTreeEESt10_Select1stIS5_ESt4lessISsESaIS5_EE11_M_get_nodeEv + fun:_ZNSt8_Rb_treeISsSt4pairIKSsPN7octomap14AbstractOcTreeEESt10_Select1stIS5_ESt4lessISsESaIS5_EE14_M_create_nodeERKS5_ + fun:_ZNSt8_Rb_treeISsSt4pairIKSsPN7octomap14AbstractOcTreeEESt10_Select1stIS5_ESt4lessISsESaIS5_EE10_M_insert_EPSt18_Rb_tree_node_baseSD_RKS5_ + fun:_ZNSt8_Rb_treeISsSt4pairIKSsPN7octomap14AbstractOcTreeEESt10_Select1stIS5_ESt4lessISsESaIS5_EE17_M_insert_unique_ESt23_Rb_tree_const_iteratorIS5_ERKS5_ + fun:_ZNSt3mapISsPN7octomap14AbstractOcTreeESt4lessISsESaISt4pairIKSsS2_EEE6insertESt17_Rb_tree_iteratorIS7_ERKS7_ + fun:_ZNSt3mapISsPN7octomap14AbstractOcTreeESt4lessISsESaISt4pairIKSsS2_EEEixERS6_ + fun:_ZN7octomap14AbstractOcTree16registerTreeTypeEPS0_ + fun:_ZN7octomap*StaticMemberInitializerC1Ev + fun:_Z41__static_initialization_and_destruction_0ii + fun:_GLOBAL__sub_I_*.cpp +} + +{ + static_member_init_keyhash + Memcheck:Leak + match-leak-kinds: reachable + fun:_Znwm + fun:_ZN9__gnu_cxx13new_allocatorIPNSt3tr18__detail10_Hash_nodeISt4pairIKN7octomap9OcTreeKeyEbELb0EEEE8allocateEmPKv + fun:_ZNSt3tr110_HashtableIN7octomap9OcTreeKeyESt4pairIKS2_bESaIS5_ESt10_Select1stIS5_ESt8equal_toIS2_ENS2_7KeyHashENS_8__detail18_Mod_range_hashingENSC_20_Default_ranged_hashENSC_20_Prime_rehash_policyELb0ELb0ELb1EE19_M_allocate_bucketsEm + fun:_ZNSt3tr110_HashtableIN7octomap9OcTreeKeyESt4pairIKS2_bESaIS5_ESt10_Select1stIS5_ESt8equal_toIS2_ENS2_7KeyHashENS_8__detail18_Mod_range_hashingENSC_20_Default_ranged_hashENSC_20_Prime_rehash_policyELb0ELb0ELb1EEC1EmRKSB_RKSD_RKSE_RKSA_RKS8_RKS6_ + fun:_ZNSt3tr115__unordered_mapIN7octomap9OcTreeKeyEbNS2_7KeyHashESt8equal_toIS2_ESaISt4pairIKS2_bEELb0EEC1EmRKS3_RKS5_RKS9_ + fun:_ZNSt3tr113unordered_mapIN7octomap9OcTreeKeyEbNS2_7KeyHashESt8equal_toIS2_ESaISt4pairIKS2_bEEEC1EmRKS3_RKS5_RKS9_ + fun:_ZN7octomap*INS_*EEC1Ed + fun:_ZN7octomap*C1Ed + fun:_ZN7octomap*StaticMemberInitializerC1Ev + fun:_Z41__static_initialization_and_destruction_0ii + fun:_GLOBAL__sub_I_*.cpp + fun:call_init.part.0 +} + +{ + static_member_init_keyray + Memcheck:Leak + match-leak-kinds: reachable + fun:_Znwm + fun:_ZN9__gnu_cxx13new_allocatorIN7octomap6KeyRayEE8allocateEmPKv + fun:_ZNSt12_Vector_baseIN7octomap6KeyRayESaIS1_EE11_M_allocateEm + fun:_ZNSt6vectorIN7octomap6KeyRayESaIS1_EE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPS1_S3_EEmRKS1_ + fun:_ZNSt6vectorIN7octomap6KeyRayESaIS1_EE6insertEN9__gnu_cxx17__normal_iteratorIPS1_S3_EEmRKS1_ + fun:_ZNSt6vectorIN7octomap6KeyRayESaIS1_EE6resizeEmS1_ + fun:_ZN7octomap14OcTreeBaseImplINS_*ENS_*EE4initEv + fun:_ZN7octomap14OcTreeBaseImplINS_*ENS_*EEC1Ed + fun:_ZN7octomap1*INS_*EEC1Ed + fun:_ZN7octomap*C1Ed + fun:_ZN7octomap*StaticMemberInitializerC1Ev + fun:_Z41__static_initialization_and_destruction_0ii +} + +{ + static_member_init_keyray2 + Memcheck:Leak + match-leak-kinds: reachable + fun:_Znwm + fun:_ZN9__gnu_cxx13new_allocatorIdE8allocateEmPKv + fun:_ZNSt12_Vector_baseIdSaIdEE11_M_allocateEm + fun:_ZNSt6vectorIdSaIdEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPdS1_EEmRKd + fun:_ZNSt6vectorIdSaIdEE6insertEN9__gnu_cxx17__normal_iteratorIPdS1_EEmRKd + fun:_ZNSt6vectorIdSaIdEE6resizeEmd + fun:_ZN7octomap14OcTreeBaseImplINS_*ENS_*EE13setResolutionEd + fun:_ZN7octomap14OcTreeBaseImplINS_*ENS_*EE4initEv + fun:_ZN7octomap14OcTreeBaseImplINS_*ENS_*EEC1Ed + fun:_ZN7octomap*INS_*EEC1Ed + fun:_ZN7octomap*C1Ed + fun:_ZN7octomap*StaticMemberInitializerC1Ev +} + + + From 14c198c4c5d46406173b1a413539981e72044d7a Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Sun, 10 Jan 2016 20:33:56 +0100 Subject: [PATCH 15/17] Extending comments for StaticMemberInitializer --- octomap/include/octomap/ColorOcTree.h | 5 ++++- octomap/include/octomap/CountingOcTree.h | 5 ++++- octomap/include/octomap/OcTree.h | 5 ++++- octomap/include/octomap/OcTreeStamped.h | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/octomap/include/octomap/ColorOcTree.h b/octomap/include/octomap/ColorOcTree.h index 94ee4e84..d2cbb455 100644 --- a/octomap/include/octomap/ColorOcTree.h +++ b/octomap/include/octomap/ColorOcTree.h @@ -172,7 +172,10 @@ namespace octomap { /** * Static member object which ensures that this OcTree's prototype - * ends up in the classIDMapping only once + * ends up in the classIDMapping only once. You need this as a + * static member in any derived octree class in order to read .ot + * files through the AbstractOcTree factory. You should also call + * ensureLinking() once from the constructor. */ class StaticMemberInitializer{ public: diff --git a/octomap/include/octomap/CountingOcTree.h b/octomap/include/octomap/CountingOcTree.h index 2f34a27c..3709d9e9 100644 --- a/octomap/include/octomap/CountingOcTree.h +++ b/octomap/include/octomap/CountingOcTree.h @@ -104,7 +104,10 @@ namespace octomap { /** * Static member object which ensures that this OcTree's prototype - * ends up in the classIDMapping only once + * ends up in the classIDMapping only once. You need this as a + * static member in any derived octree class in order to read .ot + * files through the AbstractOcTree factory. You should also call + * ensureLinking() once from the constructor. */ class StaticMemberInitializer{ public: diff --git a/octomap/include/octomap/OcTree.h b/octomap/include/octomap/OcTree.h index fa318b5f..5e11e418 100644 --- a/octomap/include/octomap/OcTree.h +++ b/octomap/include/octomap/OcTree.h @@ -71,7 +71,10 @@ namespace octomap { protected: /** * Static member object which ensures that this OcTree's prototype - * ends up in the classIDMapping only once + * ends up in the classIDMapping only once. You need this as a + * static member in any derived octree class in order to read .ot + * files through the AbstractOcTree factory. You should also call + * ensureLinking() once from the constructor. */ class StaticMemberInitializer{ public: diff --git a/octomap/include/octomap/OcTreeStamped.h b/octomap/include/octomap/OcTreeStamped.h index 21f4db1c..1d85317e 100644 --- a/octomap/include/octomap/OcTreeStamped.h +++ b/octomap/include/octomap/OcTreeStamped.h @@ -107,7 +107,10 @@ namespace octomap { protected: /** * Static member object which ensures that this OcTree's prototype - * ends up in the classIDMapping only once + * ends up in the classIDMapping only once. You need this as a + * static member in any derived octree class in order to read .ot + * files through the AbstractOcTree factory. You should also call + * ensureLinking() once from the constructor. */ class StaticMemberInitializer{ public: From a2e9d1532ec0785423e5e526f3728c4279a61f12 Mon Sep 17 00:00:00 2001 From: Christian Dornhege Date: Thu, 28 Jan 2016 14:27:45 +0100 Subject: [PATCH 16/17] fix doc of setNodeValue --- octomap/include/octomap/OccupancyOcTreeBase.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/octomap/include/octomap/OccupancyOcTreeBase.h b/octomap/include/octomap/OccupancyOcTreeBase.h index 342a5fe3..8b7f535a 100644 --- a/octomap/include/octomap/OccupancyOcTreeBase.h +++ b/octomap/include/octomap/OccupancyOcTreeBase.h @@ -174,7 +174,7 @@ namespace octomap { * octree level * * @param key OcTreeKey of the NODE that is to be updated - * @param log_odds_update value to be added (+) to log_odds value of node + * @param log_odds_value value to be set as the log_odds value of the node * @param lazy_eval whether update of inner nodes is omitted after the update (default: false). * This speeds up the insertion, but you need to call updateInnerOccupancy() when done. * @return pointer to the updated NODE @@ -186,7 +186,7 @@ namespace octomap { * Looks up the OcTreeKey corresponding to the coordinate and then calls setNodeValue() with it. * * @param value 3d coordinate of the NODE that is to be updated - * @param log_odds_update value to be added (+) to log_odds value of node + * @param log_odds_value value to be set as the log_odds value of the node * @param lazy_eval whether update of inner nodes is omitted after the update (default: false). * This speeds up the insertion, but you need to call updateInnerOccupancy() when done. * @return pointer to the updated NODE @@ -200,7 +200,7 @@ namespace octomap { * @param x * @param y * @param z - * @param log_odds_update value to be added (+) to log_odds value of node + * @param log_odds_value value to be set as the log_odds value of the node * @param lazy_eval whether update of inner nodes is omitted after the update (default: false). * This speeds up the insertion, but you need to call updateInnerOccupancy() when done. * @return pointer to the updated NODE From a4ecae21478d3376bac91c3acaf643d0345d3a42 Mon Sep 17 00:00:00 2001 From: Armin Hornung Date: Sun, 31 Jan 2016 11:30:13 +0100 Subject: [PATCH 17/17] Version 1.7.1 release --- dynamicEDT3D/CMakeLists.txt | 2 +- dynamicEDT3D/package.xml | 2 +- octomap/CHANGELOG.txt | 16 ++++++++++++++++ octomap/CMakeLists.txt | 2 +- octomap/package.xml | 6 +++--- octovis/CMakeLists.txt | 2 +- octovis/package.xml | 6 +++--- 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt index c40271f0..6b7c46b7 100644 --- a/dynamicEDT3D/CMakeLists.txt +++ b/dynamicEDT3D/CMakeLists.txt @@ -6,7 +6,7 @@ ENABLE_TESTING() # version (e.g. for packaging) set(DYNAMICEDT3D_MAJOR_VERSION 1) set(DYNAMICEDT3D_MINOR_VERSION 7) -set(DYNAMICEDT3D_PATCH_VERSION 0) +set(DYNAMICEDT3D_PATCH_VERSION 1) set(DYNAMICEDT3D_VERSION ${DYNAMICEDT3D_MAJOR_VERSION}.${DYNAMICEDT3D_MINOR_VERSION}.${DYNAMICEDT3D_PATCH_VERSION}) set(DYNAMICEDT3D_SOVERSION ${DYNAMICEDT3D_MAJOR_VERSION}.${DYNAMICEDT3D_MINOR_VERSION}) diff --git a/dynamicEDT3D/package.xml b/dynamicEDT3D/package.xml index b79de94f..ec3e9501 100644 --- a/dynamicEDT3D/package.xml +++ b/dynamicEDT3D/package.xml @@ -1,6 +1,6 @@ dynamic_edt_3d - 1.7.0 + 1.7.1 The dynamicEDT3D library implements an inrementally updatable Euclidean distance transform (EDT) in 3D. It comes with a wrapper to use the OctoMap 3D representation and hooks into the change detection of the OctoMap library to propagate changes to the EDT. Christoph Sprunk diff --git a/octomap/CHANGELOG.txt b/octomap/CHANGELOG.txt index b5bfe550..d0ef4301 100644 --- a/octomap/CHANGELOG.txt +++ b/octomap/CHANGELOG.txt @@ -1,3 +1,13 @@ +v1.7.1: 2016-01-31 +================== +- Fixed #82: Enable uninstall target for complete project +- Fixed #47: Exported CMake library paths for Windows no longer + have the Release/Debug prefix and correctly contain the .lib file +- Fixed #51: IO factory class registry with MSVC. Calling a dummy + function from an OcTree class c'tor enables reading general .ot files + when compiling with MSVC +- Fixed #100: Explicit casts to avoid warnings with MSVC + v1.7.0: 2015-11-27 ================== - BBX iterators fixed for empty trees (thx to F. Boniardi) @@ -8,6 +18,12 @@ v1.7.0: 2015-11-27 A. Ecins) - Fixed hashing overflow with clang (thx to L. Riano) + +v1.6.9: 2016-01-13 +================== +- Maintenance release for ROS: + Added function to determine state of change detection + v1.6.7: 2014-08-31 ================== - FSF address in octovis license header for OctoMap package in Fedora diff --git a/octomap/CMakeLists.txt b/octomap/CMakeLists.txt index 9a601a7d..d9f23114 100644 --- a/octomap/CMakeLists.txt +++ b/octomap/CMakeLists.txt @@ -6,7 +6,7 @@ ENABLE_TESTING() # version (e.g. for packaging) set(OCTOMAP_MAJOR_VERSION 1) set(OCTOMAP_MINOR_VERSION 7) -set(OCTOMAP_PATCH_VERSION 0) +set(OCTOMAP_PATCH_VERSION 1) set(OCTOMAP_VERSION ${OCTOMAP_MAJOR_VERSION}.${OCTOMAP_MINOR_VERSION}.${OCTOMAP_PATCH_VERSION}) set(OCTOMAP_SOVERSION ${OCTOMAP_MAJOR_VERSION}.${OCTOMAP_MINOR_VERSION}) if(COMMAND cmake_policy) diff --git a/octomap/package.xml b/octomap/package.xml index 303fb4ce..1d3a6491 100644 --- a/octomap/package.xml +++ b/octomap/package.xml @@ -1,12 +1,12 @@ octomap - 1.7.0 + 1.7.1 The OctoMap library implements a 3D occupancy grid mapping approach, providing data structures and mapping algorithms in C++. The map implementation is based on an octree. See http://octomap.github.io for details. Kai M. Wurm - Armin Hornung - Armin Hornung + Armin Hornung + Armin Hornung BSD http://octomap.github.io diff --git a/octovis/CMakeLists.txt b/octovis/CMakeLists.txt index 40b19fe3..4ba703a8 100644 --- a/octovis/CMakeLists.txt +++ b/octovis/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT( octovis ) # # version (e.g. for packaging) set(OCTOVIS_MAJOR_VERSION 1) set(OCTOVIS_MINOR_VERSION 7) -set(OCTOVIS_PATCH_VERSION 0) +set(OCTOVIS_PATCH_VERSION 1) set(OCTOVIS_VERSION ${OCTOVIS_MAJOR_VERSION}.${OCTOVIS_MINOR_VERSION}.${OCTOVIS_PATCH_VERSION}) set(OCTOVIS_SOVERSION ${OCTOVIS_MAJOR_VERSION}.${OCTOVIS_MINOR_VERSION}) # get rid of a useless warning: diff --git a/octovis/package.xml b/octovis/package.xml index e9f579a7..408570c6 100644 --- a/octovis/package.xml +++ b/octovis/package.xml @@ -1,12 +1,12 @@ octovis - 1.7.0 + 1.7.1 octovis is visualization tool for the OctoMap library based on Qt and libQGLViewer. See http://octomap.github.io for details. Kai M. Wurm - Armin Hornung - Armin Hornung + Armin Hornung + Armin Hornung GPLv2 http://octomap.github.io