Improve various subsystem APIs (#2130)

Improves the APIs for various prebuilt subsystems (PIDSubsystem, TrapezoidProfileSubsystem, ProfiledPIDSubsystem). Addresses #2128, and also changes the rather cumbersome getSetpoint API to a more intuitive setSetpoint one. Updates examples to match.
This commit is contained in:
Oblarg
2019-11-26 00:46:47 -05:00
committed by Peter Johnson
parent ce3973435e
commit 6dcd2b0e2c
19 changed files with 184 additions and 204 deletions

View File

@@ -28,8 +28,6 @@ void Elevator::Log() { frc::SmartDashboard::PutData("Wrist Pot", &m_pot); }
double Elevator::GetMeasurement() { return m_pot.Get(); }
void Elevator::UseOutput(double d) { m_motor.Set(d); }
double Elevator::GetSetpoint() { return m_setpoint; }
void Elevator::SetSetpoint(double setpoint) { m_setpoint = setpoint; }
void Elevator::UseOutput(double output, double setpoint) {
m_motor.Set(output);
}

View File

@@ -26,10 +26,6 @@ void Wrist::Log() {
// frc::SmartDashboard::PutData("Wrist Angle", &m_pot);
}
double Wrist::GetSetpoint() { return m_setpoint; }
void Wrist::SetSetpoint(double setpoint) { m_setpoint = setpoint; }
double Wrist::GetMeasurement() { return m_pot.Get(); }
void Wrist::UseOutput(double d) { m_motor.Set(d); }
void Wrist::UseOutput(double output, double setpoint) { m_motor.Set(output); }

View File

@@ -37,14 +37,7 @@ class Elevator : public frc2::PIDSubsystem {
* by
* the subsystem.
*/
void UseOutput(double d) override;
double GetSetpoint() override;
/**
* Sets the setpoint for the subsystem.
*/
void SetSetpoint(double setpoint);
void UseOutput(double output, double setpoint) override;
private:
frc::PWMVictorSPX m_motor{5};

View File

@@ -35,14 +35,7 @@ class Wrist : public frc2::PIDSubsystem {
* by
* the subsystem.
*/
void UseOutput(double d) override;
double GetSetpoint() override;
/**
* Sets the setpoint for the subsystem.
*/
void SetSetpoint(double setpoint);
void UseOutput(double output, double setpoint) override;
private:
frc::PWMVictorSPX m_motor{6};