Replace .to<double>() and .template to<double>() with .value() (#3667)

It's a less verbose way to do the same thing.
This commit is contained in:
Tyler Veness
2021-10-25 08:58:12 -07:00
committed by GitHub
parent 6bc1db44bc
commit 181723e573
134 changed files with 782 additions and 826 deletions

View File

@@ -37,7 +37,7 @@ TEST(HolonomicDriveControllerTest, ReachesReference) {
constexpr auto kDt = 0.02_s;
auto totalTime = trajectory.TotalTime();
for (size_t i = 0; i < (totalTime / kDt).to<double>(); ++i) {
for (size_t i = 0; i < (totalTime / kDt).value(); ++i) {
auto state = trajectory.Sample(kDt * i);
auto [vx, vy, omega] = controller.Calculate(robotPose, state, 0_rad);
@@ -62,5 +62,5 @@ TEST(HolonomicDriveControllerTest, DoesNotRotateUnnecessarily) {
frc::ChassisSpeeds speeds = controller.Calculate(
frc::Pose2d(0_m, 0_m, 1.57_rad), frc::Pose2d(), 0_mps, 1.57_rad);
EXPECT_EQ(0, speeds.omega.to<double>());
EXPECT_EQ(0, speeds.omega.value());
}

View File

@@ -38,7 +38,7 @@ TEST_F(PIDInputOutputTest, IntegralGainOutput) {
out = controller->Calculate(0.025, 0);
}
EXPECT_DOUBLE_EQ(-0.5 * controller->GetPeriod().to<double>(), out);
EXPECT_DOUBLE_EQ(-0.5 * controller->GetPeriod().value(), out);
}
TEST_F(PIDInputOutputTest, DerivativeGainOutput) {

View File

@@ -104,7 +104,7 @@ TEST_F(ProfiledPIDInputOutputTest, IntegralGainOutput) {
out = controller->Calculate(0.025_deg, 0_deg);
}
EXPECT_DOUBLE_EQ(-0.5 * controller->GetPeriod().to<double>(), out);
EXPECT_DOUBLE_EQ(-0.5 * controller->GetPeriod().value(), out);
}
TEST_F(ProfiledPIDInputOutputTest, DerivativeGainOutput) {

View File

@@ -26,7 +26,7 @@ TEST(RamseteControllerTest, ReachesReference) {
constexpr auto kDt = 0.02_s;
auto totalTime = trajectory.TotalTime();
for (size_t i = 0; i < (totalTime / kDt).to<double>(); ++i) {
for (size_t i = 0; i < (totalTime / kDt).value(); ++i) {
auto state = trajectory.Sample(kDt * i);
auto [vx, vy, omega] = controller.Calculate(robotPose, state);
static_cast<void>(vy);

View File

@@ -33,14 +33,14 @@ TEST(SimpleMotorFeedforwardTest, Calculate) {
Eigen::Vector<double, 1> nextR{3.0};
EXPECT_NEAR(37.524995834325161 + Ks,
simpleMotor.Calculate(2_mps, 3_mps, dt).to<double>(), 0.002);
simpleMotor.Calculate(2_mps, 3_mps, dt).value(), 0.002);
EXPECT_NEAR(plantInversion.Calculate(r, nextR)(0) + Ks,
simpleMotor.Calculate(2_mps, 3_mps, dt).to<double>(), 0.002);
simpleMotor.Calculate(2_mps, 3_mps, dt).value(), 0.002);
// These won't match exactly. It's just an approximation to make sure they're
// in the same ballpark.
EXPECT_NEAR(plantInversion.Calculate(r, nextR)(0) + Ks,
simpleMotor.Calculate(2_mps, 1_mps / dt).to<double>(), 2.0);
simpleMotor.Calculate(2_mps, 1_mps / dt).value(), 2.0);
}
} // namespace frc