mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -13,7 +13,7 @@
|
||||
#include "wpi/math/trajectory/TrajectoryConfig.hpp"
|
||||
#include "wpi/math/trajectory/TrajectoryGenerator.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::math;
|
||||
|
||||
static constexpr double kEpsilon = 0.01;
|
||||
|
||||
@@ -27,17 +27,17 @@ class SwerveDriveOdometry3dTest : public ::testing::Test {
|
||||
SwerveDriveKinematics<4> m_kinematics{m_fl, m_fr, m_bl, m_br};
|
||||
SwerveModulePosition zero;
|
||||
SwerveDriveOdometry3d<4> m_odometry{
|
||||
m_kinematics, frc::Rotation3d{}, {zero, zero, zero, zero}};
|
||||
m_kinematics, wpi::math::Rotation3d{}, {zero, zero, zero, zero}};
|
||||
};
|
||||
|
||||
TEST_F(SwerveDriveOdometry3dTest, Initialize) {
|
||||
SwerveDriveOdometry3d odometry{
|
||||
m_kinematics,
|
||||
frc::Rotation3d{},
|
||||
wpi::math::Rotation3d{},
|
||||
{zero, zero, zero, zero},
|
||||
frc::Pose3d{1_m, 2_m, 0_m, frc::Rotation3d{0_deg, 0_deg, 45_deg}}};
|
||||
wpi::math::Pose3d{1_m, 2_m, 0_m, wpi::math::Rotation3d{0_deg, 0_deg, 45_deg}}};
|
||||
|
||||
const frc::Pose3d& pose = odometry.GetPose();
|
||||
const wpi::math::Pose3d& pose = odometry.GetPose();
|
||||
|
||||
EXPECT_NEAR(pose.X().value(), 1, kEpsilon);
|
||||
EXPECT_NEAR(pose.Y().value(), 2, kEpsilon);
|
||||
@@ -48,12 +48,12 @@ TEST_F(SwerveDriveOdometry3dTest, Initialize) {
|
||||
TEST_F(SwerveDriveOdometry3dTest, TwoIterations) {
|
||||
SwerveModulePosition position{0.5_m, 0_deg};
|
||||
|
||||
m_odometry.ResetPosition(frc::Rotation3d{}, {zero, zero, zero, zero},
|
||||
m_odometry.ResetPosition(wpi::math::Rotation3d{}, {zero, zero, zero, zero},
|
||||
Pose3d{});
|
||||
|
||||
m_odometry.Update(frc::Rotation3d{}, {zero, zero, zero, zero});
|
||||
m_odometry.Update(wpi::math::Rotation3d{}, {zero, zero, zero, zero});
|
||||
|
||||
auto pose = m_odometry.Update(frc::Rotation3d{},
|
||||
auto pose = m_odometry.Update(wpi::math::Rotation3d{},
|
||||
{position, position, position, position});
|
||||
|
||||
EXPECT_NEAR(0.5, pose.X().value(), kEpsilon);
|
||||
@@ -68,9 +68,9 @@ TEST_F(SwerveDriveOdometry3dTest, 90DegreeTurn) {
|
||||
SwerveModulePosition bl{18.85_m, -90_deg};
|
||||
SwerveModulePosition br{42.15_m, -26.565_deg};
|
||||
|
||||
m_odometry.ResetPosition(frc::Rotation3d{}, {zero, zero, zero, zero},
|
||||
m_odometry.ResetPosition(wpi::math::Rotation3d{}, {zero, zero, zero, zero},
|
||||
Pose3d{});
|
||||
auto pose = m_odometry.Update(frc::Rotation3d{0_deg, 0_deg, 90_deg},
|
||||
auto pose = m_odometry.Update(wpi::math::Rotation3d{0_deg, 0_deg, 90_deg},
|
||||
{fl, fr, bl, br});
|
||||
|
||||
EXPECT_NEAR(12.0, pose.X().value(), kEpsilon);
|
||||
@@ -80,12 +80,12 @@ TEST_F(SwerveDriveOdometry3dTest, 90DegreeTurn) {
|
||||
}
|
||||
|
||||
TEST_F(SwerveDriveOdometry3dTest, GyroAngleReset) {
|
||||
m_odometry.ResetPosition(frc::Rotation3d{0_deg, 0_deg, 90_deg},
|
||||
m_odometry.ResetPosition(wpi::math::Rotation3d{0_deg, 0_deg, 90_deg},
|
||||
{zero, zero, zero, zero}, Pose3d{});
|
||||
|
||||
SwerveModulePosition position{0.5_m, 0_deg};
|
||||
|
||||
auto pose = m_odometry.Update(frc::Rotation3d{0_deg, 0_deg, 90_deg},
|
||||
auto pose = m_odometry.Update(wpi::math::Rotation3d{0_deg, 0_deg, 90_deg},
|
||||
{position, position, position, position});
|
||||
|
||||
EXPECT_NEAR(0.5, pose.X().value(), kEpsilon);
|
||||
@@ -100,7 +100,7 @@ TEST_F(SwerveDriveOdometry3dTest, AccuracyFacingTrajectory) {
|
||||
Translation2d{-1_m, -1_m}, Translation2d{-1_m, 1_m}};
|
||||
|
||||
SwerveDriveOdometry3d<4> odometry{
|
||||
kinematics, frc::Rotation3d{}, {zero, zero, zero, zero}};
|
||||
kinematics, wpi::math::Rotation3d{}, {zero, zero, zero, zero}};
|
||||
|
||||
SwerveModulePosition fl;
|
||||
SwerveModulePosition fr;
|
||||
@@ -116,8 +116,8 @@ TEST_F(SwerveDriveOdometry3dTest, AccuracyFacingTrajectory) {
|
||||
std::default_random_engine generator;
|
||||
std::normal_distribution<double> distribution(0.0, 1.0);
|
||||
|
||||
units::second_t dt = 20_ms;
|
||||
units::second_t t = 0_s;
|
||||
wpi::units::second_t dt = 20_ms;
|
||||
wpi::units::second_t t = 0_s;
|
||||
|
||||
double maxError = -std::numeric_limits<double>::max();
|
||||
double errorSum = 0;
|
||||
@@ -140,8 +140,8 @@ TEST_F(SwerveDriveOdometry3dTest, AccuracyFacingTrajectory) {
|
||||
br.angle = moduleStates[3].angle;
|
||||
|
||||
auto xhat = odometry.Update(
|
||||
frc::Rotation3d{groundTruthState.pose.Rotation() +
|
||||
frc::Rotation2d{distribution(generator) * 0.05_rad}},
|
||||
wpi::math::Rotation3d{groundTruthState.pose.Rotation() +
|
||||
wpi::math::Rotation2d{distribution(generator) * 0.05_rad}},
|
||||
{fl, fr, bl, br});
|
||||
double error = groundTruthState.pose.Translation()
|
||||
.Distance(xhat.Translation().ToTranslation2d())
|
||||
@@ -165,7 +165,7 @@ TEST_F(SwerveDriveOdometry3dTest, AccuracyFacingXAxis) {
|
||||
Translation2d{-1_m, -1_m}, Translation2d{-1_m, 1_m}};
|
||||
|
||||
SwerveDriveOdometry3d<4> odometry{
|
||||
kinematics, frc::Rotation3d{}, {zero, zero, zero, zero}};
|
||||
kinematics, wpi::math::Rotation3d{}, {zero, zero, zero, zero}};
|
||||
|
||||
SwerveModulePosition fl;
|
||||
SwerveModulePosition fr;
|
||||
@@ -181,8 +181,8 @@ TEST_F(SwerveDriveOdometry3dTest, AccuracyFacingXAxis) {
|
||||
std::default_random_engine generator;
|
||||
std::normal_distribution<double> distribution(0.0, 1.0);
|
||||
|
||||
units::second_t dt = 20_ms;
|
||||
units::second_t t = 0_s;
|
||||
wpi::units::second_t dt = 20_ms;
|
||||
wpi::units::second_t t = 0_s;
|
||||
|
||||
double maxError = -std::numeric_limits<double>::max();
|
||||
double errorSum = 0;
|
||||
@@ -205,7 +205,7 @@ TEST_F(SwerveDriveOdometry3dTest, AccuracyFacingXAxis) {
|
||||
br.angle = groundTruthState.pose.Rotation();
|
||||
|
||||
auto xhat = odometry.Update(
|
||||
frc::Rotation3d{0_rad, 0_rad, distribution(generator) * 0.05_rad},
|
||||
wpi::math::Rotation3d{0_rad, 0_rad, distribution(generator) * 0.05_rad},
|
||||
{fl, fr, bl, br});
|
||||
double error = groundTruthState.pose.Translation()
|
||||
.Distance(xhat.Translation().ToTranslation2d())
|
||||
|
||||
Reference in New Issue
Block a user