Eigen ROS package deprecated (ROS Electric). Old documentation

Eigen has been replaced with a rosdep system dependency. Electric also switched to Eigen 3. To migrate from Eigen2 to Eigen 3 see this guide

Electric

CMakeLists.txt

Starting in ROS Electric, Eigen 3 is installed as a system dependency. This means that you compile against Eigen 3 without requiring any ROS-specific build tools.

For convenience, the system install includes CMake config files for easily finding and configuring Eigen in your CMakeLists.txt using the normal find_package() macro:

find_package(Eigen REQUIRED)
include_directories(${Eigen_INCLUDE_DIRS})

Eigen is a header-only library, so you do not need to specify any linking.

Unfortunately, Eigen on Ubuntu does not have a FindEigen.cmake file and we do not have that file in a ROS package yet. You need to include it by default in your package (in a ./cmake folder for example). You can get if from here: https://code.ros.org/svn/ros-pkg/stacks/laser_pipeline/trunk/laser_geometry/cmake/FindEigen.cmake

You then need to add the following before the find_package CMake instruction:

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

You can then include directories as follows:

include_directories(${EIGEN_INCLUDE_DIRS})

Package/stack dependencies

Eigen is defined in the common_rosdeps stack/package. You will need to update

  1. manifest.xml

      <depend package="common_rosdeps" />
      <rosdep name="eigen" />
  2. stack.xml

      <depend stack="common_rosdeps" />

Fuerte

CMakeLists.txt (i.e., using Eigen in your code)

For convenience, the system install includes CMake config files for easily finding and configuring Eigen in your CMakeLists.txt using the normal find_package() macro:

find_package(Eigen REQUIRED)
include_directories(${Eigen_INCLUDE_DIRS})

Eigen is a header-only library, so you do not need to specify any linking.

You then need to include the directories as follows:

include_directories(${Eigen_INCLUDE_DIRS})

or:

include_directories(${EIGEN_INCLUDE_DIRS})

manifest.xml

declaring the system dependency with rosdep

As of Fuerte all that is required is

  <rosdep name="eigen" />

exporting Eigen-dependent headers to others

If you provide headers included by code in other packages, and those headers use Eigen, then you must also export the flags to find Eigen. Do that by adding `pkg-config --cflags eigen3` to the exported cflags in your manifest.xml. E.g., your manifest.xml might contain something like this:

 <export>
    <cpp cflags="`pkg-config --cflags eigen3` -I${prefix}/include `rosboost-cfg --cflags`" 
         lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lplanning_models"/>
  </export>

Documentation

Please see the Eigen homepage for documentation on the Eigen library. See also:

To help you get started with Eigen, we've put together an Eigen Cookbook.

Wiki: eigen (last edited 2012-05-06 20:57:16 by PatrickBouffard)