Using Eigen Library in ROS Indigo

2019-02-10 00:13发布

问题:

I am working on a project in ROS Indigo that requires using the Eigen libraries. According to indigo/Migration page on the ROS Wiki, the FindEigen.cmake module is now in the cmake_modules package.

After following steps to add the cmake_modules package to the project's CMake.txt (via find_package) and adding a build dependency to the package.xml (< build_depend >cmake_modules< /build_depend >), I'm still having issues compiling the project. I've looked at various sources citing the above steps should fix the issue in ROS Indigo, but can't seem to get it working. Here is the CMake file, and here is the package.xml . Additionally, I added the FindEigen.cmake file in the project folder. Any help would be greatly appreciated! The error reads:

CMake Error at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:75 (find_package):
Could not find a package configuration file provided by "Eigen" with any of the 
following names:
  EigenConfig.cmake
  eigen-config.cmake

Add the installation prefix of "Eigen" to CMAKE_PREFIX_PATH or set
"Eigen_DIR" to a directory containing one of the above files.  If "Eigen"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
lidar_point_cloud/CMakeLists.txt:9 (find_package)

回答1:

Just for post completeness, and following this answer in Answers ROS:

If you have Eigen already installed (check with sudo apt-get install libeigen3-dev), then you have to add the corresponding cmake_modules and Eigen lines to the CMakeLists.txt and package.xml files:

package.xml

<build_depend>cmake_modules</build_depend>
<run_depend>cmake_modules</run_depend> 

CMakeLists.txt

find_package(catkin REQUIRED cmake_modules)
find_package(Eigen REQUIRED)

catkin_package(
  INCLUDE_DIRS ...
  LIBRARIES ...
  CATKIN_DEPENDS ....
  DEPENDS Eigen
)

include_directories(
   ...
   ${Eigen_INCLUDE_DIRS}
 )

UPDATE: Note that the following is not required because the FindEigen.cmake module does not define Eigen_LIBRARIES becuse it is a header only library:

 target_link_libraries(my_target
   ....
   ${Eigen_LIBRARIES}
 )

More information: http://wiki.ros.org/indigo/Migration#cmake_modules

UPDATE: In fact <run_depend>cmake_modules</run_depend> is not needed as cmake_modules are not a runtime dependency.


In addition, you could use the ROS ecl wrappers: http://wiki.ros.org/ecl



回答2:

Eigen is not a ROS package but a standalone library. Therefore, instead of listing it as a component of catkin, just add a separate find_package call:

find_package(Eigen REQUIRED)

I can't double-check it right now (currently sitting at a machine with groovy), but I am quite sure, that this also worked for me with indigo.



回答3:

I had the same problem, this fixed it: (Ubuntu 14.04)

sudo apt-get install libeigen3-dev



回答4:

For me the "sudo apt-get install libeigen3-dev" was not working. So I installed it via the make file and by following the installation procedure given in the package, i.e.,

-download the package from http://eigen.tuxfamily.org/index.php?title=Main_Page

-create another directory which we will call 'build_dir'

-cd build_dir

-cmake source_dir

-make install

If this does not solve your problem, you may copy the eigen3 folder from wherever it is (mine was at /usr/local/include) to /usr/include. Use the command

sudo cp -r /usr/local/include/eigen3  /usr/include


标签: cmake eigen ros