diff --git a/wpimath/src/main/java/org/wpilib/math/estimator/UnscentedKalmanFilter.java b/wpimath/src/main/java/org/wpilib/math/estimator/UnscentedKalmanFilter.java index a502ddf988..350bb1a138 100644 --- a/wpimath/src/main/java/org/wpilib/math/estimator/UnscentedKalmanFilter.java +++ b/wpimath/src/main/java/org/wpilib/math/estimator/UnscentedKalmanFilter.java @@ -564,19 +564,14 @@ public class UnscentedKalmanFilter K = - Sy.transpose() - .solveFullPivHouseholderQr(Sy.solveFullPivHouseholderQr(Pxy.transpose())) - .transpose(); + Matrix K = Sy.transpose().solve(Sy.solve(Pxy.transpose())).transpose(); // Compute the posterior state mean // diff --git a/wpimath/src/main/native/include/wpi/math/estimator/UnscentedKalmanFilter.hpp b/wpimath/src/main/native/include/wpi/math/estimator/UnscentedKalmanFilter.hpp index b8afbe7433..bb112c66d4 100644 --- a/wpimath/src/main/native/include/wpi/math/estimator/UnscentedKalmanFilter.hpp +++ b/wpimath/src/main/native/include/wpi/math/estimator/UnscentedKalmanFilter.hpp @@ -437,9 +437,7 @@ class UnscentedKalmanFilter { .transpose(); } - // Compute the Kalman gain. We use Eigen's QR decomposition to solve. This - // is equivalent to MATLAB's \ operator, so we need to rearrange to use - // that. + // Compute the Kalman gain // // K = (P_{xy} / S_{y}ᵀ) / S_{y} // K = (S_{y} \ P_{xy})ᵀ / S_{y} @@ -448,8 +446,9 @@ class UnscentedKalmanFilter { // equation (27) Matrixd K = Sy.transpose() - .fullPivHouseholderQr() - .solve(Sy.fullPivHouseholderQr().solve(Pxy.transpose())) + .template triangularView() + .solve(Sy.template triangularView().solve( + Pxy.transpose())) .transpose(); // Compute the posterior state mean