Class ProfiledPIDSubsystem

All Implemented Interfaces:
Sendable, Subsystem

public abstract class ProfiledPIDSubsystem
extends SubsystemBase
A subsystem that uses a ProfiledPIDController to control an output. The controller is run synchronously from the subsystem's periodic() method.
  • Field Details

  • Constructor Details

    • ProfiledPIDSubsystem

      public ProfiledPIDSubsystem​(ProfiledPIDController controller, double initialPosition)
      Creates a new ProfiledPIDSubsystem.
      controller - the ProfiledPIDController to use
      initialPosition - the initial goal position of the controller
    • ProfiledPIDSubsystem

      public ProfiledPIDSubsystem​(ProfiledPIDController controller)
      Creates a new ProfiledPIDSubsystem. Initial goal position is zero.
      controller - the ProfiledPIDController 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 ProfiledPIDController getController()
    • setGoal

      public void setGoal​(TrapezoidProfile.State goal)
      Sets the goal state for the subsystem.
      goal - The goal state for the subsystem's motion profile.
    • setGoal

      public void setGoal​(double goal)
      Sets the goal state for the subsystem. Goal velocity assumed to be zero.
      goal - The goal position for the subsystem's motion profile.
    • useOutput

      protected abstract void useOutput​(double output, TrapezoidProfile.State setpoint)
      Uses the output from the ProfiledPIDController.
      output - the output of the ProfiledPIDController
      setpoint - the setpoint state of the ProfiledPIDController, for feedforward
    • getMeasurement

      protected abstract double getMeasurement()
      Returns the measurement of the process variable used by the ProfiledPIDController.
      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.
    • isEnabled

      public boolean isEnabled()
      Returns whether the controller is enabled.
      Whether the controller is enabled.