Class PIDSubsystem

java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
edu.wpi.first.wpilibj2.command.PIDSubsystem
All Implemented Interfaces:
Subsystem

public abstract class PIDSubsystem
extends SubsystemBase
A subsystem that uses a PIDController to control an output. The controller is run synchronously from the subsystem's periodic() method.
  • Constructor Summary

    Constructors 
    Constructor Description
    PIDSubsystem​(PIDController controller)
    Creates a new PIDSubsystem.
  • Method Summary

    Modifier and Type Method Description
    void disable()
    Disables the PID control.
    void enable()
    Enables the PID control.
    PIDController getController()  
    abstract double getMeasurement()
    Returns the measurement of the process variable used by the PIDController.
    abstract double getSetpoint()
    Returns the reference (setpoint) used by the PIDController.
    void periodic()
    This method is called periodically by the CommandScheduler.
    abstract void useOutput​(double output)
    Uses the output from the PIDController.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem

    getCurrentCommand, getDefaultCommand, register, setDefaultCommand
  • Constructor Details

    • PIDSubsystem

      public PIDSubsystem​(PIDController controller)
      Creates a new PIDSubsystem.
      Parameters:
      controller - the PIDController to use
  • Method Details

    • periodic

      public void periodic()
      Description copied from interface: Subsystem
      This method is called periodically by the CommandScheduler. Useful for updating subsystem-specific state that you don't want to offload to a Command. Teams should try to be consistent within their own codebases about which responsibilities will be handled by Commands, and which will be handled here.
    • getController

      public PIDController getController()
    • useOutput

      public abstract void useOutput​(double output)
      Uses the output from the PIDController.
      Parameters:
      output - the output of the PIDController
    • getSetpoint

      public abstract double getSetpoint()
      Returns the reference (setpoint) used by the PIDController.
      Returns:
      the reference (setpoint) to be used by the controller
    • getMeasurement

      public abstract double getMeasurement()
      Returns the measurement of the process variable used by the PIDController.
      Returns:
      the measurement of the process variable
    • enable

      public void enable()
      Enables the PID control. Resets the controller.
    • disable

      public void disable()
      Disables the PID control. Sets output to zero.