Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt cmake for Bullet #1744

Merged
merged 7 commits into from Jan 17, 2020

Conversation

j-petit
Copy link
Contributor

@j-petit j-petit commented Nov 20, 2019

Description

This PR adapts the build process in order to add the Bullet dependent code only if the available version is greater than Bullet version 2.86 (2.87 is the one available through apt on Ubuntu 18.04).

@j-petit j-petit changed the title [WIP] Adapt cmake for Bullet Adapt cmake for Bullet Nov 20, 2019
Comment on lines 29 to 32
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why you added this?

Especially the BULLET_LIBRARIES values seem strange, as CMake typically uses absolute paths to libraries, and BULLET_LIBRARIES should already contain the proper values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow, the BulletConfig.cmake file coming with libbullet-dev does not fit the library files coming with it. I was also wondering why this is the case. See the content of the config:

#                                               -*- cmake -*-
#
#  BulletConfig.cmake(.in)
#

# Use the following variables to compile and link against Bullet:
#  BULLET_FOUND              - True if Bullet was found on your system
#  BULLET_USE_FILE           - The file making Bullet usable
#  BULLET_DEFINITIONS        - Definitions needed to build with Bullet
#  BULLET_INCLUDE_DIR        - Directory where Bullet-C-Api.h can be found
#  BULLET_INCLUDE_DIRS       - List of directories of Bullet and it's dependencies
#  BULLET_LIBRARIES          - List of libraries to link against Bullet library
#  BULLET_LIBRARY_DIRS       - List of directories containing Bullet' libraries
#  BULLET_ROOT_DIR           - The base directory of Bullet
#  BULLET_VERSION_STRING     - A human-readable string containing the version

set ( BULLET_FOUND 1 )
set ( BULLET_USE_FILE     "lib/x86_64-linux-gnu/cmake/bullet/UseBullet.cmake" )
set ( BULLET_DEFINITIONS  "" )
set ( BULLET_INCLUDE_DIR  "include/bullet" )
set ( BULLET_INCLUDE_DIRS "include/bullet" )
set ( BULLET_LIBRARIES    "LinearMath;Bullet3Common;BulletInverseDynamics;BulletCollision;BulletDynamics;BulletSoftBody" )
set ( BULLET_LIBRARY_DIRS "lib/x86_64-linux-gnu" )
set ( BULLET_ROOT_DIR     "/usr" )
set ( BULLET_VERSION_STRING "2.87" )

And see the files coming with it at https://packages.ubuntu.com/bionic/i386/libbullet-dev/filelist. There is no BulletInverseDynamics coming with this package. I am also not very happy about the fact that I have to define them manually and do this concatenation with the root directory.. any ideas?

Copy link
Contributor Author

@j-petit j-petit Nov 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I simply use find_package(Bullet) this works fine, as it uses the FindBullet.cmake. However, this does not include the version number.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this approach as well. What about providing our own FindBullet.cmake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this file provided by the cmake installation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any proposals where in the source tree such a file should go?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In moveit_core/CMakeModules? In moveit_core/CMakeLists.txt you'd add something like this:

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")

find_package(Bullet)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am struggling to get this running. My idea is to have the custom FindBullet.cmake be more or less a replicate of the official one plus checking somehow the BulletConfig.cmake which comes with libbullet-dev for the BULLET_VERSION_STRING.

However if I do include(.../BulletConfig.cmake) in the FindBullet.cmake I get all the variables set which clutters the FindBullet.cmake to the point that I cannot build succesfully anymore. I would like to only partially include the BulletConfig.cmake but I cannot find that option in cmake.

Any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use the cmake PkgConfig module (since bullet also has a bullet.pc file). Your FindBullet.cmake might then look something like this:

include(FindPackageHandleStandardArgs)
find_package(PkgConfig)
if(PKGCONFIG_FOUND)
    pkg_check_modules(bullet>=2.88)
endif()
find_package_handle_standard_args(Bullet DEFAULT_MSG BULLET_LIBRARIES BULLET_INCLUDE_DIRS)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That worked :), thank you @mamoll for the help!

@j-petit j-petit mentioned this pull request Nov 20, 2019
.travis.yml Show resolved Hide resolved
# TODO: Move collision detection into separate packages
find_package(Bullet REQUIRED)

# TODO: Move collision detection into separate packages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will this entail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added as suggested here by @rhaschke.

Later, we should factor out FCL and Bullet collision checking into their own packages. Maybe add a todo as a reminder here.

So I guess create stand-alone packages?

@rhaschke
Copy link
Contributor

@j-petit, this needs to be rebased onto the (rebased) feature branch now...

moveit_core/CMakeLists.txt Outdated Show resolved Hide resolved
moveit_core/CMakeLists.txt Outdated Show resolved Hide resolved
@j-petit
Copy link
Contributor Author

j-petit commented Jan 12, 2020

