From 2a98d6b5d7bf31d038ada5e85a8b3a449fb0bf1d Mon Sep 17 00:00:00 2001 From: Justin <7595639+tervay@users.noreply.github.com> Date: Tue, 25 Oct 2022 19:10:19 -0400 Subject: [PATCH] [wpimath] PIDController: Add getters for position & velocity tolerances (#4458) --- .../first/math/controller/PIDController.java | 18 ++++++++++++++++++ .../math/controller/ProfiledPIDController.java | 18 ++++++++++++++++++ .../native/cpp/controller/PIDController.cpp | 8 ++++++++ .../include/frc/controller/PIDController.h | 14 ++++++++++++++ .../frc/controller/ProfiledPIDController.h | 18 ++++++++++++++++++ 5 files changed, 76 insertions(+) diff --git a/wpimath/src/main/java/edu/wpi/first/math/controller/PIDController.java b/wpimath/src/main/java/edu/wpi/first/math/controller/PIDController.java index 49c077dad0..de4559feff 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/controller/PIDController.java +++ b/wpimath/src/main/java/edu/wpi/first/math/controller/PIDController.java @@ -174,6 +174,24 @@ public class PIDController implements Sendable, AutoCloseable { return m_period; } + /** + * Returns the position tolerance of this controller. + * + * @return the position tolerance of the controller. + */ + public double getPositionTolerance() { + return m_positionTolerance; + } + + /** + * Returns the velocity tolerance of this controller. + * + * @return the velocity tolerance of the controller. + */ + public double getVelocityTolerance() { + return m_velocityTolerance; + } + /** * Sets the setpoint for the PIDController. * diff --git a/wpimath/src/main/java/edu/wpi/first/math/controller/ProfiledPIDController.java b/wpimath/src/main/java/edu/wpi/first/math/controller/ProfiledPIDController.java index fd3587ebc5..681e3fc54b 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/controller/ProfiledPIDController.java +++ b/wpimath/src/main/java/edu/wpi/first/math/controller/ProfiledPIDController.java @@ -131,6 +131,24 @@ public class ProfiledPIDController implements Sendable { return m_controller.getPeriod(); } + /** + * Returns the position tolerance of this controller. + * + * @return the position tolerance of the controller. + */ + public double getPositionTolerance() { + return m_controller.getPositionTolerance(); + } + + /** + * Returns the velocity tolerance of this controller. + * + * @return the velocity tolerance of the controller. + */ + public double getVelocityTolerance() { + return m_controller.getVelocityTolerance(); + } + /** * Sets the goal for the ProfiledPIDController. * diff --git a/wpimath/src/main/native/cpp/controller/PIDController.cpp b/wpimath/src/main/native/cpp/controller/PIDController.cpp index 63255a6f34..6c89d2585b 100644 --- a/wpimath/src/main/native/cpp/controller/PIDController.cpp +++ b/wpimath/src/main/native/cpp/controller/PIDController.cpp @@ -68,6 +68,14 @@ units::second_t PIDController::GetPeriod() const { return m_period; } +double PIDController::GetPositionTolerance() const { + return m_positionTolerance; +} + +double PIDController::GetVelocityTolerance() const { + return m_velocityTolerance; +} + void PIDController::SetSetpoint(double setpoint) { m_setpoint = setpoint; diff --git a/wpimath/src/main/native/include/frc/controller/PIDController.h b/wpimath/src/main/native/include/frc/controller/PIDController.h index 98625f8c14..d6a41d1949 100644 --- a/wpimath/src/main/native/include/frc/controller/PIDController.h +++ b/wpimath/src/main/native/include/frc/controller/PIDController.h @@ -101,6 +101,20 @@ class WPILIB_DLLEXPORT PIDController */ units::second_t GetPeriod() const; + /** + * Gets the position tolerance of this controller. + * + * @return The position tolerance of the controller. + */ + double GetPositionTolerance() const; + + /** + * Gets the velocity tolerance of this controller. + * + * @return The velocity tolerance of the controller. + */ + double GetVelocityTolerance() const; + /** * Sets the setpoint for the PIDController. * diff --git a/wpimath/src/main/native/include/frc/controller/ProfiledPIDController.h b/wpimath/src/main/native/include/frc/controller/ProfiledPIDController.h index 1d8d5fc249..086c53ebe0 100644 --- a/wpimath/src/main/native/include/frc/controller/ProfiledPIDController.h +++ b/wpimath/src/main/native/include/frc/controller/ProfiledPIDController.h @@ -131,6 +131,24 @@ class ProfiledPIDController */ units::second_t GetPeriod() const { return m_controller.GetPeriod(); } + /** + * Gets the position tolerance of this controller. + * + * @return The position tolerance of the controller. + */ + double GetPositionTolerance() const { + return m_controller.GetPositionTolerance(); + } + + /** + * Gets the velocity tolerance of this controller. + * + * @return The velocity tolerance of the controller. + */ + double GetVelocityTolerance() const { + return m_controller.GetVelocityTolerance(); + } + /** * Sets the goal for the ProfiledPIDController. *