ProfiledPIDControllerRadians

class wpilib.controller.ProfiledPIDControllerRadians(Kp: float, Ki: float, Kd: float, constraints: wpimath.trajectory._trajectory.TrapezoidProfileRadians.Constraints, period: seconds = 0.02)

Bases: wpilib.Sendable

Implements a PID control loop whose setpoint is constrained by a trapezoid profile.

Allocates a ProfiledPIDController with the given constants for Kp, Ki, and Kd. Users should call reset() when they first start running the controller to avoid unwanted behavior.

Parameters
  • Kp – The proportional coefficient.

  • Ki – The integral coefficient.

  • Kd – The derivative coefficient.

  • constraints – Velocity and acceleration constraints for goal.

  • period – The period between controller updates in seconds. The default is 20 milliseconds.

atGoal()bool

Returns true if the error is within the tolerance of the error.

This will return false until at least one input value has been computed.

atSetpoint()bool

Returns true if the error is within the tolerance of the error.

Currently this just reports on target as the actual value passes through the setpoint. Ideally it should be based on being within the tolerance for some period of time.

This will return false until at least one input value has been computed.

calculate(*args, **kwargs)

Overloaded function.

  1. calculate(self: wpilib.controller._controller.ProfiledPIDControllerRadians, measurement: radians) -> float

Returns the next output of the PID controller.

Parameters

measurement – The current measurement of the process variable.

  1. calculate(self: wpilib.controller._controller.ProfiledPIDControllerRadians, measurement: radians, goal: wpimath.trajectory._trajectory.TrapezoidProfileRadians.State) -> float

Returns the next output of the PID controller.

Parameters
  • measurement – The current measurement of the process variable.

  • goal – The new goal of the controller.

  1. calculate(self: wpilib.controller._controller.ProfiledPIDControllerRadians, measurement: radians, goal: radians) -> float

Returns the next output of the PID controller.

Parameters
  • measurement – The current measurement of the process variable.

  • goal – The new goal of the controller.

  1. calculate(self: wpilib.controller._controller.ProfiledPIDControllerRadians, measurement: radians, goal: radians, constraints: wpimath.trajectory._trajectory.TrapezoidProfileRadians.Constraints) -> float

Returns the next output of the PID controller.

Parameters
  • measurement – The current measurement of the process variable.

  • goal – The new goal of the controller.

  • constraints – Velocity and acceleration constraints for goal.

disableContinuousInput()None

Disables continuous input.

enableContinuousInput(minimumInput: radians, maximumInput: radians)None

Enables continuous input.

Rather then using the max and min input range as constraints, it considers them to be the same point and automatically calculates the shortest route to the setpoint.

Parameters
  • minimumInput – The minimum value expected from the input.

  • maximumInput – The maximum value expected from the input.

getD()float

Gets the differential coefficient.

Returns

differential coefficient

getGoal()wpimath.trajectory._trajectory.TrapezoidProfileRadians.State

Gets the goal for the ProfiledPIDController.

getI()float

Gets the integral coefficient.

Returns

integral coefficient

getP()float

Gets the proportional coefficient.

Returns

proportional coefficient

getPeriod()seconds

Gets the period of this controller.

Returns

The period of the controller.

getPositionError()radians

Returns the difference between the setpoint and the measurement.

Returns

The error.

getSetpoint()wpimath.trajectory._trajectory.TrapezoidProfileRadians.State

Returns the current setpoint of the ProfiledPIDController.

Returns

The current setpoint.

getVelocityError()radians_per_second

Returns the change in error per second.

initSendable(builder: wpilib.SendableBuilder)None
reset(*args, **kwargs)

Overloaded function.

  1. reset(self: wpilib.controller._controller.ProfiledPIDControllerRadians, measurement: wpimath.trajectory._trajectory.TrapezoidProfileRadians.State) -> None

Reset the previous error and the integral term.

Parameters

measurement – The current measured State of the system.

  1. reset(self: wpilib.controller._controller.ProfiledPIDControllerRadians, measuredPosition: radians, measuredVelocity: radians_per_second) -> None

Reset the previous error and the integral term.

Parameters
  • measuredPosition – The current measured position of the system.

  • measuredVelocity – The current measured velocity of the system.

  1. reset(self: wpilib.controller._controller.ProfiledPIDControllerRadians, measuredPosition: radians) -> None

Reset the previous error and the integral term.

Parameters

measuredPosition – The current measured position of the system. The velocity is assumed to be zero.

setConstraints(constraints: wpimath.trajectory._trajectory.TrapezoidProfileRadians.Constraints)None

Set velocity and acceleration constraints for goal.

Parameters

constraints – Velocity and acceleration constraints for goal.

setD(Kd: float)None

Sets the differential coefficient of the PID controller gain.

Parameters

Kd – differential coefficient

setGoal(*args, **kwargs)

Overloaded function.

  1. setGoal(self: wpilib.controller._controller.ProfiledPIDControllerRadians, goal: wpimath.trajectory._trajectory.TrapezoidProfileRadians.State) -> None

Sets the goal for the ProfiledPIDController.

Parameters

goal – The desired unprofiled setpoint.

  1. setGoal(self: wpilib.controller._controller.ProfiledPIDControllerRadians, goal: radians) -> None

Sets the goal for the ProfiledPIDController.

Parameters

goal – The desired unprofiled setpoint.

setI(Ki: float)None

Sets the integral coefficient of the PID controller gain.

Parameters

Ki – integral coefficient

setIntegratorRange(minimumIntegral: float, maximumIntegral: float)None

Sets the minimum and maximum values for the integrator.

When the cap is reached, the integrator value is added to the controller output rather than the integrator value times the integral gain.

Parameters
  • minimumIntegral – The minimum value of the integrator.

  • maximumIntegral – The maximum value of the integrator.

setP(Kp: float)None

Sets the proportional coefficient of the PID controller gain.

Parameters

Kp – proportional coefficient

setPID(Kp: float, Ki: float, Kd: float)None

Sets the PID Controller gain parameters.

Sets the proportional, integral, and differential coefficients.

Parameters
  • Kp – Proportional coefficient

  • Ki – Integral coefficient

  • Kd – Differential coefficient

setTolerance(positionTolerance: radians, velocityTolerance: radians_per_second = inf)None

Sets the error which is considered tolerable for use with AtSetpoint().

Parameters
  • positionTolerance – Position error which is tolerable.

  • velocityTolerance – Velocity error which is tolerable.