tesseract-robotics / trajopt

Trajectory Optimization Motion Planner for ROS
381 stars 103 forks source link

coef.sparseView() is failing on newer versions of eigen in absolute_c… #289

Closed johnwason closed 2 years ago

johnwason commented 2 years ago

coef.sparseView() is failing to compile on newer versions of Eigen. This PR removes the sparseView().

Levi-Armstrong commented 2 years ago

Why is it failing to compile?

johnwason commented 2 years ago
[1/23] Building CXX object CMakeFiles\trajopt_ifopt.dir\src\costs\absolute_cost.cpp.obj
FAILED: CMakeFiles/trajopt_ifopt.dir/src/costs/absolute_cost.cpp.obj 
C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo /TP -DBOOST_ALL_NO_LIB -DBoost_USE_MULTITHREADED=ON -DBoost_USE_STATIC_LIBS=OFF -DBoost_USE_STATIC_RUNTIME=OFF -DDISABLE_PNG -DTESSERACT_ASSIMP_USE_PBRMATERIAL=1 -DTESSERACT_PARSE_POINT_CLOUDS=\"ON\" -D_USE_MATH_DEFINES=ON -D__SSE2__ -D__SSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__SSE__ -D__SSSE3__ -Dtrajopt_ifopt_EXPORTS -IC:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\bullet -IC:\ws\tesseract_wheel_shared\tesseract_ws\src\trajopt_ros\trajopt_ifopt\include -IC:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include -IC:\ws\tesseract_wheel_shared\tesseract_ws\install\include -IC:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\eigen3 -IC:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\bullet -DEIGEN_DONT_ALIGN=1 -DEIGEN_DONT_VECTORIZE=1  /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG -std:c++17 /showIncludes /FoCMakeFiles\trajopt_ifopt.dir\src\costs\absolute_cost.cpp.obj /FdCMakeFiles\trajopt_ifopt.dir\ /FS -c C:\ws\tesseract_wheel_shared\tesseract_ws\src\trajopt_ros\trajopt_ifopt\src\costs\absolute_cost.cpp
C:\ws\tesseract_wheel_shared\tesseract_ws\install\include\ifopt/problem.h(244): warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/ConservativeSparseSparseProduct.h(44): error C2039: 'nonZerosEstimate': is not a member of 'Eigen::internal::evaluator<T>'
        with
        [
            T=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/SparseUtil.h(122): note: see declaration of 'Eigen::internal::evaluator<T>'
        with
        [
            T=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/ConservativeSparseSparseProduct.h(244): note: see reference to function template instantiation 'void Eigen::internal::conservative_sparse_sparse_product_impl<Lhs,ColMajorRhs,ColMajorRes>(const Lhs &,const Rhs &,ResultType &,bool)' being compiled
        with
        [
            Lhs=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>,
            Rhs=ColMajorRhs,
            ResultType=ColMajorRes
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/ConservativeSparseSparseProduct.h(239): note: while compiling class template member function 'void Eigen::internal::conservative_sparse_sparse_product_selector<Eigen::SparseView<Derived>,Eigen::SparseMatrix<double,1,int>,Dest,0,1,1>::run(const Lhs &,const Rhs &,ResultType &)'
        with
        [
            Derived=Eigen::Matrix<double,-1,1,0,-1,1>,
            Dest=Eigen::SparseMatrix<double,1,int>,
            Lhs=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>,
            Rhs=Eigen::SparseMatrix<double,1,int>,
            ResultType=Eigen::SparseMatrix<double,1,int>
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/SparseProduct.h(76): note: see reference to function template instantiation 'void Eigen::internal::conservative_sparse_sparse_product_selector<Eigen::SparseView<Derived>,Eigen::SparseMatrix<double,1,int>,Dest,0,1,1>::run(const Lhs &,const Rhs &,ResultType &)' being compiled
        with
        [
            Derived=Eigen::Matrix<double,-1,1,0,-1,1>,
            Dest=Eigen::SparseMatrix<double,1,int>,
            Lhs=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>,
            Rhs=Eigen::SparseMatrix<double,1,int>,
            ResultType=Eigen::SparseMatrix<double,1,int>
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/SparseProduct.h(76): note: see reference to class template instantiation 'Eigen::internal::conservative_sparse_sparse_product_selector<Eigen::SparseView<Derived>,Eigen::SparseMatrix<double,1,int>,Dest,0,1,1>' being compiled
        with
        [
            Derived=Eigen::Matrix<double,-1,1,0,-1,1>,
            Dest=Eigen::SparseMatrix<double,1,int>
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/SparseProduct.h(43): note: see reference to function template instantiation 'void Eigen::internal::generic_product_impl<Lhs,Rhs,Eigen::SparseShape,Eigen::SparseShape,5>::evalTo<Dest>(Dest &,const Lhs &,const Rhs &,Eigen::SparseShape)' being compiled
        with
        [
            Lhs=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>,
            Rhs=Eigen::SparseMatrix<double,1,int>,
            Dest=Eigen::SparseMatrix<double,1,int>
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/SparseProduct.h(43): note: see reference to function template instantiation 'void Eigen::internal::generic_product_impl<Lhs,Rhs,Eigen::SparseShape,Eigen::SparseShape,5>::evalTo<Dest>(Dest &,const Lhs &,const Rhs &,Eigen::SparseShape)' being compiled
        with
        [
            Lhs=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>,
            Rhs=Eigen::SparseMatrix<double,1,int>,
            Dest=Eigen::SparseMatrix<double,1,int>
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/SparseProduct.h(174): note: see reference to function template instantiation 'void Eigen::internal::generic_product_impl<Lhs,Rhs,Eigen::SparseShape,Eigen::SparseShape,5>::evalTo<Eigen::SparseMatrix<double,1,int>>(Dest &,const Lhs &,const Rhs &)' being compiled
        with
        [
            Lhs=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>,
            Rhs=Eigen::SparseMatrix<double,1,int>,
            Dest=Eigen::SparseMatrix<double,1,int>
        ]
C:\ws\tesseract_wheel_shared\vcpkg\installed\x64-windows\include\Eigen\src/SparseCore/SparseProduct.h(174): note: see reference to function template instantiation 'void Eigen::internal::generic_product_impl<Lhs,Rhs,Eigen::SparseShape,Eigen::SparseShape,5>::evalTo<Eigen::SparseMatrix<double,1,int>>(Dest &,const Lhs &,const Rhs &)' being compiled
        with
        [
            Lhs=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>,
            Rhs=Eigen::SparseMatrix<double,1,int>,
            Dest=Eigen::SparseMatrix<double,1,int>
        ]
C:\ws\tesseract_wheel_shared\tesseract_ws\src\trajopt_ros\trajopt_ifopt\src\costs\absolute_cost.cpp(83): note: see reference to function template instantiation 'Eigen::SparseMatrix<double,1,int> &Eigen::SparseMatrix<double,1,int>::operator =<Derived,Eigen::SparseMatrix<double,1,int>>(const Eigen::Product<Derived,Eigen::SparseMatrix<double,1,int>,2> &)' being compiled
        with
        [
            Derived=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>
        ]
C:\ws\tesseract_wheel_shared\tesseract_ws\src\trajopt_ros\trajopt_ifopt\src\costs\absolute_cost.cpp(83): note: see reference to function template instantiation 'Eigen::SparseMatrix<double,1,int> &Eigen::SparseMatrix<double,1,int>::operator =<Derived,Eigen::SparseMatrix<double,1,int>>(const Eigen::Product<Derived,Eigen::SparseMatrix<double,1,int>,2> &)' being compiled
        with
        [
            Derived=Eigen::SparseView<Eigen::Matrix<double,-1,1,0,-1,1>>
        ]
Levi-Armstrong commented 2 years ago

It looks like this may be due to a missing compiler flag discussed here.

johnwason commented 2 years ago

I added a check for EIGEN_HAS_OPENMP to decide which version to use.

Levi-Armstrong commented 2 years ago

It looks like it is used a few other places. Did these not cause an issue?

johnwason commented 2 years ago

I haven't seen this problem anywhere else.

johnwason commented 2 years ago

I am seeing this problem on Ubuntu 22.04 even with -fopenmp flag set