robotology / osqp-eigen

Simple Eigen-C++ wrapper for OSQP library
https://robotology.github.io/osqp-eigen/
BSD 3-Clause "New" or "Revised" License
381 stars 112 forks source link

When calling the setHessianMatrix and updateHessianMatrix functions, the compilation error #158

Closed Bzdss6 closed 3 months ago

Bzdss6 commented 4 months ago

The call code is as follows solver.data()->setHessianMatrix(mpc_solver.hessian); solver.updateHessianMatrix(mpc_solver.hessian);

The following error is given when compiling: In file included from /usr/include/eigen3/Eigen/Core:469:0, from /usr/include/eigen3/Eigen/Dense:1, from /home/wangdachui/catkin_ws/src/unitree_guide/unitree_guide/include/common/mathTypes.h:7, from /home/wangdachui/catkin_ws/src/unitree_guide/unitree_guide/include/control/BalanceCtrl.h:7, from /home/wangdachui/catkin_ws/src/unitree_guide/unitree_guide/src/control/BalanceCtrl.cpp:4: /usr/include/eigen3/Eigen/src/Core/TriangularMatrix.h: In instantiation of ‘class Eigen::TriangularView<const Eigen::SparseMatrix<double, 0, int>, 2>’: /usr/local/include/OsqpEigen/Data.tpp:38:13: required from ‘bool OsqpEigen::Data::setHessianMatrix(const Eigen::SparseCompressedBase<Derived>&) [with Derived = Eigen::SparseMatrix<double, 0, int>]’ /home/wangdachui/catkin_ws/src/unitree_guide/unitree_guide/src/control/BalanceCtrl.cpp:445:63: required from here /usr/include/eigen3/Eigen/src/Core/TriangularMatrix.h:283:17: error: no members matching ‘Eigen::TriangularView<const Eigen::SparseMatrix<double, 0, int>, 2>::Base {aka Eigen::TriangularViewImpl<const Eigen::SparseMatrix<double, 0, int>, 2, Eigen::Sparse>}::solve’ in ‘Eigen::TriangularView<const Eigen::SparseMatrix<double, 0, int>, 2>::Base {aka class Eigen::TriangularViewImpl<const Eigen::SparseMatrix<double, 0, int>, 2, Eigen::Sparse>}’ using Base::solve;

traversaro commented 4 months ago

Which version of eigen, osqp and osqp-eigen are you using?

Can you provide the full code that is creating the problem? Without knowing what is the mpc_solver.hessian variable, it is not possible to understand what is going on.

Bzdss6 commented 4 months ago

The osqp version is 0.6.3 and the osqp-eigen version is 0.7.0. Could it be that the osqp-eigen version is too old?

Related codes: Eigen::SparseMatrix<double> hessian; Eigen::Matrix<double, 120, 120> dense_hessian; ...; hessian = dense_hessian.sparseView(); ` The middle is the dense_hessian assignment

GiulioRomualdi commented 3 months ago

Hi @Bzdss6, could you please provide a self-contained application so I can try to replicate it on my PC?

Thank you!

Bzdss6 commented 3 months ago

I've solved it, the reason for the error was that this library had a definition with the same name as my other code, thank you very much!