Class PIDCommand

java.lang.Object
edu.wpi.first.wpilibj2.command.Command
edu.wpi.first.wpilibj2.command.PIDCommand
All Implemented Interfaces:
Sendable

public class PIDCommand extends Command
A command that controls an output with a PIDController. Runs forever by default - to add exit conditions and/or other behavior, subclass this class. The controller calculation and output are performed synchronously in the command's execute() method.

This class is provided by the NewCommands VendorDep

  • Field Details

  • Constructor Details

    • PIDCommand

      public PIDCommand(PIDController controller, DoubleSupplier measurementSource, DoubleSupplier setpointSource, DoubleConsumer useOutput, Subsystem... requirements)
      Creates a new PIDCommand, which controls the given output with a PIDController.
      Parameters:
      controller - the controller that controls the output.
      measurementSource - the measurement of the process variable
      setpointSource - the controller's setpoint
      useOutput - the controller's output
      requirements - the subsystems required by this command
    • PIDCommand

      public PIDCommand(PIDController controller, DoubleSupplier measurementSource, double setpoint, DoubleConsumer useOutput, Subsystem... requirements)
      Creates a new PIDCommand, which controls the given output with a PIDController.
      Parameters:
      controller - the controller that controls the output.
      measurementSource - the measurement of the process variable
      setpoint - the controller's setpoint
      useOutput - the controller's output
      requirements - the subsystems required by this command
  • Method Details

    • initialize

      public void initialize()
      Description copied from class: Command
      The initial subroutine of a command. Called once when the command is initially scheduled.
      Overrides:
      initialize in class Command
    • execute

      public void execute()
      Description copied from class: Command
      The main body of a command. Called repeatedly while the command is scheduled.
      Overrides:
      execute in class Command
    • end

      public void end(boolean interrupted)
      Description copied from class: Command
      The action to take when the command ends. Called when either the command finishes normally, or when it interrupted/canceled.

      Do not schedule commands here that share requirements with this command. Use Command.andThen(Command...) instead.

      Overrides:
      end in class Command
      Parameters:
      interrupted - whether the command was interrupted/canceled
    • getController

      Returns the PIDController used by the command.
      Returns:
      The PIDController