mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
SCRIPT: wpiformat
This commit is contained in:
committed by
Peter Johnson
parent
ae6bdc9d25
commit
2109161534
@@ -27,8 +27,8 @@ static constexpr auto kDt = 10_ms;
|
||||
}
|
||||
|
||||
TEST(TrapezoidProfileTest, ReachesGoal) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{1.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
1.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{3_m, 0_mps};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State state;
|
||||
|
||||
@@ -42,8 +42,8 @@ TEST(TrapezoidProfileTest, ReachesGoal) {
|
||||
// Tests that decreasing the maximum velocity in the middle when it is already
|
||||
// moving faster than the new max is handled correctly
|
||||
TEST(TrapezoidProfileTest, PosContinuousUnderVelChange) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{1.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
1.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{12_m, 0_mps};
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter> profile{constraints};
|
||||
@@ -76,8 +76,8 @@ TEST(TrapezoidProfileTest, PosContinuousUnderVelChange) {
|
||||
|
||||
// There is some somewhat tricky code for dealing with going backwards
|
||||
TEST(TrapezoidProfileTest, Backwards) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{-2_m, 0_mps};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State state;
|
||||
|
||||
@@ -89,8 +89,8 @@ TEST(TrapezoidProfileTest, Backwards) {
|
||||
}
|
||||
|
||||
TEST(TrapezoidProfileTest, SwitchGoalInMiddle) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{-2_m, 0_mps};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State state;
|
||||
|
||||
@@ -110,8 +110,8 @@ TEST(TrapezoidProfileTest, SwitchGoalInMiddle) {
|
||||
|
||||
// Checks to make sure that it hits top speed
|
||||
TEST(TrapezoidProfileTest, TopSpeed) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{4_m, 0_mps};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State state;
|
||||
|
||||
@@ -129,8 +129,8 @@ TEST(TrapezoidProfileTest, TopSpeed) {
|
||||
}
|
||||
|
||||
TEST(TrapezoidProfileTest, TimingToCurrent) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{2_m, 0_mps};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State state;
|
||||
|
||||
@@ -144,13 +144,13 @@ TEST(TrapezoidProfileTest, TimingToCurrent) {
|
||||
TEST(TrapezoidProfileTest, TimingToGoal) {
|
||||
using wpi::units::unit_cast;
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{2_m, 0_mps};
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter> profile{constraints};
|
||||
auto state = profile.Calculate(kDt, goal,
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State{});
|
||||
auto state = profile.Calculate(
|
||||
kDt, goal, wpi::math::TrapezoidProfile<wpi::units::meter>::State{});
|
||||
|
||||
auto predictedTimeLeft = profile.TimeLeftUntil(goal.position);
|
||||
bool reachedGoal = false;
|
||||
@@ -168,13 +168,13 @@ TEST(TrapezoidProfileTest, TimingToGoal) {
|
||||
TEST(TrapezoidProfileTest, TimingBeforeGoal) {
|
||||
using wpi::units::unit_cast;
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{2_m, 0_mps};
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter> profile{constraints};
|
||||
auto state = profile.Calculate(kDt, goal,
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State{});
|
||||
auto state = profile.Calculate(
|
||||
kDt, goal, wpi::math::TrapezoidProfile<wpi::units::meter>::State{});
|
||||
|
||||
auto predictedTimeLeft = profile.TimeLeftUntil(1_m);
|
||||
bool reachedGoal = false;
|
||||
@@ -191,13 +191,13 @@ TEST(TrapezoidProfileTest, TimingBeforeGoal) {
|
||||
TEST(TrapezoidProfileTest, TimingToNegativeGoal) {
|
||||
using wpi::units::unit_cast;
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{-2_m, 0_mps};
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter> profile{constraints};
|
||||
auto state = profile.Calculate(kDt, goal,
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State{});
|
||||
auto state = profile.Calculate(
|
||||
kDt, goal, wpi::math::TrapezoidProfile<wpi::units::meter>::State{});
|
||||
|
||||
auto predictedTimeLeft = profile.TimeLeftUntil(goal.position);
|
||||
bool reachedGoal = false;
|
||||
@@ -215,13 +215,13 @@ TEST(TrapezoidProfileTest, TimingToNegativeGoal) {
|
||||
TEST(TrapezoidProfileTest, TimingBeforeNegativeGoal) {
|
||||
using wpi::units::unit_cast;
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{-2_m, 0_mps};
|
||||
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter> profile{constraints};
|
||||
auto state = profile.Calculate(kDt, goal,
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State{});
|
||||
auto state = profile.Calculate(
|
||||
kDt, goal, wpi::math::TrapezoidProfile<wpi::units::meter>::State{});
|
||||
|
||||
auto predictedTimeLeft = profile.TimeLeftUntil(-1_m);
|
||||
bool reachedGoal = false;
|
||||
@@ -236,15 +236,16 @@ TEST(TrapezoidProfileTest, TimingBeforeNegativeGoal) {
|
||||
}
|
||||
|
||||
TEST(TrapezoidProfileTest, InitalizationOfCurrentState) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{1_mps, 1_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
1_mps, 1_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter> profile{constraints};
|
||||
EXPECT_NEAR_UNITS(profile.TimeLeftUntil(0_m), 0_s, 1e-10_s);
|
||||
EXPECT_NEAR_UNITS(profile.TotalTime(), 0_s, 1e-10_s);
|
||||
}
|
||||
|
||||
TEST(TrapezoidProfileTest, InitialVelocityConstraints) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{10_m, 0_mps};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State state{0_m, -10_mps};
|
||||
|
||||
@@ -258,8 +259,8 @@ TEST(TrapezoidProfileTest, InitialVelocityConstraints) {
|
||||
}
|
||||
|
||||
TEST(TrapezoidProfileTest, GoalVelocityConstraints) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{10_m, 5_mps};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State state{0_m, 0.75_mps};
|
||||
|
||||
@@ -273,8 +274,8 @@ TEST(TrapezoidProfileTest, GoalVelocityConstraints) {
|
||||
}
|
||||
|
||||
TEST(TrapezoidProfileTest, NegativeGoalVelocityConstraints) {
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{0.75_mps,
|
||||
0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::Constraints constraints{
|
||||
0.75_mps, 0.75_mps_sq};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State goal{10_m, -5_mps};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meter>::State state{0_m, 0.75_mps};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user