如何在cmake中添加pinocchio(一个机器人软件包)作为库

tvz2xvvm  于 2022-12-23  发布在  其他
关注(0)|答案(1)|浏览(423)

我不得不通过cmake在c项目中包含pinocchio(一个机器人技术的开源库),但是目前它失败了。
我已经安装了pinocchio c
,没有通过python绑定

sudo apt install -qqy robotpkg-pinocchio

我已经尝试了文档www.example.com中的简单示例https://gepettoweb.laas.fr/doc/stack-of-tasks/pinocchio/master/doxygen-html/index.html#OverviewComplex
如果我用最简单的例子中的源代码编译它,它就能工作:

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

为了将Pinocchio包含在一个单独的c++项目中,我尝试了以下方法:
1.发现它是这样的一个包:

find_package(pinocchio 2.6.10)

但它失败,并显示以下消息:

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.

我可以在cmake文件中指定安装pinocchio库的路径吗?
1.添加编译选项/标志,就像文档中的示例一样

target_compile_options(${PROJECT_NAME} PUBLIC $(pkg-config --cflags --libs pinocchio))

但这也会抛出一个错误消息。如果它对pkg-config --cflags --libs pinocchio有帮助,则给出以下内容:

-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

非常感谢!

abithluo

abithluo1#

来自匹诺曹网站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

因此,请尝试设置名为CMAKE_PREFIX_PATH的CMake环境变量或在cmake调用期间使用-D标志:

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

它指定FIND命令将使用的路径

相关问题