[wpiutil] Deprecate wpi::math constants in favor of wpi::numbers (#3383)

The constants were moved from std::math to std::numbers before
ratification in C++20.
This commit is contained in:
Tyler Veness
2021-05-26 00:09:36 -07:00
committed by GitHub
parent 393bf23c0c
commit a238cec12b
73 changed files with 322 additions and 284 deletions

View File

@@ -4,15 +4,15 @@
#include <gtest/gtest.h>
#include <wpi/math>
#include <wpi/numbers>
#include "Eigen/Core"
#include "frc/estimator/AngleStatistics.h"
TEST(AngleStatisticsTest, TestMean) {
Eigen::Matrix<double, 3, 3> sigmas;
sigmas << 1, 1.2, 0, 359 * wpi::math::pi / 180, 3 * wpi::math::pi / 180, 0, 1,
2, 0;
sigmas << 1, 1.2, 0, 359 * wpi::numbers::pi / 180, 3 * wpi::numbers::pi / 180,
0, 1, 2, 0;
// Weights need to produce the mean of the sigmas
Eigen::Vector3d weights{};
weights.fill(1.0 / sigmas.cols());
@@ -22,16 +22,16 @@ TEST(AngleStatisticsTest, TestMean) {
}
TEST(AngleStatisticsTest, TestResidual) {
Eigen::Vector3d a(1, 1 * wpi::math::pi / 180, 2);
Eigen::Vector3d b(1, 359 * wpi::math::pi / 180, 1);
Eigen::Vector3d a(1, 1 * wpi::numbers::pi / 180, 2);
Eigen::Vector3d b(1, 359 * wpi::numbers::pi / 180, 1);
EXPECT_TRUE(frc::AngleResidual<3>(a, b, 1).isApprox(
Eigen::Vector3d(0, 2 * wpi::math::pi / 180, 1)));
Eigen::Vector3d(0, 2 * wpi::numbers::pi / 180, 1)));
}
TEST(AngleStatisticsTest, TestAdd) {
Eigen::Vector3d a(1, 1 * wpi::math::pi / 180, 2);
Eigen::Vector3d b(1, 359 * wpi::math::pi / 180, 1);
Eigen::Vector3d a(1, 1 * wpi::numbers::pi / 180, 2);
Eigen::Vector3d b(1, 359 * wpi::numbers::pi / 180, 1);
EXPECT_TRUE(frc::AngleAdd<3>(a, b, 1).isApprox(Eigen::Vector3d(2, 0, 3)));
}