mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Remove percent tolerance from PID controller
It breaks the unit system badly; the tolerance member variable has different units depending on percent vs absolute. Absolute tolerance is a lot more natural than percent tolerance anyway.
This commit is contained in:
committed by
Peter Johnson
parent
0ca8d667d2
commit
ff8b8f0a8a
@@ -51,31 +51,9 @@ void PIDController::SetSetpoint(double setpoint) {
|
||||
|
||||
double PIDController::GetSetpoint() const { return m_setpoint; }
|
||||
|
||||
bool PIDController::AtSetpoint(double positionTolerance,
|
||||
double velocityTolerance,
|
||||
Tolerance toleranceType) const {
|
||||
if (m_toleranceType == Tolerance::kPercent) {
|
||||
return std::abs(m_positionError) < positionTolerance / 100 * m_inputRange &&
|
||||
std::abs(m_velocityError) < velocityTolerance / 100 * m_inputRange;
|
||||
} else {
|
||||
return std::abs(m_positionError) < positionTolerance &&
|
||||
std::abs(m_velocityError) < velocityTolerance;
|
||||
}
|
||||
}
|
||||
|
||||
bool PIDController::AtSetpoint() const {
|
||||
return AtSetpoint(m_positionTolerance, m_velocityTolerance);
|
||||
}
|
||||
|
||||
void PIDController::SetInputRange(double minimumInput, double maximumInput) {
|
||||
m_minimumInput = minimumInput;
|
||||
m_maximumInput = maximumInput;
|
||||
m_inputRange = maximumInput - minimumInput;
|
||||
|
||||
// Clamp setpoint to new input range
|
||||
if (m_maximumInput > m_minimumInput) {
|
||||
m_setpoint = std::clamp(m_setpoint, m_minimumInput, m_maximumInput);
|
||||
}
|
||||
return std::abs(m_positionError) < m_positionTolerance &&
|
||||
std::abs(m_velocityError) < m_velocityTolerance;
|
||||
}
|
||||
|
||||
void PIDController::EnableContinuousInput(double minimumInput,
|
||||
@@ -91,16 +69,8 @@ void PIDController::SetOutputRange(double minimumOutput, double maximumOutput) {
|
||||
m_maximumOutput = maximumOutput;
|
||||
}
|
||||
|
||||
void PIDController::SetAbsoluteTolerance(double positionTolerance,
|
||||
double velocityTolerance) {
|
||||
m_toleranceType = Tolerance::kAbsolute;
|
||||
m_positionTolerance = positionTolerance;
|
||||
m_velocityTolerance = velocityTolerance;
|
||||
}
|
||||
|
||||
void PIDController::SetPercentTolerance(double positionTolerance,
|
||||
double velocityTolerance) {
|
||||
m_toleranceType = Tolerance::kPercent;
|
||||
void PIDController::SetTolerance(double positionTolerance,
|
||||
double velocityTolerance) {
|
||||
m_positionTolerance = positionTolerance;
|
||||
m_velocityTolerance = velocityTolerance;
|
||||
}
|
||||
@@ -164,3 +134,14 @@ double PIDController::GetContinuousError(double error) const {
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void PIDController::SetInputRange(double minimumInput, double maximumInput) {
|
||||
m_minimumInput = minimumInput;
|
||||
m_maximumInput = maximumInput;
|
||||
m_inputRange = maximumInput - minimumInput;
|
||||
|
||||
// Clamp setpoint to new input range
|
||||
if (m_maximumInput > m_minimumInput) {
|
||||
m_setpoint = std::clamp(m_setpoint, m_minimumInput, m_maximumInput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +43,6 @@ units::meter_t ProfiledPIDController::GetGoal() const {
|
||||
return m_goal.position;
|
||||
}
|
||||
|
||||
bool ProfiledPIDController::AtGoal(
|
||||
double positionTolerance, double velocityTolerance,
|
||||
frc2::PIDController::Tolerance toleranceType) const {
|
||||
return AtSetpoint(positionTolerance, velocityTolerance, toleranceType) &&
|
||||
m_goal == m_setpoint;
|
||||
}
|
||||
|
||||
bool ProfiledPIDController::AtGoal() const {
|
||||
return AtSetpoint() && m_goal == m_setpoint;
|
||||
}
|
||||
@@ -63,22 +56,10 @@ double ProfiledPIDController::GetSetpoint() const {
|
||||
return m_controller.GetSetpoint();
|
||||
}
|
||||
|
||||
bool ProfiledPIDController::AtSetpoint(
|
||||
double positionTolerance, double velocityTolerance,
|
||||
frc2::PIDController::Tolerance toleranceType) const {
|
||||
return m_controller.AtSetpoint(positionTolerance, velocityTolerance,
|
||||
toleranceType);
|
||||
}
|
||||
|
||||
bool ProfiledPIDController::AtSetpoint() const {
|
||||
return m_controller.AtSetpoint();
|
||||
}
|
||||
|
||||
void ProfiledPIDController::SetInputRange(double minimumInput,
|
||||
double maximumInput) {
|
||||
m_controller.SetInputRange(minimumInput, maximumInput);
|
||||
}
|
||||
|
||||
void ProfiledPIDController::EnableContinuousInput(double minimumInput,
|
||||
double maximumInput) {
|
||||
m_controller.EnableContinuousInput(minimumInput, maximumInput);
|
||||
@@ -93,14 +74,9 @@ void ProfiledPIDController::SetOutputRange(double minimumOutput,
|
||||
m_controller.SetOutputRange(minimumOutput, maximumOutput);
|
||||
}
|
||||
|
||||
void ProfiledPIDController::SetAbsoluteTolerance(double positionTolerance,
|
||||
double velocityTolerance) {
|
||||
m_controller.SetAbsoluteTolerance(positionTolerance, velocityTolerance);
|
||||
}
|
||||
|
||||
void ProfiledPIDController::SetPercentTolerance(double positionTolerance,
|
||||
double velocityTolerance) {
|
||||
m_controller.SetPercentTolerance(positionTolerance, velocityTolerance);
|
||||
void ProfiledPIDController::SetTolerance(double positionTolerance,
|
||||
double velocityTolerance) {
|
||||
m_controller.SetTolerance(positionTolerance, velocityTolerance);
|
||||
}
|
||||
|
||||
double ProfiledPIDController::GetPositionError() const {
|
||||
|
||||
@@ -21,8 +21,6 @@ namespace frc2 {
|
||||
*/
|
||||
class PIDController : public frc::SendableBase {
|
||||
public:
|
||||
enum class Tolerance { kAbsolute, kPercent };
|
||||
|
||||
/**
|
||||
* Allocates a PIDController with the given constants for Kp, Ki, and Kd.
|
||||
*
|
||||
@@ -116,20 +114,6 @@ class PIDController : public frc::SendableBase {
|
||||
*/
|
||||
double GetSetpoint() const;
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
* @param velocityTolerance The maximum allowable velocity error.
|
||||
* @param toleranceType The type of tolerance specified.
|
||||
*/
|
||||
bool AtSetpoint(
|
||||
double positionTolerance,
|
||||
double velocityTolerance = std::numeric_limits<double>::infinity(),
|
||||
Tolerance toleranceType = Tolerance::kAbsolute) const;
|
||||
|
||||
/**
|
||||
* Returns true if the error is within the tolerance of the error.
|
||||
*
|
||||
@@ -137,14 +121,6 @@ class PIDController : public frc::SendableBase {
|
||||
*/
|
||||
bool AtSetpoint() const;
|
||||
|
||||
/**
|
||||
* Sets the minimum and maximum values expected from the input.
|
||||
*
|
||||
* @param minimumInput The minimum value expected from the input.
|
||||
* @param maximumInput The maximum value expected from the input.
|
||||
*/
|
||||
void SetInputRange(double minimumInput, double maximumInput);
|
||||
|
||||
/**
|
||||
* Enables continuous input.
|
||||
*
|
||||
@@ -171,24 +147,12 @@ class PIDController : public frc::SendableBase {
|
||||
void SetOutputRange(double minimumOutput, double maximumOutput);
|
||||
|
||||
/**
|
||||
* Sets the absolute error which is considered tolerable for use with
|
||||
* AtSetpoint().
|
||||
* Sets the error which is considered tolerable for use with AtSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
* @param velociytTolerance Velocity error which is tolerable.
|
||||
*/
|
||||
void SetAbsoluteTolerance(
|
||||
double positionTolerance,
|
||||
double velocityTolerance = std::numeric_limits<double>::infinity());
|
||||
|
||||
/**
|
||||
* Sets the percent error which is considered tolerable for use with
|
||||
* AtSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
* @param velociytTolerance Velocity error which is tolerable.
|
||||
*/
|
||||
void SetPercentTolerance(
|
||||
void SetTolerance(
|
||||
double positionTolerance,
|
||||
double velocityTolerance = std::numeric_limits<double>::infinity());
|
||||
|
||||
@@ -276,13 +240,19 @@ class PIDController : public frc::SendableBase {
|
||||
// The sum of the errors for use in the integral calc
|
||||
double m_totalError = 0;
|
||||
|
||||
Tolerance m_toleranceType = Tolerance::kAbsolute;
|
||||
|
||||
// The error that is considered at setpoint.
|
||||
double m_positionTolerance = 0.05;
|
||||
double m_velocityTolerance = std::numeric_limits<double>::infinity();
|
||||
|
||||
double m_setpoint = 0;
|
||||
|
||||
/**
|
||||
* Sets the minimum and maximum values expected from the input.
|
||||
*
|
||||
* @param minimumInput The minimum value expected from the input.
|
||||
* @param maximumInput The maximum value expected from the input.
|
||||
*/
|
||||
void SetInputRange(double minimumInput, double maximumInput);
|
||||
};
|
||||
|
||||
} // namespace frc2
|
||||
|
||||
@@ -118,21 +118,6 @@ class ProfiledPIDController : public SendableBase {
|
||||
*/
|
||||
units::meter_t GetGoal() const;
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
* @param velocityTolerance The maximum allowable velocity error.
|
||||
* @param toleranceType The type of tolerance specified.
|
||||
*/
|
||||
bool AtGoal(
|
||||
double positionTolerance,
|
||||
double velocityTolerance = std::numeric_limits<double>::infinity(),
|
||||
frc2::PIDController::Tolerance toleranceType =
|
||||
frc2::PIDController::Tolerance::kAbsolute) const;
|
||||
|
||||
/**
|
||||
* Returns true if the error is within the tolerance of the error.
|
||||
*
|
||||
@@ -154,21 +139,6 @@ class ProfiledPIDController : public SendableBase {
|
||||
*/
|
||||
double GetSetpoint() const;
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
* @param velocityTolerance The maximum allowable velocity error.
|
||||
* @param toleranceType The type of tolerance specified.
|
||||
*/
|
||||
bool AtSetpoint(
|
||||
double positionTolerance,
|
||||
double velocityTolerance = std::numeric_limits<double>::infinity(),
|
||||
frc2::PIDController::Tolerance toleranceType =
|
||||
frc2::PIDController::Tolerance::kAbsolute) const;
|
||||
|
||||
/**
|
||||
* Returns true if the error is within the tolerance of the error.
|
||||
*
|
||||
@@ -180,14 +150,6 @@ class ProfiledPIDController : public SendableBase {
|
||||
*/
|
||||
bool AtSetpoint() const;
|
||||
|
||||
/**
|
||||
* Sets the minimum and maximum values expected from the input.
|
||||
*
|
||||
* @param minimumInput The minimum value expected from the input.
|
||||
* @param maximumInput The maximum value expected from the input.
|
||||
*/
|
||||
void SetInputRange(double minimumInput, double maximumInput);
|
||||
|
||||
/**
|
||||
* Enables continuous input.
|
||||
*
|
||||
@@ -214,24 +176,13 @@ class ProfiledPIDController : public SendableBase {
|
||||
void SetOutputRange(double minimumOutput, double maximumOutput);
|
||||
|
||||
/**
|
||||
* Sets the absolute error which is considered tolerable for use with
|
||||
* Sets the error which is considered tolerable for use with
|
||||
* AtSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
* @param velocityTolerance Velocity error which is tolerable.
|
||||
*/
|
||||
void SetAbsoluteTolerance(
|
||||
double positionTolerance,
|
||||
double velocityTolerance = std::numeric_limits<double>::infinity());
|
||||
|
||||
/**
|
||||
* Sets the percent error which is considered tolerable for use with
|
||||
* AtSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
* @param velocityTolerance Velocity error which is tolerable.
|
||||
*/
|
||||
void SetPercentTolerance(
|
||||
void SetTolerance(
|
||||
double positionTolerance,
|
||||
double velocityTolerance = std::numeric_limits<double>::infinity());
|
||||
|
||||
|
||||
@@ -25,15 +25,6 @@ TEST_F(PIDInputOutputTest, OutputRangeTest) {
|
||||
EXPECT_DOUBLE_EQ(50, controller->Calculate(0, 100));
|
||||
}
|
||||
|
||||
TEST_F(PIDInputOutputTest, InputRangeTest) {
|
||||
controller->SetP(1);
|
||||
controller->SetOutputRange(-1000, 1000);
|
||||
controller->SetInputRange(-50, 50);
|
||||
|
||||
EXPECT_DOUBLE_EQ(-100, controller->Calculate(100, 0));
|
||||
EXPECT_DOUBLE_EQ(50, controller->Calculate(0, 100));
|
||||
}
|
||||
|
||||
TEST_F(PIDInputOutputTest, ContinuousInputTest) {
|
||||
controller->SetP(1);
|
||||
controller->EnableContinuousInput(-180, 180);
|
||||
|
||||
@@ -8,68 +8,39 @@
|
||||
#include "frc/controller/PIDController.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
class PIDToleranceTest : public testing::Test {
|
||||
protected:
|
||||
static constexpr double kSetpoint = 50.0;
|
||||
static constexpr double kRange = 200;
|
||||
static constexpr double kTolerance = 10.0;
|
||||
static constexpr double kSetpoint = 50.0;
|
||||
static constexpr double kRange = 200;
|
||||
static constexpr double kTolerance = 10.0;
|
||||
|
||||
frc2::PIDController* pidController;
|
||||
TEST(PIDToleranceTest, InitialTolerance) {
|
||||
frc2::PIDController controller{0.5, 0.0, 0.0};
|
||||
controller.EnableContinuousInput(-kRange / 2, kRange / 2);
|
||||
|
||||
void SetUp() override {
|
||||
pidController = new frc2::PIDController(0.5, 0.0, 0.0);
|
||||
pidController->SetInputRange(-kRange / 2, kRange / 2);
|
||||
}
|
||||
|
||||
void TearDown() override { delete pidController; }
|
||||
};
|
||||
|
||||
TEST_F(PIDToleranceTest, Initial) { EXPECT_TRUE(pidController->AtSetpoint()); }
|
||||
|
||||
TEST_F(PIDToleranceTest, Absolute) {
|
||||
pidController->SetAbsoluteTolerance(kTolerance);
|
||||
pidController->SetSetpoint(kSetpoint);
|
||||
|
||||
pidController->Calculate(0.0);
|
||||
|
||||
EXPECT_FALSE(pidController->AtSetpoint())
|
||||
<< "Error was in tolerance when it should not have been. Error was "
|
||||
<< pidController->GetPositionError();
|
||||
|
||||
pidController->Calculate(kSetpoint + kTolerance / 2);
|
||||
|
||||
EXPECT_TRUE(pidController->AtSetpoint())
|
||||
<< "Error was not in tolerance when it should have been. Error was "
|
||||
<< pidController->GetPositionError();
|
||||
|
||||
pidController->Calculate(kSetpoint + 10 * kTolerance);
|
||||
|
||||
EXPECT_FALSE(pidController->AtSetpoint())
|
||||
<< "Error was in tolerance when it should not have been. Error was "
|
||||
<< pidController->GetPositionError();
|
||||
EXPECT_TRUE(controller.AtSetpoint());
|
||||
}
|
||||
|
||||
TEST_F(PIDToleranceTest, Percent) {
|
||||
pidController->SetPercentTolerance(kTolerance);
|
||||
pidController->SetSetpoint(kSetpoint);
|
||||
TEST(PIDToleranceTest, AbsoluteTolerance) {
|
||||
frc2::PIDController controller{0.5, 0.0, 0.0};
|
||||
controller.EnableContinuousInput(-kRange / 2, kRange / 2);
|
||||
|
||||
pidController->Calculate(0.0);
|
||||
controller.SetTolerance(kTolerance);
|
||||
controller.SetSetpoint(kSetpoint);
|
||||
|
||||
EXPECT_FALSE(pidController->AtSetpoint())
|
||||
controller.Calculate(0.0);
|
||||
|
||||
EXPECT_FALSE(controller.AtSetpoint())
|
||||
<< "Error was in tolerance when it should not have been. Error was "
|
||||
<< pidController->GetPositionError();
|
||||
<< controller.GetPositionError();
|
||||
|
||||
// Half of percent tolerance away from setpoint
|
||||
pidController->Calculate(kSetpoint + (kTolerance / 2) / 100 * kRange);
|
||||
controller.Calculate(kSetpoint + kTolerance / 2);
|
||||
|
||||
EXPECT_TRUE(pidController->AtSetpoint())
|
||||
EXPECT_TRUE(controller.AtSetpoint())
|
||||
<< "Error was not in tolerance when it should have been. Error was "
|
||||
<< pidController->GetPositionError();
|
||||
<< controller.GetPositionError();
|
||||
|
||||
// Double percent tolerance away from setpoint
|
||||
pidController->Calculate(kSetpoint + (kTolerance * 2) / 100 * kRange);
|
||||
controller.Calculate(kSetpoint + 10 * kTolerance);
|
||||
|
||||
EXPECT_FALSE(pidController->AtSetpoint())
|
||||
EXPECT_FALSE(controller.AtSetpoint())
|
||||
<< "Error was in tolerance when it should not have been. Error was "
|
||||
<< pidController->GetPositionError();
|
||||
<< controller.GetPositionError();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ ShooterSubsystem::ShooterSubsystem()
|
||||
m_shooterMotor(kShooterMotorPort),
|
||||
m_feederMotor(kFeederMotorPort),
|
||||
m_shooterEncoder(kEncoderPorts[0], kEncoderPorts[1]) {
|
||||
m_controller.SetAbsoluteTolerance(kShooterToleranceRPS);
|
||||
m_controller.SetTolerance(kShooterToleranceRPS);
|
||||
m_shooterEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ DriveStraight::DriveStraight(double distance, DriveTrain* drivetrain)
|
||||
[this](double output) { m_drivetrain->Drive(output, output); },
|
||||
{drivetrain}),
|
||||
m_drivetrain(drivetrain) {
|
||||
m_controller.SetAbsoluteTolerance(0.01);
|
||||
m_controller.SetTolerance(0.01);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
|
||||
@@ -18,7 +18,7 @@ SetDistanceToBox::SetDistanceToBox(double distance, DriveTrain* drivetrain)
|
||||
[this](double output) { m_drivetrain->Drive(output, output); },
|
||||
{drivetrain}),
|
||||
m_drivetrain(drivetrain) {
|
||||
m_controller.SetAbsoluteTolerance(0.01);
|
||||
m_controller.SetTolerance(0.01);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
|
||||
@@ -16,7 +16,7 @@ Elevator::Elevator()
|
||||
#ifdef SIMULATION // Check for simulation and update PID values
|
||||
GetPIDController()->SetPID(kP_simulation, kI_simulation, 0, 0);
|
||||
#endif
|
||||
m_controller.SetAbsoluteTolerance(0.005);
|
||||
m_controller.SetTolerance(0.005);
|
||||
|
||||
SetName("Elevator");
|
||||
// Let's show everything on the LiveWindow
|
||||
|
||||
@@ -14,7 +14,7 @@ Wrist::Wrist() : frc2::PIDSubsystem(frc2::PIDController(kP_real, 0, 0)) {
|
||||
#ifdef SIMULATION // Check for simulation and update PID values
|
||||
GetPIDController()->SetPID(kP_simulation, 0, 0, 0);
|
||||
#endif
|
||||
m_controller.SetAbsoluteTolerance(2.5);
|
||||
m_controller.SetTolerance(2.5);
|
||||
|
||||
SetName("Wrist");
|
||||
// Let's show everything on the LiveWindow
|
||||
|
||||
@@ -26,8 +26,7 @@ TurnToAngle::TurnToAngle(double targetAngleDegrees, DriveSubsystem* drive)
|
||||
// Set the controller tolerance - the delta tolerance ensures the robot is
|
||||
// stationary at the setpoint before it is considered as having reached the
|
||||
// reference
|
||||
m_controller.SetAbsoluteTolerance(kTurnToleranceDeg,
|
||||
kTurnRateToleranceDegPerS);
|
||||
m_controller.SetTolerance(kTurnToleranceDeg, kTurnRateToleranceDegPerS);
|
||||
|
||||
AddRequirements({drive});
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override { m_pidController.SetInputRange(0, 5); }
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
// When the button is pressed once, the selected elevator setpoint is
|
||||
// incremented.
|
||||
|
||||
@@ -22,10 +22,6 @@ class Robot : public frc::TimedRobot {
|
||||
* ultrasonic sensor.
|
||||
*/
|
||||
void TeleopInit() override {
|
||||
// Set expected range to 0-24 inches; e.g. at 24 inches from object go full
|
||||
// forward, at 0 inches from object go full backward.
|
||||
m_pidController.SetInputRange(0, 24 * kValueToInches);
|
||||
|
||||
// Set setpoint of the PID Controller
|
||||
m_pidController.SetSetpoint(kHoldDistance * kValueToInches);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ TEST_P(MotorEncoderTest, PositionPIDController) {
|
||||
Reset();
|
||||
double goal = 1000;
|
||||
frc2::PIDController pidController(0.001, 0.01, 0.0);
|
||||
pidController.SetAbsoluteTolerance(50.0);
|
||||
pidController.SetTolerance(50.0);
|
||||
pidController.SetOutputRange(-0.2, 0.2);
|
||||
pidController.SetSetpoint(goal);
|
||||
|
||||
@@ -166,7 +166,7 @@ TEST_P(MotorEncoderTest, VelocityPIDController) {
|
||||
Reset();
|
||||
|
||||
frc2::PIDController pidController(1e-5, 0.0, 0.0006);
|
||||
pidController.SetAbsoluteTolerance(200.0);
|
||||
pidController.SetTolerance(200.0);
|
||||
pidController.SetOutputRange(-0.3, 0.3);
|
||||
pidController.SetSetpoint(600);
|
||||
|
||||
|
||||
@@ -63,12 +63,6 @@ public class PIDController extends SendableBase {
|
||||
// The sum of the errors for use in the integral calc
|
||||
private double m_totalError;
|
||||
|
||||
enum Tolerance {
|
||||
kAbsolute, kPercent
|
||||
}
|
||||
|
||||
private Tolerance m_toleranceType = Tolerance.kAbsolute;
|
||||
|
||||
// The percentage or absolute error that is considered at setpoint.
|
||||
private double m_positionTolerance = 0.05;
|
||||
private double m_velocityTolerance = Double.POSITIVE_INFINITY;
|
||||
@@ -223,43 +217,8 @@ public class PIDController extends SendableBase {
|
||||
* @return Whether the error is within the acceptable bounds.
|
||||
*/
|
||||
public boolean atSetpoint() {
|
||||
return atSetpoint(m_positionTolerance, m_velocityTolerance, m_toleranceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error and change in error are below the specified tolerances.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
* @param velocityTolerance The maximum allowable velocity error.
|
||||
* @param toleranceType The type of tolerance specified.
|
||||
* @return Whether the error is within the acceptable bounds.
|
||||
*/
|
||||
public boolean atSetpoint(double positionTolerance, double velocityTolerance,
|
||||
Tolerance toleranceType) {
|
||||
if (toleranceType == Tolerance.kPercent) {
|
||||
return Math.abs(m_positionError) < positionTolerance / 100 * m_inputRange
|
||||
&& Math.abs(m_velocityError) < velocityTolerance / 100 * m_inputRange;
|
||||
} else {
|
||||
return Math.abs(m_positionError) < positionTolerance
|
||||
&& Math.abs(m_velocityError) < velocityTolerance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum and maximum values expected from the input.
|
||||
*
|
||||
* @param minimumInput The minimum value expected from the input.
|
||||
* @param maximumInput The maximum value expected from the input.
|
||||
*/
|
||||
public void setInputRange(double minimumInput, double maximumInput) {
|
||||
m_minimumInput = minimumInput;
|
||||
m_maximumInput = maximumInput;
|
||||
m_inputRange = maximumInput - minimumInput;
|
||||
|
||||
// Clamp setpoint to new input
|
||||
if (m_maximumInput > m_minimumInput) {
|
||||
m_setpoint = MathUtils.clamp(m_setpoint, m_minimumInput, m_maximumInput);
|
||||
}
|
||||
return Math.abs(m_positionError) < m_positionTolerance
|
||||
&& Math.abs(m_velocityError) < m_velocityTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,43 +255,21 @@ public class PIDController extends SendableBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the absolute error which is considered tolerable for use with atSetpoint().
|
||||
* Sets the error which is considered tolerable for use with atSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
*/
|
||||
public void setAbsoluteTolerance(double positionTolerance) {
|
||||
setAbsoluteTolerance(positionTolerance, Double.POSITIVE_INFINITY);
|
||||
public void setTolerance(double positionTolerance) {
|
||||
setTolerance(positionTolerance, Double.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the absolute error which is considered tolerable for use with atSetpoint().
|
||||
* Sets the error which is considered tolerable for use with atSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
* @param velocityTolerance Velocity error which is tolerable.
|
||||
*/
|
||||
public void setAbsoluteTolerance(double positionTolerance, double velocityTolerance) {
|
||||
m_toleranceType = Tolerance.kAbsolute;
|
||||
m_positionTolerance = positionTolerance;
|
||||
m_velocityTolerance = velocityTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the percent error which is considered tolerable for use with atSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
*/
|
||||
public void setPercentTolerance(double positionTolerance) {
|
||||
setPercentTolerance(positionTolerance, Double.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the percent error which is considered tolerable for use with atSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
* @param velocityTolerance Velocity error which is tolerable.
|
||||
*/
|
||||
public void setPercentTolerance(double positionTolerance, double velocityTolerance) {
|
||||
m_toleranceType = Tolerance.kPercent;
|
||||
public void setTolerance(double positionTolerance, double velocityTolerance) {
|
||||
m_positionTolerance = positionTolerance;
|
||||
m_velocityTolerance = velocityTolerance;
|
||||
}
|
||||
@@ -422,4 +359,21 @@ public class PIDController extends SendableBase {
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum and maximum values expected from the input.
|
||||
*
|
||||
* @param minimumInput The minimum value expected from the input.
|
||||
* @param maximumInput The maximum value expected from the input.
|
||||
*/
|
||||
private void setInputRange(double minimumInput, double maximumInput) {
|
||||
m_minimumInput = minimumInput;
|
||||
m_maximumInput = maximumInput;
|
||||
m_inputRange = maximumInput - minimumInput;
|
||||
|
||||
// Clamp setpoint to new input
|
||||
if (m_maximumInput > m_minimumInput) {
|
||||
m_setpoint = MathUtils.clamp(m_setpoint, m_minimumInput, m_maximumInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,46 +152,6 @@ public class ProfiledPIDController extends SendableBase {
|
||||
return m_goal.position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* <p>This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
*/
|
||||
public boolean atGoal(double positionTolerance) {
|
||||
return atGoal(positionTolerance, Double.POSITIVE_INFINITY, PIDController.Tolerance.kAbsolute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* <p>This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
* @param velocityTolerance The maximum allowable velocity error.
|
||||
*/
|
||||
public boolean atGoal(double positionTolerance, double velocityTolerance) {
|
||||
return atGoal(positionTolerance, velocityTolerance, PIDController.Tolerance.kAbsolute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* <p>This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
* @param velocityTolerance The maximum allowable velocity error.
|
||||
* @param toleranceType The type of tolerance specified.
|
||||
*/
|
||||
public boolean atGoal(
|
||||
double positionTolerance,
|
||||
double velocityTolerance,
|
||||
PIDController.Tolerance toleranceType) {
|
||||
return atSetpoint(positionTolerance, velocityTolerance, toleranceType)
|
||||
&& m_goal.equals(m_setpoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error is within the tolerance of the error.
|
||||
*
|
||||
@@ -219,46 +179,6 @@ public class ProfiledPIDController extends SendableBase {
|
||||
return m_controller.getSetpoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* <p>This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
*/
|
||||
public boolean atSetpoint(double positionTolerance) {
|
||||
return atSetpoint(positionTolerance, Double.POSITIVE_INFINITY,
|
||||
PIDController.Tolerance.kAbsolute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* <p>This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
* @param velocityTolerance The maximum allowable velocity error.
|
||||
*/
|
||||
public boolean atSetpoint(double positionTolerance, double velocityTolerance) {
|
||||
return atSetpoint(positionTolerance, velocityTolerance, PIDController.Tolerance.kAbsolute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error is within tolerance of the setpoint.
|
||||
*
|
||||
* <p>This will return false until at least one input value has been computed.
|
||||
*
|
||||
* @param positionTolerance The maximum allowable position error.
|
||||
* @param velocityTolerance The maximum allowable velocity error.
|
||||
* @param toleranceType The type of tolerance specified.
|
||||
*/
|
||||
public boolean atSetpoint(
|
||||
double positionTolerance,
|
||||
double velocityTolerance,
|
||||
PIDController.Tolerance toleranceType) {
|
||||
return m_controller.atSetpoint(positionTolerance, velocityTolerance, toleranceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the error is within the tolerance of the error.
|
||||
*
|
||||
@@ -268,16 +188,6 @@ public class ProfiledPIDController extends SendableBase {
|
||||
return m_controller.atSetpoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum and maximum values expected from the input.
|
||||
*
|
||||
* @param minimumInput The minimum value expected from the input.
|
||||
* @param maximumInput The maximum value expected from the input.
|
||||
*/
|
||||
public void setInputRange(double minimumInput, double maximumInput) {
|
||||
m_controller.setInputRange(minimumInput, maximumInput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables continuous input.
|
||||
*
|
||||
@@ -310,47 +220,22 @@ public class ProfiledPIDController extends SendableBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the absolute error which is considered tolerable for use with
|
||||
* atSetpoint().
|
||||
* Sets the error which is considered tolerable for use with atSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
*/
|
||||
public void setAbsoluteTolerance(double positionTolerance) {
|
||||
setAbsoluteTolerance(positionTolerance, Double.POSITIVE_INFINITY);
|
||||
public void setTolerance(double positionTolerance) {
|
||||
setTolerance(positionTolerance, Double.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the absolute error which is considered tolerable for use with
|
||||
* atSetpoint().
|
||||
* Sets the error which is considered tolerable for use with atSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
* @param velocityTolerance Velocity error which is tolerable.
|
||||
*/
|
||||
public void setAbsoluteTolerance(double positionTolerance, double velocityTolerance) {
|
||||
m_controller.setAbsoluteTolerance(positionTolerance, velocityTolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the percent error which is considered tolerable for use with
|
||||
* atSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
*/
|
||||
public void setPercentTolerance(double positionTolerance) {
|
||||
m_controller.setPercentTolerance(positionTolerance, Double.POSITIVE_INFINITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the percent error which is considered tolerable for use with
|
||||
* atSetpoint().
|
||||
*
|
||||
* @param positionTolerance Position error which is tolerable.
|
||||
* @param velocityTolerance Velocity error which is tolerable.
|
||||
*/
|
||||
public void setPercentTolerance(
|
||||
double positionTolerance,
|
||||
double velocityTolerance) {
|
||||
m_controller.setPercentTolerance(positionTolerance, velocityTolerance);
|
||||
public void setTolerance(double positionTolerance, double velocityTolerance) {
|
||||
m_controller.setTolerance(positionTolerance, velocityTolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,18 +33,6 @@ class PIDInputOutputTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void inputRangeTest() {
|
||||
m_controller.setP(1);
|
||||
m_controller.setOutputRange(-1000, 1000);
|
||||
m_controller.setInputRange(-50, 50);
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(-100, m_controller.calculate(100, 0), 1e-5),
|
||||
() -> assertEquals(50, m_controller.calculate(0, 100), 1e-5)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void continuousInputTest() {
|
||||
m_controller.setP(1);
|
||||
|
||||
@@ -7,83 +7,48 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.controller;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class PIDToleranceTest {
|
||||
private PIDController m_pidController;
|
||||
private static final double kSetpoint = 50.0;
|
||||
private static final double kTolerance = 10.0;
|
||||
private static final double kRange = 200;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
m_pidController = new PIDController(0.05, 0.0, 0.0);
|
||||
m_pidController.setInputRange(-kRange / 2, kRange / 2);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
m_pidController.close();
|
||||
m_pidController = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
void initialToleranceTest() {
|
||||
assertTrue(m_pidController.atSetpoint());
|
||||
var controller = new PIDController(0.05, 0.0, 0.0);
|
||||
controller.enableContinuousInput(-kRange / 2, kRange / 2);
|
||||
|
||||
assertTrue(controller.atSetpoint());
|
||||
}
|
||||
|
||||
@Test
|
||||
void absoluteToleranceTest() {
|
||||
m_pidController.setAbsoluteTolerance(kTolerance);
|
||||
m_pidController.setSetpoint(kSetpoint);
|
||||
var controller = new PIDController(0.05, 0.0, 0.0);
|
||||
controller.enableContinuousInput(-kRange / 2, kRange / 2);
|
||||
|
||||
m_pidController.calculate(0.0);
|
||||
controller.setTolerance(kTolerance);
|
||||
controller.setSetpoint(kSetpoint);
|
||||
|
||||
assertFalse(m_pidController.atSetpoint(),
|
||||
"Error was in tolerance when it should not have been. Error was " + m_pidController
|
||||
controller.calculate(0.0);
|
||||
|
||||
assertFalse(controller.atSetpoint(),
|
||||
"Error was in tolerance when it should not have been. Error was " + controller
|
||||
.getPositionError());
|
||||
|
||||
m_pidController.calculate(kSetpoint + kTolerance / 2);
|
||||
controller.calculate(kSetpoint + kTolerance / 2);
|
||||
|
||||
assertTrue(m_pidController.atSetpoint(),
|
||||
"Error was not in tolerance when it should have been. Error was " + m_pidController
|
||||
assertTrue(controller.atSetpoint(),
|
||||
"Error was not in tolerance when it should have been. Error was " + controller
|
||||
.getPositionError());
|
||||
|
||||
m_pidController.calculate(kSetpoint + 10 * kTolerance);
|
||||
controller.calculate(kSetpoint + 10 * kTolerance);
|
||||
|
||||
assertFalse(m_pidController.atSetpoint(),
|
||||
"Error was in tolerance when it should not have been. Error was " + m_pidController
|
||||
.getPositionError());
|
||||
}
|
||||
|
||||
@Test
|
||||
void percentToleranceTest() {
|
||||
m_pidController.setPercentTolerance(kTolerance);
|
||||
m_pidController.setSetpoint(kSetpoint);
|
||||
|
||||
m_pidController.calculate(0.0);
|
||||
|
||||
assertFalse(m_pidController.atSetpoint(),
|
||||
"Error was in tolerance when it should not have been. Error was " + m_pidController
|
||||
.getPositionError());
|
||||
|
||||
// Half of percent tolerance away from setpoint
|
||||
m_pidController.calculate(kSetpoint + (kTolerance / 2) / 100 * kRange);
|
||||
|
||||
assertTrue(m_pidController.atSetpoint(),
|
||||
"Error was not in tolerance when it should have been. Error was " + m_pidController
|
||||
.getPositionError());
|
||||
|
||||
// Double percent tolerance away from setpoint
|
||||
m_pidController.calculate(kSetpoint + (kTolerance * 2) / 100 * kRange);
|
||||
|
||||
assertFalse(m_pidController.atSetpoint(),
|
||||
"Error was in tolerance when it should not have been. Error was " + m_pidController
|
||||
assertFalse(controller.atSetpoint(),
|
||||
"Error was in tolerance when it should not have been. Error was " + controller
|
||||
.getPositionError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ShooterSubsystem extends PIDSubsystem {
|
||||
*/
|
||||
public ShooterSubsystem() {
|
||||
super(new PIDController(kP, kI, kD));
|
||||
getController().setAbsoluteTolerance(kShooterToleranceRPS);
|
||||
getController().setTolerance(kShooterToleranceRPS);
|
||||
m_shooterEncoder.setDistancePerPulse(kEncoderDistancePerPulse);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DriveStraight extends PIDCommand {
|
||||
m_drivetrain = drivetrain;
|
||||
addRequirements(m_drivetrain);
|
||||
|
||||
getController().setAbsoluteTolerance(0.01);
|
||||
getController().setTolerance(0.01);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SetDistanceToBox extends PIDCommand {
|
||||
m_drivetrain = drivetrain;
|
||||
addRequirements(m_drivetrain);
|
||||
|
||||
getController().setAbsoluteTolerance(0.01);
|
||||
getController().setTolerance(0.01);
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Elevator extends PIDSubsystem {
|
||||
if (Robot.isSimulation()) { // Check for simulation and update PID values
|
||||
getController().setPID(kP_simulation, kI_simulation, 0);
|
||||
}
|
||||
getController().setAbsoluteTolerance(0.005);
|
||||
getController().setTolerance(0.005);
|
||||
|
||||
m_motor = new Victor(5);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Wrist extends PIDSubsystem {
|
||||
if (Robot.isSimulation()) { // Check for simulation and update PID values
|
||||
getController().setPID(kP_simulation, 0, 0);
|
||||
}
|
||||
getController().setAbsoluteTolerance(2.5);
|
||||
getController().setTolerance(2.5);
|
||||
|
||||
m_motor = new Victor(6);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class TurnToAngle extends PIDCommand {
|
||||
getController().enableContinuousInput(-180, 180);
|
||||
// Set the controller tolerance - the delta tolerance ensures the robot is stationary at the
|
||||
// setpoint before it is considered as having reached the reference
|
||||
getController().setAbsoluteTolerance(kTurnToleranceDeg, kTurnRateToleranceDegPerS);
|
||||
getController().setTolerance(kTurnToleranceDeg, kTurnRateToleranceDegPerS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,7 +50,6 @@ public class Robot extends TimedRobot {
|
||||
m_joystick = new Joystick(kJoystickChannel);
|
||||
|
||||
m_pidController = new PIDController(kP, kI, kD);
|
||||
m_pidController.setInputRange(0, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,9 +21,6 @@ public class Robot extends TimedRobot {
|
||||
// distance in inches the robot wants to stay from an object
|
||||
private static final double kHoldDistance = 12.0;
|
||||
|
||||
// maximum distance in inches we expect the robot to see
|
||||
private static final double kMaxDistance = 24.0;
|
||||
|
||||
// factor to convert sensor values to a distance in inches
|
||||
private static final double kValueToInches = 0.125;
|
||||
|
||||
@@ -46,13 +43,6 @@ public class Robot extends TimedRobot {
|
||||
new PWMVictorSPX(kRightMotorPort));
|
||||
private final PIDController m_pidController = new PIDController(kP, kI, kD);
|
||||
|
||||
@Override
|
||||
public void robotInit() {
|
||||
// Set expected range to 0-24 inches; e.g. at 24 inches from object go
|
||||
// full forward, at 0 inches from object go full backward.
|
||||
m_pidController.setInputRange(0, kMaxDistance * kValueToInches);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleopInit() {
|
||||
// Set setpoint of the pid controller
|
||||
|
||||
@@ -177,7 +177,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
@Test
|
||||
public void testPositionPIDController() {
|
||||
PIDController pidController = new PIDController(0.001, 0.0005, 0);
|
||||
pidController.setAbsoluteTolerance(50.0);
|
||||
pidController.setTolerance(50.0);
|
||||
pidController.setOutputRange(-0.2, 0.2);
|
||||
pidController.setSetpoint(1000);
|
||||
|
||||
@@ -200,7 +200,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
public void testVelocityPIDController() {
|
||||
LinearFilter filter = LinearFilter.movingAverage(50);
|
||||
PIDController pidController = new PIDController(1e-5, 0.0, 0.0006);
|
||||
pidController.setAbsoluteTolerance(200);
|
||||
pidController.setTolerance(200);
|
||||
pidController.setOutputRange(-0.3, 0.3);
|
||||
pidController.setSetpoint(600);
|
||||
|
||||
|
||||
@@ -117,8 +117,8 @@ public class PIDTest extends AbstractComsSetup {
|
||||
me.reset();
|
||||
}
|
||||
|
||||
private void setupAbsoluteTolerance() {
|
||||
m_controller.setAbsoluteTolerance(absoluteTolerance);
|
||||
private void setupTolerance() {
|
||||
m_controller.setTolerance(absoluteTolerance);
|
||||
}
|
||||
|
||||
private void setupOutputRange() {
|
||||
@@ -127,7 +127,7 @@ public class PIDTest extends AbstractComsSetup {
|
||||
|
||||
@Test
|
||||
public void testInitialSettings() {
|
||||
setupAbsoluteTolerance();
|
||||
setupTolerance();
|
||||
setupOutputRange();
|
||||
double reference = 2500.0;
|
||||
m_controller.setSetpoint(reference);
|
||||
@@ -143,7 +143,7 @@ public class PIDTest extends AbstractComsSetup {
|
||||
|
||||
@Test
|
||||
public void testSetSetpoint() {
|
||||
setupAbsoluteTolerance();
|
||||
setupTolerance();
|
||||
setupOutputRange();
|
||||
double reference = 2500.0;
|
||||
m_controller.setSetpoint(reference);
|
||||
@@ -152,7 +152,7 @@ public class PIDTest extends AbstractComsSetup {
|
||||
|
||||
@Test(timeout = 10000)
|
||||
public void testRotateToTarget() {
|
||||
setupAbsoluteTolerance();
|
||||
setupTolerance();
|
||||
setupOutputRange();
|
||||
double reference = 1000.0;
|
||||
assertEquals(pidData() + "did not start at 0", 0, me.getMotor().get(), 0);
|
||||
|
||||
Reference in New Issue
Block a user