From a92adff9cdd8e150c1ce918cf35e33310230e468 Mon Sep 17 00:00:00 2001 From: Jens Petit Date: Wed, 20 Nov 2019 13:45:14 +0100 Subject: [PATCH 1/7] cmake for using Bullet only if correct version available --- moveit_core/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/moveit_core/CMakeLists.txt b/moveit_core/CMakeLists.txt index 57f19a86be..d8813475cd 100644 --- a/moveit_core/CMakeLists.txt +++ b/moveit_core/CMakeLists.txt @@ -22,7 +22,13 @@ endif() find_package(Boost REQUIRED system filesystem date_time thread iostreams) find_package(Eigen3 REQUIRED) # TODO: Move collision detection into separate packages -find_package(Bullet REQUIRED) + +find_package(Bullet CONFIG) +if (BULLET_VERSION_STRING VERSION_GREATER "2.86") + set(MOVEIT_HAVE_BULLET 1) + # TODO: Add here all cmake code which is bullet specific + add_subdirectory(collision_detection_bullet) +endif() find_package(PkgConfig REQUIRED) pkg_check_modules(LIBFCL_PC REQUIRED fcl) From f13e30fd15d2e56a91cb150c9a8099589f868a60 Mon Sep 17 00:00:00 2001 From: Jens Petit Date: Wed, 20 Nov 2019 16:42:38 +0100 Subject: [PATCH 2/7] Fixup --- .travis.yml | 1 + moveit_core/CMakeLists.txt | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c51f7602da..6ed584a5ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ env: - TEST="clang-format catkin_lint" - TEST=code-coverage - ROS_DISTRO=melodic + - ROS_DISTRO=kinetic matrix: # Add a separate config to the matrix, using clang as compiler include: diff --git a/moveit_core/CMakeLists.txt b/moveit_core/CMakeLists.txt index d8813475cd..7d1d30c5c8 100644 --- a/moveit_core/CMakeLists.txt +++ b/moveit_core/CMakeLists.txt @@ -21,13 +21,18 @@ endif() find_package(Boost REQUIRED system filesystem date_time thread iostreams) find_package(Eigen3 REQUIRED) - # TODO: Move collision detection into separate packages +# TODO: Move collision detection into separate packages find_package(Bullet CONFIG) -if (BULLET_VERSION_STRING VERSION_GREATER "2.86") - set(MOVEIT_HAVE_BULLET 1) - # TODO: Add here all cmake code which is bullet specific - add_subdirectory(collision_detection_bullet) +if(BULLET_FOUND AND BULLET_VERSION_STRING VERSION_GREATER "2.86") + set(BULLET_ENABLE "BULLET") + set(BULLET_INCLUDE_DIRS "${BULLET_ROOT_DIR}/${BULLET_INCLUDE_DIRS}") + set(BULLET_INCLUDE_DIR "${BULLET_ROOT_DIR}/${BULLET_INCLUDE_DIR}") + set(BULLET_LIBRARY_DIRS "${BULLET_ROOT_DIR}/${BULLET_LIBRARY_DIRS}") + set(BULLET_LIBRARIES "libBulletDynamics.so;libBulletCollision.so;libLinearMath.so;libBulletSoftBody.so") + message(STATUS "Compiling with Bullet") +else() + message(STATUS "Version of Bullet too old or not available: disabling Bullet collision detection plugin") endif() find_package(PkgConfig REQUIRED) @@ -151,7 +156,7 @@ catkin_package( OCTOMAP urdfdom urdfdom_headers - BULLET + ${BULLET_ENABLE} ) include_directories(SYSTEM ${EIGEN3_INCLUDE_DIRS} @@ -196,7 +201,6 @@ add_subdirectory(robot_state) add_subdirectory(robot_trajectory) add_subdirectory(collision_detection) add_subdirectory(collision_detection_fcl) -add_subdirectory(collision_detection_bullet) add_subdirectory(kinematic_constraints) add_subdirectory(planning_scene) add_subdirectory(constraint_samplers) @@ -207,3 +211,7 @@ add_subdirectory(distance_field) add_subdirectory(collision_distance_field) add_subdirectory(kinematics_metrics) add_subdirectory(dynamics_solver) + +if(BULLET_ENABLE) + add_subdirectory(collision_detection_bullet) +endif() From c620e2789a482573c3f80a70f83524bdd87fbe1c Mon Sep 17 00:00:00 2001 From: Jens Petit Date: Mon, 25 Nov 2019 17:09:24 +0100 Subject: [PATCH 3/7] PR review fixup --- moveit_core/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/moveit_core/CMakeLists.txt b/moveit_core/CMakeLists.txt index 7d1d30c5c8..fd74383c17 100644 --- a/moveit_core/CMakeLists.txt +++ b/moveit_core/CMakeLists.txt @@ -24,6 +24,8 @@ find_package(Eigen3 REQUIRED) # TODO: Move collision detection into separate packages find_package(Bullet CONFIG) + +# TODO(j-petit): Version check can be dropped when Xenial reaches end-of-life if(BULLET_FOUND AND BULLET_VERSION_STRING VERSION_GREATER "2.86") set(BULLET_ENABLE "BULLET") set(BULLET_INCLUDE_DIRS "${BULLET_ROOT_DIR}/${BULLET_INCLUDE_DIRS}") @@ -32,7 +34,7 @@ if(BULLET_FOUND AND BULLET_VERSION_STRING VERSION_GREATER "2.86") set(BULLET_LIBRARIES "libBulletDynamics.so;libBulletCollision.so;libLinearMath.so;libBulletSoftBody.so") message(STATUS "Compiling with Bullet") else() - message(STATUS "Version of Bullet too old or not available: disabling Bullet collision detection plugin") + message(STATUS "Version of Bullet too old or not available: disabling Bullet collision detection plugin. Try using Ubuntu 18.04 or later.") endif() find_package(PkgConfig REQUIRED) From 6fa57e8c05a89fa2dce6290eaa30ce6a198646bc Mon Sep 17 00:00:00 2001 From: Jens Petit Date: Tue, 7 Jan 2020 12:22:59 +0100 Subject: [PATCH 4/7] Rewrite with own FindBullet.cmake --- moveit_core/CMakeLists.txt | 8 +- moveit_core/CMakeModules/FindBullet.cmake | 96 +++++++++++++++++++++++ 2 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 moveit_core/CMakeModules/FindBullet.cmake diff --git a/moveit_core/CMakeLists.txt b/moveit_core/CMakeLists.txt index fd74383c17..630ad7420d 100644 --- a/moveit_core/CMakeLists.txt +++ b/moveit_core/CMakeLists.txt @@ -22,16 +22,14 @@ endif() find_package(Boost REQUIRED system filesystem date_time thread iostreams) find_package(Eigen3 REQUIRED) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") + # TODO: Move collision detection into separate packages -find_package(Bullet CONFIG) +find_package(Bullet) # TODO(j-petit): Version check can be dropped when Xenial reaches end-of-life if(BULLET_FOUND AND BULLET_VERSION_STRING VERSION_GREATER "2.86") set(BULLET_ENABLE "BULLET") - set(BULLET_INCLUDE_DIRS "${BULLET_ROOT_DIR}/${BULLET_INCLUDE_DIRS}") - set(BULLET_INCLUDE_DIR "${BULLET_ROOT_DIR}/${BULLET_INCLUDE_DIR}") - set(BULLET_LIBRARY_DIRS "${BULLET_ROOT_DIR}/${BULLET_LIBRARY_DIRS}") - set(BULLET_LIBRARIES "libBulletDynamics.so;libBulletCollision.so;libLinearMath.so;libBulletSoftBody.so") message(STATUS "Compiling with Bullet") else() message(STATUS "Version of Bullet too old or not available: disabling Bullet collision detection plugin. Try using Ubuntu 18.04 or later.") diff --git a/moveit_core/CMakeModules/FindBullet.cmake b/moveit_core/CMakeModules/FindBullet.cmake new file mode 100644 index 0000000000..fa9b02d69b --- /dev/null +++ b/moveit_core/CMakeModules/FindBullet.cmake @@ -0,0 +1,96 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindBullet +# ---------- +# +# Try to find the Bullet physics engine +# +# +# +# :: +# +# This module defines the following variables +# +# +# +# :: +# +# BULLET_FOUND - Was bullet found +# BULLET_INCLUDE_DIRS - the Bullet include directories +# BULLET_LIBRARIES - Link to this, by default it includes +# all bullet components (Dynamics, +# Collision, LinearMath, & SoftBody) +# +# +# +# :: +# +# This module accepts the following variables +# +# +# +# :: +# +# BULLET_ROOT - Can be set to bullet install path or Windows build path + +if(EXISTS "/usr/lib/x86_64-linux-gnu/cmake/bullet/BulletConfig.cmake") + include("/usr/lib/x86_64-linux-gnu/cmake/bullet/BulletConfig.cmake") +endif() + +macro(_FIND_BULLET_LIBRARY _var) + find_library(${_var} + NAMES + ${ARGN} + HINTS + ${BULLET_ROOT} + ${BULLET_ROOT}/lib/Release + ${BULLET_ROOT}/lib/Debug + ${BULLET_ROOT}/out/release8/libs + ${BULLET_ROOT}/out/debug8/libs + PATH_SUFFIXES lib + ) + mark_as_advanced(${_var}) +endmacro() + +macro(_BULLET_APPEND_LIBRARIES _list _release) + set(_debug ${_release}_DEBUG) + if(${_debug}) + set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}}) + else() + set(${_list} ${${_list}} ${${_release}}) + endif() +endmacro() + +find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h + HINTS + ${BULLET_ROOT}/include + ${BULLET_ROOT}/src + PATH_SUFFIXES bullet +) + +# Find the libraries + +_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics) +_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_Debug BulletDynamics_d) +_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision) +_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d) +_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY BulletMath LinearMath) +_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_Debug LinearMath_d) +_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody) +_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_Debug BulletSoftBody_d) + + +find_package(PackageHandleStandardArgs REQUIRED) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG + BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY + BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR) + +set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR}) +if(BULLET_FOUND) + _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY) + _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY) + _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY) + _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_SOFTBODY_LIBRARY) +endif() From 16a898ff0cc09ac4682ddcc310497542f914542c Mon Sep 17 00:00:00 2001 From: Jens Petit Date: Wed, 8 Jan 2020 10:45:13 +0100 Subject: [PATCH 5/7] Use pkg-config --- moveit_core/CMakeLists.txt | 5 +- moveit_core/CMakeModules/FindBullet.cmake | 100 ++-------------------- 2 files changed, 10 insertions(+), 95 deletions(-) diff --git a/moveit_core/CMakeLists.txt b/moveit_core/CMakeLists.txt index 630ad7420d..345c15683a 100644 --- a/moveit_core/CMakeLists.txt +++ b/moveit_core/CMakeLists.txt @@ -25,10 +25,10 @@ find_package(Eigen3 REQUIRED) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") # TODO: Move collision detection into separate packages -find_package(Bullet) +find_package(Bullet 2.87) # TODO(j-petit): Version check can be dropped when Xenial reaches end-of-life -if(BULLET_FOUND AND BULLET_VERSION_STRING VERSION_GREATER "2.86") +if(BULLET_FOUND) set(BULLET_ENABLE "BULLET") message(STATUS "Compiling with Bullet") else() @@ -41,6 +41,7 @@ pkg_check_modules(LIBFCL_PC REQUIRED fcl) find_path(LIBFCL_INCLUDE_DIRS fcl/config.h HINTS ${LIBFCL_PC_INCLUDE_DIR} ${LIBFCL_PC_INCLUDE_DIRS}) find_library(LIBFCL_LIBRARIES fcl HINTS ${LIBFCL_PC_LIBRARY_DIRS}) + find_package(octomap REQUIRED) find_package(urdfdom REQUIRED) find_package(urdfdom_headers REQUIRED) diff --git a/moveit_core/CMakeModules/FindBullet.cmake b/moveit_core/CMakeModules/FindBullet.cmake index fa9b02d69b..1dff096d89 100644 --- a/moveit_core/CMakeModules/FindBullet.cmake +++ b/moveit_core/CMakeModules/FindBullet.cmake @@ -1,96 +1,10 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. +include(FindPackageHandleStandardArgs) +find_package(PkgConfig) -#.rst: -# FindBullet -# ---------- -# -# Try to find the Bullet physics engine -# -# -# -# :: -# -# This module defines the following variables -# -# -# -# :: -# -# BULLET_FOUND - Was bullet found -# BULLET_INCLUDE_DIRS - the Bullet include directories -# BULLET_LIBRARIES - Link to this, by default it includes -# all bullet components (Dynamics, -# Collision, LinearMath, & SoftBody) -# -# -# -# :: -# -# This module accepts the following variables -# -# -# -# :: -# -# BULLET_ROOT - Can be set to bullet install path or Windows build path - -if(EXISTS "/usr/lib/x86_64-linux-gnu/cmake/bullet/BulletConfig.cmake") - include("/usr/lib/x86_64-linux-gnu/cmake/bullet/BulletConfig.cmake") +if(PKGCONFIG_FOUND) + pkg_check_modules(BULLET bullet) endif() -macro(_FIND_BULLET_LIBRARY _var) - find_library(${_var} - NAMES - ${ARGN} - HINTS - ${BULLET_ROOT} - ${BULLET_ROOT}/lib/Release - ${BULLET_ROOT}/lib/Debug - ${BULLET_ROOT}/out/release8/libs - ${BULLET_ROOT}/out/debug8/libs - PATH_SUFFIXES lib - ) - mark_as_advanced(${_var}) -endmacro() - -macro(_BULLET_APPEND_LIBRARIES _list _release) - set(_debug ${_release}_DEBUG) - if(${_debug}) - set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}}) - else() - set(${_list} ${${_list}} ${${_release}}) - endif() -endmacro() - -find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h - HINTS - ${BULLET_ROOT}/include - ${BULLET_ROOT}/src - PATH_SUFFIXES bullet -) - -# Find the libraries - -_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics) -_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_Debug BulletDynamics_d) -_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision) -_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d) -_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY BulletMath LinearMath) -_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_Debug LinearMath_d) -_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody) -_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_Debug BulletSoftBody_d) - - -find_package(PackageHandleStandardArgs REQUIRED) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG - BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY - BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR) - -set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR}) -if(BULLET_FOUND) - _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY) - _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY) - _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY) - _BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_SOFTBODY_LIBRARY) -endif() +find_package_handle_standard_args(Bullet + REQUIRED_VARS BULLET_LIBRARIES BULLET_INCLUDE_DIRS + VERSION_VAR BULLET_VERSION) From e412224256695d7589fc6f3bf926178828724385 Mon Sep 17 00:00:00 2001 From: Jens Petit Date: Wed, 8 Jan 2020 11:25:11 +0100 Subject: [PATCH 6/7] Fix travis failure for melodic --- moveit_core/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/moveit_core/CMakeLists.txt b/moveit_core/CMakeLists.txt index 345c15683a..5f1ff12c85 100644 --- a/moveit_core/CMakeLists.txt +++ b/moveit_core/CMakeLists.txt @@ -30,6 +30,8 @@ find_package(Bullet 2.87) # TODO(j-petit): Version check can be dropped when Xenial reaches end-of-life if(BULLET_FOUND) set(BULLET_ENABLE "BULLET") + set(BULLET_LIB "moveit_collision_detection_bullet") + set(BULLET_INC "collision_detection_bullet/include") message(STATUS "Compiling with Bullet") else() message(STATUS "Version of Bullet too old or not available: disabling Bullet collision detection plugin. Try using Ubuntu 18.04 or later.") @@ -83,7 +85,7 @@ set(THIS_PACKAGE_INCLUDE_DIRS backtrace/include collision_detection/include collision_detection_fcl/include - collision_detection_bullet/include + ${BULLET_INC} constraint_samplers/include controller_manager/include distance_field/include @@ -120,7 +122,7 @@ catkin_package( moveit_planning_interface moveit_collision_detection moveit_collision_detection_fcl - moveit_collision_detection_bullet + ${BULLET_LIB} moveit_kinematic_constraints moveit_planning_scene moveit_constraint_samplers From 6bab622c1750ac81bd469ddd6407cf5b118084b4 Mon Sep 17 00:00:00 2001 From: Jens Petit Date: Sun, 12 Jan 2020 13:27:18 +0100 Subject: [PATCH 7/7] Fix moveit_ros_planning dependency on Bullet --- .../planning/planning_components_tools/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/moveit_ros/planning/planning_components_tools/CMakeLists.txt b/moveit_ros/planning/planning_components_tools/CMakeLists.txt index 77f51dacd2..4faa041dfb 100644 --- a/moveit_ros/planning/planning_components_tools/CMakeLists.txt +++ b/moveit_ros/planning/planning_components_tools/CMakeLists.txt @@ -14,8 +14,10 @@ target_link_libraries(moveit_visualize_robot_collision_volume moveit_planning_sc add_executable(moveit_evaluate_collision_checking_speed src/evaluate_collision_checking_speed.cpp) target_link_libraries(moveit_evaluate_collision_checking_speed moveit_planning_scene_monitor ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -add_executable(moveit_compare_collision_checking_speed_fcl_bullet src/compare_collision_speed_checking_fcl_bullet.cpp) -target_link_libraries(moveit_compare_collision_checking_speed_fcl_bullet moveit_planning_scene_monitor ${catkin_LIBRARIES} ${Boost_LIBRARIES}) +if("${catkin_LIBRARIES}" MATCHES "moveit_collision_detection_bullet") + add_executable(moveit_compare_collision_checking_speed_fcl_bullet src/compare_collision_speed_checking_fcl_bullet.cpp) + target_link_libraries(moveit_compare_collision_checking_speed_fcl_bullet moveit_planning_scene_monitor ${catkin_LIBRARIES} ${Boost_LIBRARIES}) +endif() add_executable(moveit_kinematics_speed_and_validity_evaluator src/kinematics_speed_and_validity_evaluator.cpp) target_link_libraries(moveit_kinematics_speed_and_validity_evaluator moveit_robot_model_loader ${catkin_LIBRARIES} ${Boost_LIBRARIES})