From 023b70268a79ea85dd9cb8378985adbfa88e787e Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 2 Jul 2026 15:19:44 -0700 Subject: [PATCH] [upstream_utils] Upgrade to Sleipnir 0.6.4 (#9045) --- upstream_utils/sleipnir.py | 2 +- .../0002-Downgrade-to-Eigen-5.0.1.patch | 47 ++++++++++--------- .../sleipnir/autodiff/variable_block.hpp | 20 -------- .../math/optimization/CurrentManagerTest.java | 2 +- .../cpp/optimization/CurrentManagerTest.cpp | 2 +- 5 files changed, 29 insertions(+), 44 deletions(-) diff --git a/upstream_utils/sleipnir.py b/upstream_utils/sleipnir.py index 684ecbf73f..161cd456da 100755 --- a/upstream_utils/sleipnir.py +++ b/upstream_utils/sleipnir.py @@ -46,7 +46,7 @@ using small_vector = wpi::util::SmallVector; def main(): name = "sleipnir" url = "https://github.com/SleipnirGroup/Sleipnir" - tag = "v0.6.3" + tag = "v0.6.4" sleipnir = Lib(name, url, tag, copy_upstream_src) sleipnir.main() diff --git a/upstream_utils/sleipnir_patches/0002-Downgrade-to-Eigen-5.0.1.patch b/upstream_utils/sleipnir_patches/0002-Downgrade-to-Eigen-5.0.1.patch index f7e0e7f993..b979fc6242 100644 --- a/upstream_utils/sleipnir_patches/0002-Downgrade-to-Eigen-5.0.1.patch +++ b/upstream_utils/sleipnir_patches/0002-Downgrade-to-Eigen-5.0.1.patch @@ -5,9 +5,9 @@ Subject: [PATCH 2/2] Downgrade to Eigen 5.0.1 --- include/sleipnir/autodiff/variable.hpp | 20 ++++++-- - include/sleipnir/autodiff/variable_block.hpp | 30 +++++++++--- - include/sleipnir/autodiff/variable_matrix.hpp | 46 ++++++++++++------- - 3 files changed, 69 insertions(+), 27 deletions(-) + include/sleipnir/autodiff/variable_block.hpp | 24 ++++++--- + include/sleipnir/autodiff/variable_matrix.hpp | 50 ++++++++++++------- + 3 files changed, 66 insertions(+), 28 deletions(-) diff --git a/include/sleipnir/autodiff/variable.hpp b/include/sleipnir/autodiff/variable.hpp index ad8baa3b58047f5257c210b88446324cca121d4a..6c692cbe113a3aaf7f02727260ed0b6d1f4a3c23 100644 @@ -55,7 +55,7 @@ index ad8baa3b58047f5257c210b88446324cca121d4a..6c692cbe113a3aaf7f02727260ed0b6d } diff --git a/include/sleipnir/autodiff/variable_block.hpp b/include/sleipnir/autodiff/variable_block.hpp -index 55cafb5d48afff2dbdff07516d85759180ef74c7..cf1b2a37614f748db679071df1780a569527983f 100644 +index 272e036e7ca6372e9255b24e674e55cd60f8b75c..e744b11070d844514b0d6d1c5fe29c905512c3fc 100644 --- a/include/sleipnir/autodiff/variable_block.hpp +++ b/include/sleipnir/autodiff/variable_block.hpp @@ -161,7 +161,7 @@ class VariableBlock : public SleipnirBase { @@ -89,20 +89,7 @@ index 55cafb5d48afff2dbdff07516d85759180ef74c7..cf1b2a37614f748db679071df1780a56 } (*this)[i, j] = sum; } -@@ -470,7 +474,11 @@ class VariableBlock : public SleipnirBase { - - for (int row = 0; row < rows(); ++row) { - for (int col = 0; col < cols(); ++col) { -- (*this)[row, col] /= rhs[0, 0]; -+ if constexpr (EigenMatrixLike) { -+ (*this)[row, col] /= rhs(0, 0); -+ } else { -+ (*this)[row, col] /= rhs[0, 0]; -+ } - } - } - -@@ -500,7 +508,11 @@ class VariableBlock : public SleipnirBase { +@@ -484,7 +488,11 @@ class VariableBlock : public SleipnirBase { for (int row = 0; row < rows(); ++row) { for (int col = 0; col < cols(); ++col) { @@ -115,7 +102,7 @@ index 55cafb5d48afff2dbdff07516d85759180ef74c7..cf1b2a37614f748db679071df1780a56 } } -@@ -532,7 +544,11 @@ class VariableBlock : public SleipnirBase { +@@ -516,7 +524,11 @@ class VariableBlock : public SleipnirBase { for (int row = 0; row < rows(); ++row) { for (int col = 0; col < cols(); ++col) { @@ -128,7 +115,7 @@ index 55cafb5d48afff2dbdff07516d85759180ef74c7..cf1b2a37614f748db679071df1780a56 } } -@@ -612,7 +628,7 @@ class VariableBlock : public SleipnirBase { +@@ -596,7 +608,7 @@ class VariableBlock : public SleipnirBase { for (int row = 0; row < rows(); ++row) { for (int col = 0; col < cols(); ++col) { @@ -138,7 +125,7 @@ index 55cafb5d48afff2dbdff07516d85759180ef74c7..cf1b2a37614f748db679071df1780a56 } diff --git a/include/sleipnir/autodiff/variable_matrix.hpp b/include/sleipnir/autodiff/variable_matrix.hpp -index 72559959cfc4cb38e099a2268c66088ea19551f5..59393e2eabdf9107de8ff6b554a48d83f8b9ef1e 100644 +index 6f632fb7b6575205ef59f936556c98c723238888..59393e2eabdf9107de8ff6b554a48d83f8b9ef1e 100644 --- a/include/sleipnir/autodiff/variable_matrix.hpp +++ b/include/sleipnir/autodiff/variable_matrix.hpp @@ -154,7 +154,7 @@ class VariableMatrix : public SleipnirBase { @@ -168,6 +155,24 @@ index 72559959cfc4cb38e099a2268c66088ea19551f5..59393e2eabdf9107de8ff6b554a48d83 } } } +@@ -507,7 +507,7 @@ class VariableMatrix : public SleipnirBase { + for (int j = 0; j < rhs.cols(); ++j) { + Variable sum{Scalar(0)}; + for (int k = 0; k < lhs.cols(); ++k) { +- sum += lhs[i, k] * rhs[k, j]; ++ sum += lhs(i, k) * rhs[k, j]; + } + result[i, j] = sum; + } +@@ -530,7 +530,7 @@ class VariableMatrix : public SleipnirBase { + for (int j = 0; j < rhs.cols(); ++j) { + Variable sum{Scalar(0)}; + for (int k = 0; k < lhs.cols(); ++k) { +- sum += lhs[i, k] * rhs[k, j]; ++ sum += lhs[i, k] * rhs(k, j); + } + result[i, j] = sum; + } @@ -573,7 +573,7 @@ class VariableMatrix : public SleipnirBase { for (int row = 0; row < result.rows(); ++row) { diff --git a/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/autodiff/variable_block.hpp b/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/autodiff/variable_block.hpp index cf1b2a3761..e744b11070 100644 --- a/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/autodiff/variable_block.hpp +++ b/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/autodiff/variable_block.hpp @@ -465,26 +465,6 @@ class VariableBlock : public SleipnirBase { return *this; } - /// Compound matrix division-assignment operator. - /// - /// @param rhs Variable to divide. - /// @return Result of division. - VariableBlock& operator/=(const MatrixLike auto& rhs) { - slp_assert(rhs.rows() == 1 && rhs.cols() == 1); - - for (int row = 0; row < rows(); ++row) { - for (int col = 0; col < cols(); ++col) { - if constexpr (EigenMatrixLike) { - (*this)[row, col] /= rhs(0, 0); - } else { - (*this)[row, col] /= rhs[0, 0]; - } - } - } - - return *this; - } - /// Compound matrix division-assignment operator. /// /// @param rhs Variable to divide. diff --git a/wpimath/src/test/java/org/wpilib/math/optimization/CurrentManagerTest.java b/wpimath/src/test/java/org/wpilib/math/optimization/CurrentManagerTest.java index b4c7b0ff1e..e6e0c13cc7 100644 --- a/wpimath/src/test/java/org/wpilib/math/optimization/CurrentManagerTest.java +++ b/wpimath/src/test/java/org/wpilib/math/optimization/CurrentManagerTest.java @@ -35,7 +35,7 @@ class CurrentManagerTest { // Expected values are from the following program: // - // #!/usr/bin/env python3 + // #!/usr/bin/env python // // from scipy.optimize import minimize // diff --git a/wpimath/src/test/native/cpp/optimization/CurrentManagerTest.cpp b/wpimath/src/test/native/cpp/optimization/CurrentManagerTest.cpp index 10efc8a90a..09958e5605 100644 --- a/wpimath/src/test/native/cpp/optimization/CurrentManagerTest.cpp +++ b/wpimath/src/test/native/cpp/optimization/CurrentManagerTest.cpp @@ -26,7 +26,7 @@ TEST(CurrentManagerTest, NotEnoughCurrent) { // Expected values are from the following program: // - // #!/usr/bin/env python3 + // #!/usr/bin/env python // // from scipy.optimize import minimize //