error using eigen
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}
)
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.
Please post the contents of your
CMakeLists.txt
fileThank you @Choco93 and @pavel92 for your answers. I added the CMakeLists.txt to my question.
as @Choco93 said: This seems to be not ROS related. There error provided is:
and seems to stem from `Kalman.cpp:64.
Try googling for that. This delivers e.g. https://stackoverflow.com/questions/2...