Class ProfiledPIDCommand

  • All Implemented Interfaces:
    Sendable, Command

    public class ProfiledPIDCommand
    extends CommandBase
    A command that controls an output with a ProfiledPIDController. 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.
    • Constructor Detail

      • ProfiledPIDCommand

        public ProfiledPIDCommand​(ProfiledPIDController controller,
                                  DoubleSupplier measurementSource,
                                  Supplier<TrapezoidProfile.State> goalSource,
                                  BiConsumer<Double,​TrapezoidProfile.State> useOutput,
                                  Subsystem... requirements)
        Creates a new PIDCommand, which controls the given output with a ProfiledPIDController. Goal velocity is specified.
        Parameters:
        controller - the controller that controls the output.
        measurementSource - the measurement of the process variable
        goalSource - the controller's goal
        useOutput - the controller's output
        requirements - the subsystems required by this command
      • ProfiledPIDCommand

        public ProfiledPIDCommand​(ProfiledPIDController controller,
                                  DoubleSupplier measurementSource,
                                  DoubleSupplier goalSource,
                                  BiConsumer<Double,​TrapezoidProfile.State> useOutput,
                                  Subsystem... requirements)
        Creates a new PIDCommand, which controls the given output with a ProfiledPIDController. Goal velocity is implicitly zero.
        Parameters:
        controller - the controller that controls the output.
        measurementSource - the measurement of the process variable
        goalSource - the controller's goal
        useOutput - the controller's output
        requirements - the subsystems required by this command
      • ProfiledPIDCommand

        public ProfiledPIDCommand​(ProfiledPIDController controller,
                                  DoubleSupplier measurementSource,
                                  TrapezoidProfile.State goal,
                                  BiConsumer<Double,​TrapezoidProfile.State> useOutput,
                                  Subsystem... requirements)
        Creates a new PIDCommand, which controls the given output with a ProfiledPIDController. Goal velocity is specified.
        Parameters:
        controller - the controller that controls the output.
        measurementSource - the measurement of the process variable
        goal - the controller's goal
        useOutput - the controller's output
        requirements - the subsystems required by this command
      • ProfiledPIDCommand

        public ProfiledPIDCommand​(ProfiledPIDController controller,
                                  DoubleSupplier measurementSource,
                                  double goal,
                                  BiConsumer<Double,​TrapezoidProfile.State> useOutput,
                                  Subsystem... requirements)
        Creates a new PIDCommand, which controls the given output with a ProfiledPIDController. Goal velocity is implicitly zero.
        Parameters:
        controller - the controller that controls the output.
        measurementSource - the measurement of the process variable
        goal - the controller's goal
        useOutput - the controller's output
        requirements - the subsystems required by this command
    • Method Detail

      • initialize

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

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

        public void end​(boolean interrupted)
        Description copied from interface: 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.

        Parameters:
        interrupted - whether the command was interrupted/canceled
      • getController

        public ProfiledPIDController getController()
        Returns the ProfiledPIDController used by the command.
        Returns:
        The ProfiledPIDController