TRC Library for FRC (2011) 2011
TRC Library Code Project

TrcPIDCtrl Class Reference

#include <TrcPIDCtrl.h>

List of all members.

Public Member Functions

 TrcPIDCtrl (__in float Kp, __in float Ki, __in float Kd, __in PIDInput *pidInput, __in bool fAbsSetPt=false, __in bool fInverse=false)
 ~TrcPIDCtrl (void)
void Reset (void)
float GetKp (void)
float GetKi (void)
float GetKd (void)
void SetPID (__in float Kp, __in float Ki, __in float Kd)
float GetError (void)
float GetTarget (void)
void SetTarget (__in float setpt, __in float tolerance)
bool OnTarget (void)
void SetInputRange (__in float minInput, __in float maxInput)
void SetOutputRange (__in float minOutput, __in float maxOutput)
float CalcPIDOutput (void)

Detailed Description

This class defines and implements the TrcPIDCtrl object. This object replaces the PIDController object from the WPI library. The PIDController object in the WPI library is not flexible enough because it dealt with PID input and PID output directly. In contrast, the TrcPIDCtrl object is a simple primitive that calculates the PID output according to the given PID input. So it is agnostic to the kind of input, output or even how the calculated output is used. This is especially important because the TrcPIDDrive object is going to combine two PID controllers to calculate the drive output. One PID controller is for driving straight distance and the other is for turning. In addition, the WPI PIDController is creating a periodic loop per controller. In the TRC library, we will do periodic loop at a higher level in the TrcPIDDrive object instead. oller does not.

Definition at line 64 of file TrcPIDCtrl.h.

Constructor & Destructor Documentation

TrcPIDCtrl::TrcPIDCtrl ( __in float  Kp,
__in float  Ki,
__in float  Kd,
__in PIDInput pidInput,
__in bool  fAbsSetPt = false,
__in bool  fInverse = false 
) [inline]

Constructor: Create an instance of the TrcPIDCtrl object.

KpSpecifies the proportional coefficient.
KiSpecifies the integral coefficient.
KdSpecifies the derivative coefficient.
pidInputSpecifies the PID input object.
fAbsSetPtIf true, the setpoint specified is absolute. Otherwise, the setpoint is relative to the current input value.
fInverseIf true, it reverses the polarity of the error.

Definition at line 96 of file TrcPIDCtrl.h.

TrcPIDCtrl::~TrcPIDCtrl ( void  ) [inline]

Destructor: Destroy an instance of the TrcPIDCtrl object.

Definition at line 139 of file TrcPIDCtrl.h.

Member Function Documentation

float TrcPIDCtrl::CalcPIDOutput ( void  ) [inline]

This function returns the calculated PID output according to the input value from the input source.

Returns the PID control source input value.

Definition at line 391 of file TrcPIDCtrl.h.

float TrcPIDCtrl::GetError ( void  ) [inline]

This function gets the last error.

the last error.

Definition at line 245 of file TrcPIDCtrl.h.

float TrcPIDCtrl::GetKd ( void  ) [inline]

This function gets the differential constant.

Differential coefficient constant.

Definition at line 204 of file TrcPIDCtrl.h.

float TrcPIDCtrl::GetKi ( void  ) [inline]

This function gets the integral constant.

Integral coefficient constant.

Definition at line 188 of file TrcPIDCtrl.h.

float TrcPIDCtrl::GetKp ( void  ) [inline]

This function gets the proportional constant.

Proportional coefficient constant.

Definition at line 172 of file TrcPIDCtrl.h.

float TrcPIDCtrl::GetTarget ( void  ) [inline]

This function gets the PID controller setpoint.

the current setpoint.

Definition at line 261 of file TrcPIDCtrl.h.

bool TrcPIDCtrl::OnTarget ( void  ) [inline]

This function determines if we are on target by checking if the previous error is within target tolerance.

True if we are on target, false otherwise.

Definition at line 323 of file TrcPIDCtrl.h.

void TrcPIDCtrl::Reset ( void  ) [inline]

This function resets the PID controller.

Definition at line 152 of file TrcPIDCtrl.h.

void TrcPIDCtrl::SetInputRange ( __in float  minInput,
__in float  maxInput 
) [inline]

This function sets the minimum and maximum values expected from the input.

minInputSpecifies the minimum value.
maxInputSpecifies the maximum value.

Definition at line 346 of file TrcPIDCtrl.h.

void TrcPIDCtrl::SetOutputRange ( __in float  minOutput,
__in float  maxOutput 
) [inline]

This function limits the minimum and maximum values of the output.

minOutputSpecifies the minimum value.
maxOutputSpecifies the maximum value.

Definition at line 369 of file TrcPIDCtrl.h.

void TrcPIDCtrl::SetPID ( __in float  Kp,
__in float  Ki,
__in float  Kd 
) [inline]

This function sets the PID controller constants.

KpSpecifies the proportional constant.
KiSpecifies the integral constant.
KdSpecifies the differential constant.

Definition at line 222 of file TrcPIDCtrl.h.

void TrcPIDCtrl::SetTarget ( __in float  setpt,
__in float  tolerance 
) [inline]

This function sets the PID controller setpoint.

setptSpecifies the target setpoint.
toleranceSpecifies the target tolerance.

Definition at line 278 of file TrcPIDCtrl.h.

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Defines