diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 8faa7e209a..c0b064cacf 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -37,6 +37,21 @@ jobs: - run: nix build -L .#libpinocchio - run: nix build -L .#pinocchio-py + nix-eigen_5: + runs-on: "${{ matrix.os }}-latest" + strategy: + fail-fast: false + matrix: + os: [ubuntu, macos] + steps: + - uses: actions/checkout@v5 + - uses: cachix/install-nix-action@v31 + - uses: cachix/cachix-action@v16 + with: + name: gepetto + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - run: nix build -L .#libpinocchio-eigen_5 + check: if: always() name: check-macos-linux-nix @@ -44,6 +59,7 @@ jobs: needs: - nix-full - nix-split + - nix-eigen_5 runs-on: Ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dd8941bcf..03b23f1f28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,10 +10,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Changed - Homogenize python viewers examples ([#2771](https://github.com/stack-of-tasks/pinocchio/pull/2771)) + +### Added - Add docker images ([#2776](https://github.com/stack-of-tasks/pinocchio/pull/2776)) - ROS: added jrl_cmakemodules dependency ([#2789](https://github.com/stack-of-tasks/pinocchio/pull/2789)) +### Fixed +- Fix compatibility issues with Eigen5 ([#2779](https://github.com/stack-of-tasks/pinocchio/pull/2779)) + ## [3.8.0] - 2025-09-17 ### Added diff --git a/flake.nix b/flake.nix index 26ad4f3d23..4f2b7df177 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,16 @@ }; packages = { default = self'.packages.pinocchio; + eigen_5 = pkgs.eigen.overrideAttrs (super: rec { + version = "5.0.0"; + src = pkgs.fetchFromGitLab { + inherit (super.src) owner repo; + tag = version; + hash = "sha256-L1KUFZsaibC/FD6abTXrT3pvaFhbYnw+GaWsxM2gaxM="; + }; + patches = [ ]; + postPatch = ""; + }); pinocchio = pkgs.python3Packages.pinocchio.overrideAttrs (super: { propagatedBuildInputs = super.propagatedBuildInputs ++ [ pkgs.example-robot-data ]; src = pkgs.lib.fileset.toSource { @@ -71,6 +81,16 @@ ]; }; }); + + libpinocchio-eigen_5 = + (self'.packages.libpinocchio.override { eigen = self'.packages.eigen_5; }).overrideAttrs + (super: { + pname = "${super.pname}-eigen_5"; + cmakeFlags = super.cmakeFlags ++ [ + "-DBUILD_WITH_CASADI_SUPPORT=OFF" + "-DBUILD_WITH_COLLISION_SUPPORT=OFF" + ]; + }); pinocchio-py = pkgs.python3Packages.pinocchio.overrideAttrs (super: { pname = "pinocchio-py"; cmakeFlags = super.cmakeFlags ++ [ "-DBUILD_STANDALONE_PYTHON_INTERFACE=ON" ]; diff --git a/include/pinocchio/autodiff/casadi.hpp b/include/pinocchio/autodiff/casadi.hpp index 0340d0121e..8db8c395df 100644 --- a/include/pinocchio/autodiff/casadi.hpp +++ b/include/pinocchio/autodiff/casadi.hpp @@ -142,6 +142,18 @@ namespace Eigen { return std::numeric_limits::digits10; } + +#if EIGEN_VERSION_AT_LEAST(3, 4, 90) + EIGEN_DEVICE_FUNC constexpr static int digits() + { + return NumTraits::digits(); + } + + EIGEN_DEVICE_FUNC constexpr static int max_digits10() + { + return NumTraits::max_digits10(); + } +#endif }; } // namespace Eigen @@ -391,7 +403,6 @@ namespace Eigen typedef typename ScalarBinaryOpTraits::ReturnType result_type; - EIGEN_EMPTY_STRUCT_CTOR(scalar_max_op) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator()(const LhsScalar & a, const RhsScalar & b) const { @@ -412,7 +423,6 @@ namespace Eigen typedef typename ScalarBinaryOpTraits::ReturnType result_type; - EIGEN_EMPTY_STRUCT_CTOR(scalar_max_op) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator()(const LhsScalar & a, const RhsScalar & b) const { @@ -428,14 +438,38 @@ namespace Eigen typedef typename ScalarBinaryOpTraits::ReturnType result_type; - EIGEN_EMPTY_STRUCT_CTOR(scalar_max_op) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator()(const LhsScalar & a, const RhsScalar & b) const { return ::pinocchio::math::internal::call_max::run(a, b); } }; + } // namespace internal + namespace numext + { +#if EIGEN_VERSION_AT_LEAST(3, 4, 90) + // The function Eigen::internal::gemv_dense_selector::run defined in + // Eigen/src/Core/GeneralProduct.h call at some point Eigen::numext::is_exactly_zero function. + // Since equality operator is not defined on casadi scalar type this create a compilation error. + // To overcome this issue, overload Eigen::numext::equal_strict_impl::run function. + template<> + struct equal_strict_impl< + ::casadi::Matrix<::casadi::SXElem>, + ::casadi::Matrix<::casadi::SXElem>, + false, + true, + false, + true> + { + static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool + run(const ::casadi::Matrix<::casadi::SXElem> &, const ::casadi::Matrix<::casadi::SXElem> &) + { + return false; + } + }; +#endif + } // namespace numext } // namespace Eigen #include "pinocchio/autodiff/casadi/spatial/se3-tpl.hpp" diff --git a/include/pinocchio/math/tridiagonal-matrix.hpp b/include/pinocchio/math/tridiagonal-matrix.hpp index d7005e5e46..10e16b67e9 100644 --- a/include/pinocchio/math/tridiagonal-matrix.hpp +++ b/include/pinocchio/math/tridiagonal-matrix.hpp @@ -260,11 +260,11 @@ namespace pinocchio subDiagonal().setZero(); } - EIGEN_CONSTEXPR Eigen::Index rows() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index rows() const noexcept { return m_size; } - EIGEN_CONSTEXPR Eigen::Index cols() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index cols() const noexcept { return m_size; } @@ -358,11 +358,11 @@ namespace pinocchio m_lhs.subDiagonal().asDiagonal() * m_rhs.topRows(reduced_size); } - EIGEN_CONSTEXPR Eigen::Index rows() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index rows() const noexcept { return m_lhs.rows(); } - EIGEN_CONSTEXPR Eigen::Index cols() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index cols() const noexcept { return m_rhs.cols(); } @@ -407,11 +407,11 @@ namespace pinocchio m_lhs.rightCols(reduced_size) * m_rhs.subDiagonal().asDiagonal(); } - EIGEN_CONSTEXPR Eigen::Index rows() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index rows() const noexcept { return m_lhs.rows(); } - EIGEN_CONSTEXPR Eigen::Index cols() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index cols() const noexcept { return m_rhs.cols(); } @@ -496,11 +496,11 @@ namespace pinocchio } } - EIGEN_CONSTEXPR Eigen::Index rows() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index rows() const noexcept { return m_size; } - EIGEN_CONSTEXPR Eigen::Index cols() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index cols() const noexcept { return m_size; } @@ -576,11 +576,11 @@ namespace pinocchio } } - EIGEN_CONSTEXPR Eigen::Index rows() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index rows() const noexcept { return m_lhs.rows(); } - EIGEN_CONSTEXPR Eigen::Index cols() const EIGEN_NOEXCEPT + EIGEN_CONSTEXPR Eigen::Index cols() const noexcept { return m_rhs.cols(); } diff --git a/include/pinocchio/multibody/joint/joint-revolute.hpp b/include/pinocchio/multibody/joint/joint-revolute.hpp index bbff93fdbe..9a4b988b40 100644 --- a/include/pinocchio/multibody/joint/joint-revolute.hpp +++ b/include/pinocchio/multibody/joint/joint-revolute.hpp @@ -80,9 +80,17 @@ namespace pinocchio typedef Matrix3 AngularType; typedef Matrix3 AngularRef; typedef Matrix3 ConstAngularRef; +#if EIGEN_VERSION_AT_LEAST(3, 4, 90) + typedef typename Vector3::ZeroReturnType LinearType; + typedef const typename Vector3::ZeroReturnType ConstLinearType; + typedef typename Vector3::ZeroReturnType LinearRef; + typedef const typename Vector3::ZeroReturnType ConstLinearRef; +#else typedef typename Vector3::ConstantReturnType LinearType; + typedef const typename Vector3::ConstantReturnType ConstLinearType; typedef typename Vector3::ConstantReturnType LinearRef; typedef const typename Vector3::ConstantReturnType ConstLinearRef; +#endif typedef typename traits::ActionMatrixType ActionMatrixType; typedef typename traits::HomogeneousMatrixType HomogeneousMatrixType; }; // traits TransformRevoluteTpl @@ -98,6 +106,7 @@ namespace pinocchio { EIGEN_MAKE_ALIGNED_OPERATOR_NEW PINOCCHIO_SE3_TYPEDEF_TPL(TransformRevoluteTpl); + typedef typename traits::ConstLinearType ConstLinearType; TransformRevoluteTpl() { @@ -180,9 +189,9 @@ namespace pinocchio m_cos = cos; } - LinearType translation() const + ConstLinearType translation() const { - return LinearType::PlainObject::Zero(3); + return ConstLinearType::PlainObject::Zero(3); } AngularType rotation() const { diff --git a/unittest/spatial.cpp b/unittest/spatial.cpp index 65cb9b9279..828f0920ce 100644 --- a/unittest/spatial.cpp +++ b/unittest/spatial.cpp @@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(test_SE3) { const double prec = Eigen::NumTraits::dummy_precision(); SE3 M(SE3::Random()); - M.rotation() += prec * SE3::Matrix3::Random(); + M.rotation() += 2. * prec * SE3::Matrix3::Random(); BOOST_CHECK(!M.isNormalized()); SE3 M_normalized = M.normalized();