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

Unable to compile code with pinocchio::computeCollisions() with ROS 2 Humble binary install #2289

Closed
scastro-bdai opened this issue Jun 18, 2024 · 8 comments

Comments

@scastro-bdai
Copy link

scastro-bdai commented Jun 18, 2024

Bug description

I've installed ros-humble-pinocchio package (it's version 2.6.21) which claims to have HPP-FCL support. However, I don't seem to be able to use collision checking functions.

Expected behavior

Compiling code that calls computeCollisions() should work.

Reproduction steps

I've successfully written a good deal of code, that loads models and computes forward kinematics and Jacobians... but when I try to bring in the computeCollisions() functions I get a build error:

error: ‘computeCollisions’ is not a member of ‘pinocchio’

I have included the header: #include "pinocchio/algorithm/geometry.hpp", which appears to be the right one for 2.6.21.

Am I missing something obvious, or is there an issue with HPP-FCL support in the installed version?

I also tried to build Pinocchio 2.6.21 from source, and even after hard-coding the CMake option to build with collision support, this issue still persists. Seems none of the unit tests / examples involving collisions were compiled regardless... but I'm also very bad at understanding CMake, so it's likely user error.

System

  • OS: Ubuntu 22.04
  • Pinocchio version: 2.6.21 (from binaries)
@jcarpent
Copy link
Contributor

@wxmerkt @nim65s Any clue on this issue?

@nim65s
Copy link
Contributor

nim65s commented Jun 19, 2024

I'll be able to look into this next week, if @wxmerkt doesn't have any spare time before that

@jcarpent
Copy link
Contributor

@scastro-bdai Could you provide reproducible command lines to try quickly in a docker image?

@sea-bass
Copy link
Contributor

sea-bass commented Jun 19, 2024

Switching to my personal account, but it's still me!

I've made a simple repo here: https://github.com/sea-bass/pinocchio_ros_cpp_example

As stated in the repo README, you should be able to do:

docker compose build
docker compose run base

Once you're in the container, you can do colcon build to build the package, which should work fine.

Now go into the file pinocchio_ros_example/src/pinocchio_example.cpp and uncomment these lines that call computeCollisions(). Building again, you'll find my error:

/workspace/src/pinocchio_ros_example/src/pinocchio_example.cpp:16:28: error: ‘computeCollisions’ is not a member of ‘pinocchio’
   16 |   auto result = pinocchio::computeCollisions(model, data, collision_model, collision_data, q);

@wxmerkt
Copy link
Member

wxmerkt commented Jun 22, 2024

Checking the binary build log shows that it compiles with PINOCCHIO_WITH_HPP_FCL and also runs the collision tests successfully: https://build.ros2.org/job/Hbin_uJ64__pinocchio__ubuntu_jammy_amd64__binary/95/consoleFull

Debug notes:

Running the standard Docker image, installing Pinocchio from binaries shows HPP_FCL is included:

docker run -it --rm ros:humble /bin/bash
apt update && apt install -y ros-humble-pinocchio
python3 -c "import pinocchio ; print(pinocchio.WITH_HPP_FCL)"

When using the repro example (thank you!), it shows that it cannot find hpp-fcl during configuration. This is because it's not included in the exported dependencies, e.g. adding

message (WARNING ${pinocchio_LIBRARIES})

shows that we are not linking to or exporting the dependency to hpp-fcl.

However, we can see that the pinocchioTargets.cmake includes hpp-fcl for the pinocchio::pinocchio target.

So with this workaround, it compiles and runs:

ament_target_dependencies(pinocchio_example Eigen3 eigen3_cmake_module)
target_link_libraries(pinocchio_example PUBLIC pinocchio::pinocchio)

I.e. linking directly using CMake rather than using ament. I am not too familiar with ament so cannot say where exactly the packaging issue comes in.

I fixed your example with this workaround and now it works fine: wxmerkt/pinocchio_ros_cpp_example@d000ca6

@sea-bass
Copy link
Contributor

Brilliant, thank you for looking into this!

I also don't know much about the inner workings of ament, but this workaround will for sure let us carry on with our work, without the need to build Pinocchio from source.

@nim65s
Copy link
Contributor

nim65s commented Jun 24, 2024

Thanks @wxmerkt !

@nim65s nim65s closed this as completed Jun 24, 2024
@sea-bass
Copy link
Contributor

By the way... I fleshed out the example in https://github.com/sea-bass/pinocchio_ros_cpp_example, so now it runs and hopefully serves as an example for people using ROS 2 with Pinocchio.

If there is any interest in this going in the regular documentation here, I'm happy to donate this example so it doesn't live on my personal account.

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

No branches or pull requests

5 participants