ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Essentially, what you are trying to do is create an overlay of octomap on top of your installed version. First thing to understand is that "octomap" is no longer a regular ros package that gets found with "rosmake", so it does not need to be in your ROS_PACKAGE_PATH. There is no manifest.xml or package.xml in it (only some pre-built versions may contain it for packaging reasons).

Instead, octomap is a regular CMake package that octomap_server locates using CMake's FIND_PACKAGE mechanism in the CMakeLists.txt. For this octomap provides a file "octomap-config.cmake" that contains all the linker and compiler flags and dirs. ROS picks it up in /opt/ros/fuerte/lib/cmake/octomap since the setup.bash sets the variable $CMAKE_PREFIX_PATH.

You can manually specify the path for CMake by setting the variable "octomap_DIR" to the directory containing octomap-config.cmake (either build or install location, both should work) before compiling. E.g.:

export octomap_DIR=/scratch/octomap-devel-openmp/octomap/lib/cmake/octomap
rosmake octomap_server

This should then pick up the correct version, but I have also seen occasion where rosbuild preferred the installed version instead, I don't know why that happens.

To work around that, it may be necessary to remove the installed ros-fuerte-octomap, or try to use the version argument in CMake's find_package in octomap_server:

find_package(octomap 1.5)

The installed version in Fuerte is 1.4, so CMake should skip over that one.

Essentially, what you are trying to do is create an overlay of octomap on top of your installed version. First thing to understand is that "octomap" is no longer a regular ros package that gets found with "rosmake", so it does not need to be in your ROS_PACKAGE_PATH. There is no manifest.xml or package.xml in it (only some pre-built versions may contain it for packaging reasons).

Instead, octomap is a regular CMake package that octomap_server locates using CMake's FIND_PACKAGE mechanism in the CMakeLists.txt. For this octomap provides a file "octomap-config.cmake" that contains all the linker and compiler flags and dirs. ROS picks it up in /opt/ros/fuerte/lib/cmake/octomap since the setup.bash sets the variable $CMAKE_PREFIX_PATH.

You can manually specify the path for CMake by setting the variable "octomap_DIR" to the directory containing octomap-config.cmake (either build or install location, both should work) before compiling. E.g.:

export octomap_DIR=/scratch/octomap-devel-openmp/octomap/lib/cmake/octomap
rosmake octomap_server

This should then pick up the correct version, but I have also seen occasion where rosbuild preferred the installed version instead, I don't know why that happens.

To work around that, it may be necessary to remove the installed ros-fuerte-octomap, or try to use the version argument in CMake's find_package in octomap_server:

find_package(octomap 1.5)
1.5 REQUIRED)

The installed version in Fuerte is 1.4, so CMake should skip over that one.


Update: Some remarks to your lines in CMakeLists: Don't include octomap-config.cmake, instead point the environment variable octomap_DIR to the directory containing it and use find_package. Your include_directories path is wrong, you need to remove the trailing "octomap". Otherwise is looks good. Here are the lines working for me:

find_package(octomap 1.5 REQUIRED)
include_directories(BEFORE ${OCTOMAP_INCLUDE_DIRS})
link_directories(${OCTOMAP_LIBRARY_DIRS})
link_libraries(${PROJECT_NAME} ${OCTOMAP_LIBRARY_DIRS}/liboctomap.so ${OCTOMAP_LIBRARY_DIRS}/liboctomath.so)
MESSAGE(STATUS "OctoMap paths:" ${OCTOMAP_INCLUDE_DIRS} " " ${OCTOMAP_LIBRARY_DIRS})

I found that CMakeLists.txt picks up the right paths (see the status message in the last line), but rosmake ignores it and uses its own path for headers and picks up liboctomap from LD_LIBRARY_PATH instead. Adding BEFORE to include_directories fixes the first problem, while the absolute library paths in link_libraries fixes the second. OctoMap will fix that in a new release.

However, you will now notice that octomap_server for fuerte will no longer compile since it relies on OctoMap 1.4 and the devel branches on github will aim for a 1.6 release. You will have more luck with the groovy version at http://alufr-ros-pkg.googlecode.com/svn/branches/octomap_stacks-groovy-devel/octomap_mapping/ (although the changes are small, and should be easy to apply).