ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
Public Member Functions | List of all members
arpirobot::PID Class Reference

#include <arpirobot/core/action/PID.hpp>

Public Member Functions

 PID (double kp=0, double ki=0, double kd=0, double kf=0, double min=-1.0, double max=1.0)
 
double getKp ()
 
void setKp (double kp)
 
double getKi ()
 
void setKi (double ki)
 
double getKd ()
 
void setKd (double kd)
 
double getKf ()
 
void setKf (double kf)
 
double getMin ()
 
void setMin (double min)
 
double getMax ()
 
void setMax (double max)
 
double getSetpoint ()
 
void setSetpoint (double setpoint)
 
void reset ()
 
double getOutput (double currentPv)
 

Detailed Description

Implementation of a simple PID controller with feedforward gain support.

Constructor & Destructor Documentation

◆ PID()

arpirobot::PID::PID ( double  kp = 0,
double  ki = 0,
double  kd = 0,
double  kf = 0,
double  min = -1.0,
double  max = 1.0 
)

Construct a new PID object

Parameters
kpProportional gain
kiIntegral gain
kdDerivative gain
kfFeedforward gain (often not used, but useful for some systems)
minMinimum value to cap PID output at
maxMaximum value to cap PID output at

Member Function Documentation

◆ getKd()

double arpirobot::PID::getKd ( )

Get the derivitive gain

Returns
derivative gain (kd)

◆ getKf()

double arpirobot::PID::getKf ( )

Get the feedforward gain

Returns
feedforward gain (kf)

◆ getKi()

double arpirobot::PID::getKi ( )

Get the integral gain

Returns
integral gain (ki)

◆ getKp()

double arpirobot::PID::getKp ( )

Get the proportional gain

Returns
proportional gain (kp)

◆ getMax()

double arpirobot::PID::getMax ( )

Get the maximum allowed PID output

Returns
max allowed PID output

◆ getMin()

double arpirobot::PID::getMin ( )

Get the minimum allowed PID output

Returns
min allowed PID output

◆ getOutput()

double arpirobot::PID::getOutput ( double  currentPv)

Calculate the current output of the PID controller.

Parameters
currentPvCurrent value of the process variable.
Returns
The PID controller's output, capped at the set min and max values

◆ getSetpoint()

double arpirobot::PID::getSetpoint ( )

Get the controller's current setpoint

Returns
Current setpoint

◆ reset()

void arpirobot::PID::reset ( )

Reset the PID controller's internal state. This resets the accumulated integral value and the previous error used by the derivative gain.

◆ setKd()

void arpirobot::PID::setKd ( double  kd)

Set the derivative gain

Parameters
kdNew value of kd

◆ setKf()

void arpirobot::PID::setKf ( double  kf)

Set the feedforward gain

Parameters
kfNew value of kf

◆ setKi()

void arpirobot::PID::setKi ( double  ki)

Set the integral gain (ki)

Parameters
kiNew value of ki

◆ setKp()

void arpirobot::PID::setKp ( double  kp)

Set the proportional gain (kp)

Parameters
kpNew value of kp

◆ setMax()

void arpirobot::PID::setMax ( double  max)

Set the maximum allowed PID output

Parameters
maxNew max allowed PID output

◆ setMin()

void arpirobot::PID::setMin ( double  min)

Set the minimum allowed PID output

Parameters
minNew min allowed PID output

◆ setSetpoint()

void arpirobot::PID::setSetpoint ( double  setpoint)

Set the controller's setpoint

Parameters
setpointNew setpoint for the controller

The documentation for this class was generated from the following file: