mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
SCRIPT: wpiformat
This commit is contained in:
committed by
Peter Johnson
parent
ae6bdc9d25
commit
2109161534
@@ -14,12 +14,13 @@
|
||||
|
||||
static constexpr wpi::units::meter_t kTolerance{1 / 12.0};
|
||||
static constexpr wpi::units::radian_t kAngularTolerance{2.0 * std::numbers::pi /
|
||||
180.0};
|
||||
180.0};
|
||||
|
||||
TEST(LTVUnicycleControllerTest, ReachesReference) {
|
||||
constexpr wpi::units::second_t kDt = 20_ms;
|
||||
|
||||
wpi::math::LTVUnicycleController controller{{0.0625, 0.125, 2.5}, {4.0, 4.0}, kDt};
|
||||
wpi::math::LTVUnicycleController controller{
|
||||
{0.0625, 0.125, 2.5}, {4.0, 4.0}, kDt};
|
||||
wpi::math::Pose2d robotPose{2.7_m, 23_m, 0_deg};
|
||||
|
||||
auto waypoints = std::vector{wpi::math::Pose2d{2.75_m, 22.521_m, 0_rad},
|
||||
@@ -33,13 +34,14 @@ TEST(LTVUnicycleControllerTest, ReachesReference) {
|
||||
auto [vx, vy, omega] = controller.Calculate(robotPose, state);
|
||||
static_cast<void>(vy);
|
||||
|
||||
robotPose = robotPose + wpi::math::Twist2d{vx * kDt, 0_m, omega * kDt}.Exp();
|
||||
robotPose =
|
||||
robotPose + wpi::math::Twist2d{vx * kDt, 0_m, omega * kDt}.Exp();
|
||||
}
|
||||
|
||||
auto& endPose = trajectory.States().back().pose;
|
||||
EXPECT_NEAR_UNITS(endPose.X(), robotPose.X(), kTolerance);
|
||||
EXPECT_NEAR_UNITS(endPose.Y(), robotPose.Y(), kTolerance);
|
||||
EXPECT_NEAR_UNITS(wpi::math::AngleModulus(endPose.Rotation().Radians() -
|
||||
robotPose.Rotation().Radians()),
|
||||
robotPose.Rotation().Radians()),
|
||||
0_rad, kAngularTolerance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user