diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDSubsystem.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDSubsystem.java index f9337c6052..9badc34336 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDSubsystem.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/PIDSubsystem.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -61,6 +61,15 @@ public abstract class PIDSubsystem extends SubsystemBase { m_setpoint = setpoint; } + /** + * Returns the current setpoint of the subsystem. + * + * @return The current setpoint + */ + public double getSetpoint() { + return m_setpoint; + } + /** * Uses the output from the PIDController. * diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDSubsystem.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDSubsystem.cpp index 14d965ce76..39eec29c58 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDSubsystem.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDSubsystem.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -22,6 +22,8 @@ void PIDSubsystem::Periodic() { void PIDSubsystem::SetSetpoint(double setpoint) { m_setpoint = setpoint; } +double PIDSubsystem::GetSetpoint() const { return m_setpoint; } + void PIDSubsystem::Enable() { m_controller.Reset(); m_enabled = true; diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/PIDSubsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/PIDSubsystem.h index 3a6df88c1e..608fe563f7 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/PIDSubsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/PIDSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -37,6 +37,13 @@ class PIDSubsystem : public SubsystemBase { */ void SetSetpoint(double setpoint); + /** + * Gets the setpoint for the subsystem. + * + * @return the setpoint for the subsystem + */ + double GetSetpoint() const; + /** * Enables the PID control. Resets the controller. */