ProfiledPIDControllerRadians

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

Bases: 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: wpimath._controls._controls.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: wpimath._controls._controls.controller.ProfiledPIDControllerRadians, measurement: radians, goal: wpimath._controls._controls.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: wpimath._controls._controls.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: wpimath._controls._controls.controller.ProfiledPIDControllerRadians, measurement: radians, goal: radians, constraints: wpimath._controls._controls.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._controls._controls.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.

getPositionTolerance() float

Gets the position tolerance of this controller.

Returns:

The position tolerance of the controller.

getSetpoint() wpimath._controls._controls.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.

getVelocityTolerance() float

Gets the velocity tolerance of this controller.

Returns:

The velocity tolerance of the controller.

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

Overloaded function.

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

Reset the previous error and the integral term.

Parameters:

measurement – The current measured State of the system.

  1. reset(self: wpimath._controls._controls.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: wpimath._controls._controls.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._controls._controls.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: wpimath._controls._controls.controller.ProfiledPIDControllerRadians, goal: wpimath._controls._controls.trajectory.TrapezoidProfileRadians.State) -> None

Sets the goal for the ProfiledPIDController.

Parameters:

goal – The desired unprofiled setpoint.

  1. setGoal(self: wpimath._controls._controls.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.