Home > Blockchain >  how to add pinocchio (a robotics package) as library in cmake
how to add pinocchio (a robotics package) as library in cmake

Time:12-21

I have to include pinocchio (an open-source library for robotics) in a c project via cmake, but it fails currently. (https://github.com/stack-of-tasks/pinocchio)

I've installed pinocchio c without the python bindings via

sudo apt install -qqy robotpkg-pinocchio

I've tried out the simple examples from the documentation https://gepettoweb.laas.fr/doc/stack-of-tasks/pinocchio/master/doxygen-html/index.html#OverviewComplex

If I compile it like this with the source code from the simplest example, it works:

g   -std=c  11 overview-simple.cpp -o overview-simple $(pkg-config --cflags --libs pinocchio)  

For including Pinocchio in a separate c project, I've tried the following things:

  1. finding it as a package like this:
find_package(pinocchio 2.6.10)

but it fails with this message:

By not providing "FindPinocchio.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Pinocchio", but CMake did not find one.

  Could not find a package configuration file provided by "Pinocchio"
  (requested version 2.6.10) with any of the following names:

    PinocchioConfig.cmake
    pinocchio-config.cmake

  Add the installation prefix of "Pinocchio" to CMAKE_PREFIX_PATH or set
  "Pinocchio_DIR" to a directory containing one of the above files.  If
  "Pinocchio" provides a separate development package or SDK, be sure it has
  been installed.

Can I somehow specify the path of the installed pinocchio library in the cmake file?

  1. adding the compile options/flags just like in the example from the documentation
target_compile_options(${PROJECT_NAME} PUBLIC $(pkg-config --cflags --libs pinocchio))

but that also throws an error message. If it helps pkg-config --cflags --libs pinocchio, gives the following:

-DPINOCCHIO_WITH_URDFDOM -DPINOCCHIO_WITH_HPP_FCL -DHPP_FCL_HAS_OCTOMAP -DHPP_FCL_HAVE_OCTOMAP -DFCL_HAVE_OCTOMAP -DOCTOMAP_MAJOR_VERSION=1 -DOCTOMAP_MINOR_VERSION=9 -DOCTOMAP_PATCH_VERSION=7 -I/opt/openrobots/lib/pkgconfig/../../include -I/opt/openrobots/include -I/usr/local/include/eigen3 -I/usr/lib/x86_64-linux-gnu/pkgconfig/../../../include -L/opt/openrobots/lib/pkgconfig/../../lib -L/opt/openrobots/lib -L/usr/lib/x86_64-linux-gnu/pkgconfig/../../../lib/x86_64-linux-gnu -Wl,-rpath,/opt/openrobots/lib/pkgconfig/../../lib -lpinocchio -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lboost_filesystem -lboost_serialization -lboost_system -lurdfdom_sensor -lurdfdom_model_state -lurdfdom_model -lurdfdom_world -lconsole_bridge -Wl,-rpath,/opt/openrobots/lib -lhpp-fcl -loctomap -loctomath

Thank you very much!

CodePudding user response:

From the pinocchio website pinocchio:

Configure environment variables
All the packages will be installed in the /opt/openrobots directory. To make use of installed libraries and programs, you must need to configure your PATH, PKG_CONFIG_PATH, PYTHONPATH and other similar environment variables to point inside this directory. For instance:

export PATH=/opt/openrobots/bin:$PATH
export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/opt/openrobots/lib/python2.7/site-packages:$PYTHONPATH # Adapt your desired python version here
export CMAKE_PREFIX_PATH=/opt/openrobots:$CMAKE_PREFIX_PATH

So try setting CMake environnement variable called CMAKE_PREFIX_PATH or use -D flag during cmake invocation:

cmake -D CMAKE_PREFIX_PATH=/usr/local/lib <path to source or build dir>

It specifies the path which will be used by the FIND command

  • Related