Ask Your Question
0

error using eigen

asked 2019-12-02 16:29:10 -0600

hossein gravatar image

updated 2019-12-05 20:07:58 -0600

jayess gravatar image

Hello all! I wanted to use Eigen library with my ROS project. I installed eigen3 and followed the instruction at https://github.com/ros/cmake_modules/... but when I try to run catkin_make it returns many errors which are mainly pointing to eigen library itself. I even tested eigen library with a non-ros C++ program and it works fine. Errors returned from catkin_make are very long but the last part of it are as follows:

In file included from /usr/include/eigen3/Eigen/Core:347:0,
             from /usr/include/eigen3/Eigen/Dense:1,
             from /home/hossein/multi_ws/src/event_formation/include/kalman.h:1,
             from/home/hossein/multi_ws/src/event_formation/src/Kalman.cpp:6:/usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h: In instantiation of ‘Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::CwiseBinaryOp(const Lhs&, const Rhs&, const BinaryOp&) [with BinaryOp = Eigen::internal::scalar_sum_op<float, double>; LhsType = const Eigen::Matrix<float, 3, 3>; RhsType = const Eigen::Matrix<double, 3, 3>; Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::Lhs = Eigen::Matrix<float, 3, 3>; Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::Rhs = Eigen::Matrix<double, 3, 3>]’:/usr/include/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h:27:1:   required from ‘const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<typename Eigen::internal::traits<T>::Scalar, typename Eigen::internal::traits<OtherDerived>::Scalar>, const Derived, const OtherDerived> Eigen::MatrixBase<Derived>::operator+(const Eigen::MatrixBase<OtherDerived>&) const [with OtherDerived = Eigen::Matrix<double, 3, 3>; Derived = Eigen::Matrix<float, 3, 3>; typename Eigen::internal::traits<OtherDerived>::Scalar = double; typename Eigen::internal::traits<T>::Scalar = float]’/home/hossein/multi_ws/src/event_formation/src/Kalman.cpp:64:58:   required from here
/usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:107:7: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
   EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename Rhs::Scalar);
   ^
event_formation/CMakeFiles/event_formation.dir/build.make:86: recipe for target 'event_formation/CMakeFiles/event_formation.dir/src/Kalman.cpp.o' failed
make[2]: *** [event_formation/CMakeFiles/event_formation.dir/src/Kalman.cpp.o] Error 1
CMakeFiles/Makefile2:3102: recipe for target 'event_formation/CMakeFiles/event_formation.dir/all' failed
make[1]: *** [event_formation/CMakeFiles/event_formation.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

The CMakeLists.txr is as follows:

cmake_minimum_required(VERSION 2.8.3)
project(event_formation)


find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
)
find_package(cmake_modules REQUIRED)
find_package(Eigen REQUIRED)


 add_message_files(
  FILES
   event.msg
)

 generate_messages(
   DEPENDENCIES
   std_msgs
 )

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS roscpp rospy std_msgs
  DEPENDS system_lib
  DEPENDS Eigen
)

include_directories(
 include
  ${catkin_INCLUDE_DIRS}
)


include_directories(
  include
  ${catkin_LIBRARIES}
  ${Eigen_INCLUDE_DIRS}
)


add_executable(event_formation src/main.cpp src/Kalman.cpp)
  target_link_libraries(event_formation  
  ${catkin_LIBRARIES}
  )
edit retag flag offensive close merge delete

Comments

1

This doesn't seem like a linking or build error, meaning eigen was added to your project successfully. And for the rest I think stack overflow would be right place to ask such questions. Also people can't really help you much with just error message without looking at actual code.

Choco93 gravatar imageChoco93 ( 2019-12-03 02:45:37 -0600 )edit

Please post the contents of your CMakeLists.txt file

pavel92 gravatar imagepavel92 ( 2019-12-03 03:26:15 -0600 )edit

Thank you @Choco93 and @pavel92 for your answers. I added the CMakeLists.txt to my question.

hossein gravatar imagehossein ( 2019-12-03 07:50:05 -0600 )edit

as @Choco93 said: This seems to be not ROS related. There error provided is:

YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY

and seems to stem from `Kalman.cpp:64.

Try googling for that. This delivers e.g. https://stackoverflow.com/questions/2...

mgruhler gravatar imagemgruhler ( 2019-12-03 08:11:46 -0600 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2019-12-04 17:42:12 -0600

hossein gravatar image

Thanks every one for your help. I dug into my code as @Choco and @mgluhrer said and found out that the problem was because of assigning a wrong type of matrix to one of my matrices in my calculations. Although it's a bit odd for me that a small mistake leads to this long error in eigen library.

edit flag offensive delete link more
0

answered 2019-12-04 04:10:41 -0600

pavel92 gravatar image

I am not much familiar with eigen errors. Maybe the dependency should be to Eigen3 instead of Eigen since you have installed eigen3.

find_package(Eigen3 REQUIRED)


On another note, dont forget to include the eigen directories:

include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})

and link your target with the eigen libraries:

target_link_libraries(your_target ${catkin_LIBRARIES} ${EIGEN3_LIBRARIES})

Also since you are generating a custom msg add the message_runtime as dependency:

catkin_package(
  INCLUDE_DIRS include
#  LIBRARIES event_formation
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
  DEPENDS system_lib
  DEPENDS Eigen3
)
edit flag offensive delete link more

Comments

Thanks. The problem was not from CMakeLists.txt file.

hossein gravatar imagehossein ( 2019-12-04 17:45:43 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-12-02 16:29:10 -0600

Seen: 39 times

Last updated: yesterday