Class PIDController

Class Documentation

class PIDController

Class used as a Proportional-Integral-Derivative controller.

Public Functions

PIDController(double _kp, double _ki, double _kd)

Creates a new PID controller with the given gains

Parameters
  • _kp – proportional gain

  • _ki – integral gain

  • _kd – derivative gain

void setTolerance(double _errorTolerance, double _derivativeTolerance = (1 << 30))

Sets the maximum tolerance of the controller

Parameters
  • _errorTolerance – maximum error tolerance

  • _derivativeTolerance – maximum derivative tolerance. Defaults to infinity

void setIntegratorRange(double _integratorRangeMin, double _integratorRangeMax)

Sets the error range in which the integral will accumulate

Parameters
  • _integratorRangeMin – lower bound of the range

  • _integratorRangeMax – upper bound of the range

void setOutputRange(double _minOutput, double _maxOutput)

Sets the range of possible output values

Parameters
  • _minOutput – lower bound for output values

  • _maxOutput – upper bound for output values

void setDeltaTime(Units::Time _deltaTime)

Sets the amount of time between each controller loop

void setSetpoint(double _setpoint)

Sets the target value of the controller

bool atSetpoint()

Returns whether or not the controller has reached the setpoint based on the controller’s tolerance

double getOutput()

Returns the computed control input

void update(double measurement)

Update the PID controller with the new measured value