Travis fails because the feature branch is behind master (issues with moveit_tutorials, therefore I created a rebase PR in #1831.

@j-petit
Copy link
Contributor Author

j-petit commented Jan 13, 2020

So it passes, can someone give this a final review?

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (feature-bullet-trajopt@753604c). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@                    Coverage Diff                    @@
##             feature-bullet-trajopt    #1744   +/-   ##
=========================================================
  Coverage                          ?   50.29%           
=========================================================
  Files                             ?      312           
  Lines                             ?    24536           
  Branches                          ?        0           
=========================================================
  Hits                              ?    12341           
  Misses                            ?    12195           
  Partials                          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 753604c...6bab622. Read the comment docs.

@j-petit
Copy link
Contributor Author

j-petit commented Jan 17, 2020

Ping @mamoll

find_package(PkgConfig)

if(PKGCONFIG_FOUND)
pkg_check_modules(BULLET bullet)
Copy link
Contributor

@mamoll mamoll Jan 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be

pkg_check_modules(BULLET Bullet>=${Bullet_FIND_VERSION})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the version is handled in the last line through VERSION_VAR BULLET_VERSION which makes it possible to use find_package(Bullet 2.87) in the moveit_core/CMakeLists.txt. I found that clearer to have the requirement for the Bullet version in the moveit_core/CmakeLists.txt instead of hidden inside the FindBullet.cmake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that. That's even better.

@mamoll mamoll merged commit 8f75792 into moveit:feature-bullet-trajopt Jan 17, 2020
davetcoleman pushed a commit that referenced this pull request Jan 23, 2020
* Empty collision checker template for usage with tesseract and bullet (#1499)

* Adding documentation to collision detection (#1488)

* CMake adaptions for Tesseract integration

* Empty collision detector template for tesseract and bullet

* Making bullet as a collision plugin available

* Adding missing error messages

* Adding new folders and libraries to cmake

* Fixing the BSD license

* clang-format

* Generic collision detection test suite (#1543)

Generalize collision detection tests by using a templated test fixture.

* Bullet Collision Detection (#1504)

* Added discrete BVH Bullet manager
* Added continuous collision detection
* Cleanup of tesseract code
   * removed simple collision managers
   * changed enum to enum classes
   * fixed typos
   * removing debugging statements
   * removing tesseract allowed collision matrix
   * removed tesseract macros
   * replaced typedefs of stl containers
   * removed tesseract attached object code
   * ACM members of collision robot and world removed and ACM check into callback out of class
   * remove ContactTestType and replace through MoveIt CollisionRequest
   * BodyType int changed to enum
   * removed tesseract_msgs dependency and unnecessary tesseract code
   * changed dependency from bullet3_ros to debian Bullet package

* Adding bullet and tesseract simple collision manager to the template:
   * added benchmark case for checking collision speed
   * tests for bullet collision checking

* Adding missing features:
  * attached objects
  * contact reporting max number of contacts fixed
  * Bullet plugin xml name fixed
  * padding and scaling for robot added
  * updated tests

* Adding continuous collision detection to Bullet (#1551)

* Adding continous collision detection:
  * check only active links added
  * benchmark FCL vs Bullet
  * renaming files from bt to bullet
  * renaming variables from bt to bullet
  * clang-tidy and clang-format
  * renaming of variables to be in moveit format
  * continuous tests added
  * CCD active links changed
  * distance testing added to panda test suite

* New collision features:
  * broadphase early culling
  * minimal distance reporting
  * renaming collision filter and group
  * removed extra margin on AABB for bullet
  * ACM in test from SRDF

* PR review

* Unified Collision Environment Bullet (#1572)

* Templated tests adapted for unified collision env

* Unified Bullet collision environment:
  * broadphase filtering adapted for early culling
  * ACM from SRDF in test
  * cleanup for bullet single collision env
  * removed link2castcow for CCD and only use constructor of COW directly
  * parent class for collision managers
  * removed function pointer for ACM check
  * removed extra self-collision manager and use only single manager
  * speed benchmark for unified environment

* PR review:
  * more descriptive variable names
  * added user to TODO

* PR review:
  * shortening namespace
  * documentation improvements
  * virtual destructor of BVH manager
  * remove extra speed benchmark
  * bugfix for not initialized managers

* Licenses revised of old tesseract files

* PR review:
  * replaced include guards through pragma
  * used default instead of empty {} for ctor/dtor

* Comments in Bullet readme about thread safety and speed

* Readme for speed benchmark (#1648)

* FCL Bullet benchmark readme
  * Benchmark script and launch file updated

* PR review fixups

* Adapt cmake for Bullet (#1744)

* cmake for using Bullet only if correct version available

* Fixup

* PR review fixup

* Rewrite with own FindBullet.cmake

* Use pkg-config

* Fix travis failure for melodic

* Fix moveit_ros_planning dependency on Bullet

* Rename PR2-related collision test files (#1856)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants