0
$\begingroup$

Rosanswers logo

hi guys,

I am working on Indigo installed on Ubuntu 14.04. I want to use Eigen library in my code. I used this tutorial to add the library to my codes. I also checked this one. After following these two tutorials, my package.xml contains:

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

and my CMakeLists.txt has these lines:

find_package(catkin REQUIRED COMPONENTS cmake_modules )
find_package(Eigen REQUIRED)
catkin_package(
  INCLUDE_DIRS include
  LIBRARIES talker1
  CATKIN_DEPENDS roscpp rospy std_msgs geometry_msgs nav_msgs tf cmake_modules
  DEPENDS Eigen
)
add_executable(CRControl1 src/CRControl1.cpp)
add_dependencies(CRControl1 beginner_tutorials_generate_messages_cpp)
target_link_libraries(CRControl1 ${catkin_LIBRARIES} ${EIGEN_LIBRARIES})

But unfortunately, non of them worked. when I am trying to compile, I get this error:

/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:52:40: error: ‘RowMajorBit’ was not declared in this scope
       Options = MatrixType::Options & ~RowMajorBit, // these are the options for the TmpMatrixType, we need a ColMajor matrix here!
In file included from /home/soheil/catkin_ws/src/talker1/src/CRControl1.h:31:0,
                 from /home/soheil/catkin_ws/src/talker1/src/CRControl1.cpp:1:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:58:22: error: expected nested-name-specifier before ‘NumTraits’
     typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
                      ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:58:22: error: expected ‘;’ at end of member declaration
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:58:31: error: expected unqualified-id before ‘<’ token
     typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
                               ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:60:13: error: ‘Matrix’ does not name a type
     typedef Matrix<Scalar, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1> TmpMatrixType;
             ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:62:13: error: ‘Transpositions’ does not name a type
     typedef Transpositions<RowsAtCompileTime, MaxRowsAtCompileTime> TranspositionType;
             ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:63:13: error: ‘PermutationMatrix’ does not name a type
     typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationType;
             ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:125:18: error: ‘TranspositionType’ does not name a type
     inline const TranspositionType& transpositionsP() const
                  ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:132:12: error: ‘Diagonal’ does not name a type
     inline Diagonal<const MatrixType> vectorD() const
            ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:175:18: error: ‘solve_retval’ in namespace ‘Eigen::internal’ does not name a type
     inline const internal::solve_retval<LDLT, Rhs>
                  ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:194:23: error: ‘MatrixBase’ has not been declared
     bool solveInPlace(MatrixBase<Derived> &bAndX) const;
                       ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:194:33: error: expected ‘,’ or ‘...’ before ‘<’ token
     bool solveInPlace(MatrixBase<Derived> &bAndX) const;
                                 ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:199:28: error: ‘MatrixBase’ does not name a type
     LDLT& rankUpdate(const MatrixBase<Derived>& w, const RealScalar& alpha=1);
                            ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:199:38: error: expected ‘,’ or ‘...’ before ‘<’ token
     LDLT& rankUpdate(const MatrixBase<Derived>& w, const RealScalar& alpha=1);
                                      ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:221:5: error: ‘ComputationInfo’ does not name a type
     ComputationInfo info() const
     ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:236:5: error: ‘TranspositionType’ does not name a type
     TranspositionType m_transpositions;
     ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:237:5: error: ‘TmpMatrixType’ does not name a type
     TmpMatrixType m_temporary;
     ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In constructor ‘Eigen::LDLT<_MatrixType, _UpLo>::LDLT()’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:72:26: error: class ‘Eigen::LDLT<_MatrixType, _UpLo>’ does not have any field named ‘m_transpositions’
     LDLT() : m_matrix(), m_transpositions(), m_isInitialized(false) {}
                          ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In constructor ‘Eigen::LDLT<_MatrixType, _UpLo>::LDLT(Eigen::LDLT<_MatrixType, _UpLo>::Index)’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:82:9: error: class ‘Eigen::LDLT<_MatrixType, _UpLo>’ does not have any field named ‘m_transpositions’
         m_transpositions(size),
         ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:83:9: error: class ‘Eigen::LDLT<_MatrixType, _UpLo>’ does not have any field named ‘m_temporary’
         m_temporary(size),
         ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In constructor ‘Eigen::LDLT<_MatrixType, _UpLo>::LDLT(const MatrixType&)’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:94:9: error: class ‘Eigen::LDLT<_MatrixType, _UpLo>’ does not have any field named ‘m_transpositions’
         m_transpositions(matrix.rows()),
         ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:95:9: error: class ‘Eigen::LDLT<_MatrixType, _UpLo>’ does not have any field named ‘m_temporary’
         m_temporary(matrix.rows()),
         ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In member function ‘typename Eigen::LDLT<_MatrixType, _UpLo>::Traits::MatrixU Eigen::LDLT<_MatrixType, _UpLo>::matrixU() const’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:112:65: error: there are no arguments to ‘eigen_assert’ that depend on a template parameter, so a declaration of ‘eigen_assert’ must be available [-fpermissive]
       eigen_assert(m_isInitialized && "LDLT is not initialized.");
                                                                 ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:112:65: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In member function ‘typename Eigen::LDLT<_MatrixType, _UpLo>::Traits::MatrixL Eigen::LDLT<_MatrixType, _UpLo>::matrixL() const’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:119:65: error: there are no arguments to ‘eigen_assert’ that depend on a template parameter, so a declaration of ‘eigen_assert’ must be available [-fpermissive]
       eigen_assert(m_isInitialized && "LDLT is not initialized.");
                                                                 ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In member function ‘bool Eigen::LDLT<_MatrixType, _UpLo>::isPositive() const’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:141:65: error: there are no arguments to ‘eigen_assert’ that depend on a template parameter, so a declaration of ‘eigen_assert’ must be available [-fpermissive]
       eigen_assert(m_isInitialized && "LDLT is not initialized.");
                                                                 ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In member function ‘bool Eigen::LDLT<_MatrixType, _UpLo>::isNegative() const’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:155:65: error: there are no arguments to ‘eigen_assert’ that depend on a template parameter, so a declaration of ‘eigen_assert’ must be available [-fpermissive]
       eigen_assert(m_isInitialized && "LDLT is not initialized.");
                                                                 ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In member function ‘const MatrixType& Eigen::LDLT<_MatrixType, _UpLo>::matrixLDLT() const’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:207:65: error: there are no arguments to ‘eigen_assert’ that depend on a template parameter, so a declaration of ‘eigen_assert’ must be available [-fpermissive]
       eigen_assert(m_isInitialized && "LDLT is not initialized.");
                                                                 ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: At global scope:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:246:32: error: ‘Lower’ was not declared in this scope
 template<> struct ldlt_inplace<Lower>
                                ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:246:37: error: template argument 1 is invalid
 template<> struct ldlt_inplace<Lower>
                                     ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:399:32: error: ‘Upper’ was not declared in this scope
 template<> struct ldlt_inplace<Upper>
                                ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:399:37: error: template argument 1 is invalid
 template<> struct ldlt_inplace<Upper>
                                     ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:416:61: error: ‘Lower’ was not declared in this scope
 template<typename MatrixType> struct LDLT_Traits<MatrixType,Lower>
                                                             ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:416:66: error: template argument 2 is invalid
 template<typename MatrixType> struct LDLT_Traits<MatrixType,Lower>
                                                                  ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:424:61: error: ‘Upper’ was not declared in this scope
 template<typename MatrixType> struct LDLT_Traits<MatrixType,Upper>
                                                             ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:424:66: error: template argument 2 is invalid
 template<typename MatrixType> struct LDLT_Traits<MatrixType,Upper>
                                                                  ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In member function ‘Eigen::LDLT<MatrixType, _UpLo>& Eigen::LDLT<_MatrixType, _UpLo>::compute(const MatrixType&)’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:444:3: error: ‘m_transpositions’ was not declared in this scope
   m_transpositions.resize(size);
   ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:446:3: error: ‘m_temporary’ was not declared in this scope
   m_temporary.resize(size);
   ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: At global scope:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:461:66: error: ‘MatrixBase’ does not name a type
 LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename NumTraits<typename MatrixType::Scalar>::Real& sigma)
                                                                  ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:461:76: error: expected ‘,’ or ‘...’ before ‘<’ token
 LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename NumTraits<typename MatrixType::Scalar>::Real& sigma)
                                                                            ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In member function ‘Eigen::LDLT<MatrixType, _UpLo>& Eigen::LDLT<_MatrixType, _UpLo>::rankUpdate(int)’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:463:22: error: ‘w’ was not declared in this scope
   const Index size = w.rows();
                      ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:472:5: error: ‘m_transpositions’ was not declared in this scope
     m_transpositions.resize(size);
     ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:475:5: error: ‘m_temporary’ was not declared in this scope
     m_temporary.resize(size);
     ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:476:14: error: ‘sigma’ was not declared in this scope
     m_sign = sigma>=0 ? 1 : -1;
              ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:480:50: error: ‘m_transpositions’ was not declared in this scope
   internal::ldlt_inplace<UpLo>::update(m_matrix, m_transpositions, m_temporary, w, sigma);
                                                  ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:480:68: error: ‘m_temporary’ was not declared in this scope
   internal::ldlt_inplace<UpLo>::update(m_matrix, m_transpositions, m_temporary, w, sigma);
                                                                    ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:480:84: error: ‘sigma’ was not declared in this scope
   internal::ldlt_inplace<UpLo>::update(m_matrix, m_transpositions, m_temporary, w, sigma);
                                                                                    ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: At global scope:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:487:8: error: ‘solve_retval’ is not a class template
 struct solve_retval<LDLT<_MatrixType,_UpLo>, Rhs>
        ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:488:22: error: expected template-name before ‘<’ token
   : solve_retval_base<LDLT<_MatrixType,_UpLo>, Rhs>
                      ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:488:22: error: expected ‘{’ before ‘<’ token
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:488:22: error: expected unqualified-id before ‘<’ token
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:543:43: error: ‘bool Eigen::LDLT<_MatrixType, _UpLo>::solveInPlace’ is not a static member of ‘class Eigen::LDLT<_MatrixType, _UpLo>’
 bool LDLT<MatrixType,_UpLo>::solveInPlace(MatrixBase<Derived> &bAndX) const
                                           ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:543:43: error: template definition of non-template ‘bool Eigen::LDLT<_MatrixType, _UpLo>::solveInPlace’
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:543:43: error: ‘MatrixBase’ was not declared in this scope
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:543:61: error: expected primary-expression before ‘>’ token
 bool LDLT<MatrixType,_UpLo>::solveInPlace(MatrixBase<Derived> &bAndX) const
                                                             ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:543:64: error: ‘bAndX’ was not declared in this scope
 bool LDLT<MatrixType,_UpLo>::solveInPlace(MatrixBase<Derived> &bAndX) const
                                                                ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: In member function ‘MatrixType Eigen::LDLT<_MatrixType, _UpLo>::reconstructedMatrix() const’:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:559:61: error: there are no arguments to ‘eigen_assert’ that depend on a template parameter, so a declaration of ‘eigen_assert’ must be available [-fpermissive]
   eigen_assert(m_isInitialized && "LDLT is not initialized.");
                                                             ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:565:25: error: there are no arguments to ‘transpositionsP’ that depend on a template parameter, so a declaration of ‘transpositionsP’ must be available [-fpermissive]
   res = transpositionsP() * res;
                         ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:569:17: error: there are no arguments to ‘vectorD’ that depend on a template parameter, so a declaration of ‘vectorD’ must be available [-fpermissive]
   res = vectorD().asDiagonal() * res;
                 ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:573:25: error: there are no arguments to ‘transpositionsP’ that depend on a template parameter, so a declaration of ‘transpositionsP’ must be available [-fpermissive]
   res = transpositionsP().transpose() * res;
                         ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h: At global scope:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:582:80: error: wrong number of template arguments (1, should be 2)
 inline const LDLT<typename SelfAdjointView<MatrixType, UpLo>::PlainObject, UpLo>
                                                                                ^
In file included from /home/soheil/catkin_ws/src/talker1/src/CRControl1.h:31:0,
                 from /home/soheil/catkin_ws/src/talker1/src/CRControl1.cpp:1:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:45:49: error: provided for ‘template<class _MatrixType, int _UpLo> class Eigen::LDLT’
 template<typename _MatrixType, int _UpLo> class LDLT
                                                 ^
In file included from /home/soheil/catkin_ws/src/talker1/src/CRControl1.h:31:0,
                 from /home/soheil/catkin_ws/src/talker1/src/CRControl1.cpp:1:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:583:16: error: expected initializer before ‘<’ token
 SelfAdjointView<MatrixType, UpLo>::ldlt() const
                ^
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:592:60: error: wrong number of template arguments (1, should be 2)
 inline const LDLT<typename MatrixBase<Derived>::PlainObject>
                                                            ^
In file included from /home/soheil/catkin_ws/src/talker1/src/CRControl1.h:31:0,
                 from /home/soheil/catkin_ws/src/talker1/src/CRControl1.cpp:1:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:45:49: error: provided for ‘template<class _MatrixType, int _UpLo> class Eigen::LDLT’
 template<typename _MatrixType, int _UpLo> class LDLT
                                                 ^
In file included from /home/soheil/catkin_ws/src/talker1/src/CRControl1.h:31:0,
                 from /home/soheil/catkin_ws/src/talker1/src/CRControl1.cpp:1:
/usr/include/eigen3/Eigen/src/Cholesky/LDLT.h:593:11: error: expected initializer before ‘<’ token
 MatrixBase<Derived>::ldlt() const
           ^
/home/soheil/catkin_ws/src/talker1/src/CRControl1.cpp: In constructor ‘CRControl::CRControl()’:
/home/soheil/catkin_ws/src/talker1/src/CRControl1.cpp:4:67: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
  CRControl::CRControl(): count_a (0) , count_b (0) , theta(0.0) , e { 0.0 , 0.0 , 0.0} , dedt { 0.0 , 0.0 , 0.0} , vx(0.0) , vy(0.0) , vz(0.0) , x(0.0) , y(0.0) , z(0.0) , dxdt(0.0) , dydt(0.0), dtheta_dt(0.0) , deltha_t(0.0) , deltha_x(0.0) , deltha_y(0.0) , deltha_z(0.0)
                                                                   ^
/home/soheil/catkin_ws/src/talker1/src/CRControl1.cpp:4:90: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
  CRControl::CRControl(): count_a (0) , count_b (0) , theta(0.0) , e { 0.0 , 0.0 , 0.0} , dedt { 0.0 , 0.0 , 0.0} , vx(0.0) , vy(0.0) , vz(0.0) , x(0.0) , y(0.0) , z(0.0) , dxdt(0.0) , dydt(0.0), dtheta_dt(0.0) , deltha_t(0.0) , deltha_x(0.0) , deltha_y(0.0) , deltha_z(0.0)
                                                                                          ^
make[2]: *** [talker1/CMakeFiles/CRControl1.dir/src/CRControl1.cpp.o] Error 1
make[2]: Leaving directory `/home/soheil/catkin_ws/build'
make[1]: *** [talker1/CMakeFiles/CRControl1.dir/all] Error 2
make[1]: Leaving directory `/home/soheil/catkin_ws/build'
make: *** [all] Error 2

16:18:37 Build Finished (took 9s.630ms)

there is nothing special in my code. I just include eigen library.

#include <eigen3/Eigen/src/Cholesky/LDLT.h>

What should I do for it?


Originally posted by soheilred on ROS Answers with karma: 1 on 2015-08-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

well, it says matrix is an unknown type, so you probably need to include something containing the definition of matrix

#include <eigen3/Eigen/Eigen>

also potentially you want to add to your CMakeLists.txt:

include_directories(src ${EIGEN3_INCLUDE_DIR})

because then you can use

#include <Eigen/Eigen>

which works even on non-Ubuntu plattforms


Originally posted by Simon Schmeisser with karma: 229 on 2015-08-12

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by soheilred on 2015-08-12:
thank you for your quick answer. but it still does not work. These things are happening even before I define any matrix or vectors. I get the error when I write the include line.

Comment by Simon Schmeisser on 2015-08-12:
it looks a bit strange that your include contains a "src", is that really untented? maybe you want to include

 #include <eigen3/Eigen/Cholesky>

instead?

Comment by soheilred on 2015-08-12:
this is what Eclipse auto-completion gives to me. Otherwise, it shows the line with a red line beneath it as an error:

Unresolved inclusion error

Comment by soheilred on 2015-08-12:
the problem solved. you were right Simon. The inclusion command was not true. But, actually I cannot understand what's wrong with my Eclipse. I used this feature without any problem. But it seams that it cannot handle this library correctly. do you have any idea about the problem?

Comment by Simon Schmeisser on 2015-08-13:
Eigen contains lot of template magic, maybe that breaks eclipse, but no, I have no idea actually ;)

Comment by soheilred on 2015-08-18:
It seems that problem has not been solved completely. When I could include the library into my code, I built my node without any problem. But now, when I want to run my node, I get this error: CRControl1: /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:238: void Eigen::PlainObjectBase

Comment by soheilred on 2015-08-18:
.... (nbRows<=MaxRowsAtCompileTime)) && (!(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic) || (nbCols<=MaxColsAtCompileTime)) && nbRows>=0 && nbCols>=0 && "Invalid sizes when resizing a matrix or array."' failed.

Comment by dmngu9 on 2016-01-05:
i got the same problem. how did you solve it?

Comment by soheilred on 2016-01-05:
the problem is for Eclipse. I shifted to Qt and everything works fine.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.