PIDCommand

class commands2.PIDCommand(*args, **kwargs)[source]

Bases: Command

A command that controls an output with a wpimath.controller.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.

Creates a new PIDCommand, which controls the given output with a wpimath.controller.PIDController.

Parameters:
  • controller – the controller that controls the output.

  • measurementSource – the measurement of the process variable

  • setpoint – the controller’s setpoint (either a function that returns a) number or a number

  • useOutput – the controller’s output

  • requirements – the subsystems required by this command

end(interrupted)[source]

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 andThen() instead.

Parameters:

interrupted – whether the command was interrupted/canceled

execute()[source]

The main body of a command. Called repeatedly while the command is scheduled.

getController()[source]

Returns the PIDController used by the command.

Returns:

The PIDController

initialize()[source]

The initial subroutine of a command. Called once when the command is initially scheduled.