WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PIDController Class Reference

#include <PIDController.h>

Inheritance diagram for PIDController:
Controller

Public Member Functions

 PIDController (float p, float i, float d, PIDSource *source, PIDOutput *output, float period=0.05)
 
 PIDController (float p, float i, float d, float f, PIDSource *source, PIDOutput *output, float period=0.05)
 
virtual ~PIDController ()
 
virtual float Get ()
 
virtual void SetContinuous (bool continuous=true)
 
virtual void SetInputRange (float minimumInput, float maximumInput)
 
virtual void SetOutputRange (float mimimumOutput, float maximumOutput)
 
virtual void SetPID (float p, float i, float d)
 
virtual void SetPID (float p, float i, float d, float f)
 
virtual float GetP ()
 
virtual float GetI ()
 
virtual float GetD ()
 
virtual float GetF ()
 
virtual void SetSetpoint (float setpoint)
 
virtual float GetSetpoint ()
 
virtual float GetError ()
 
virtual void SetTolerance (float percent)
 
virtual void SetAbsoluteTolerance (float absValue)
 
virtual void SetPercentTolerance (float percentValue)
 
virtual bool OnTarget ()
 
virtual void Enable ()
 
virtual void Disable ()
 
virtual bool IsEnabled ()
 
virtual void Reset ()
 
virtual void InitTable (ITable *table)
 

Protected Member Functions

void Calculate ()
 
 DISALLOW_COPY_AND_ASSIGN (PIDController)
 

Protected Attributes

ITable * m_table
 

Detailed Description

Class implements a PID Control Loop.

Creates a separate thread which reads the given PIDSource and takes care of the integral calculations, as well as writing the given PIDOutput

Constructor & Destructor Documentation

PIDController::PIDController ( float  Kp,
float  Ki,
float  Kd,
PIDSource source,
PIDOutput output,
float  period = 0.05 
)

Allocate a PID object with the given constants for P, I, D

Parameters
Kpthe proportional coefficient
Kithe integral coefficient
Kdthe derivative coefficient
sourceThe PIDSource object that is used to get values
outputThe PIDOutput object that is set to the output value
periodthe loop time for doing calculations. This particularly effects calculations of the integral and differental terms. The default is 50ms.
PIDController::PIDController ( float  Kp,
float  Ki,
float  Kd,
float  Kf,
PIDSource source,
PIDOutput output,
float  period = 0.05 
)

Allocate a PID object with the given constants for P, I, D

Parameters
Kpthe proportional coefficient
Kithe integral coefficient
Kdthe derivative coefficient
sourceThe PIDSource object that is used to get values
outputThe PIDOutput object that is set to the output value
periodthe loop time for doing calculations. This particularly effects calculations of the integral and differental terms. The default is 50ms.
PIDController::~PIDController ( )
virtual

Free the PID object

Member Function Documentation

void PIDController::Calculate ( )
protected

Read the input, calculate the output accordingly, and write to the output. This should only be called by the Notifier indirectly through CallCalculate and is created during initialization.

void PIDController::Disable ( )
virtual

Stop running the PIDController, this sets the output to zero before stopping.

Implements Controller.

void PIDController::Enable ( )
virtual

Begin running the PIDController

Implements Controller.

float PIDController::Get ( )
virtual

Return the current PID result This is always centered on zero and constrained the the max and min outs

Returns
the latest calculated output
float PIDController::GetD ( )
virtual

Get the Differential coefficient

Returns
differential coefficient
float PIDController::GetError ( )
virtual

Retruns the current difference of the input from the setpoint

Returns
the current error
float PIDController::GetF ( )
virtual

Get the Feed forward coefficient

Returns
Feed forward coefficient
float PIDController::GetI ( )
virtual

Get the Integral coefficient

Returns
integral coefficient
float PIDController::GetP ( )
virtual

Get the Proportional coefficient

Returns
proportional coefficient
float PIDController::GetSetpoint ( )
virtual

Returns the current setpoint of the PIDController

Returns
the current setpoint
bool PIDController::IsEnabled ( )
virtual

Return true if PIDController is enabled.

void PIDController::Reset ( )
virtual

Reset the previous error,, the integral term, and disable the controller.

void PIDController::SetContinuous ( bool  continuous = true)
virtual

Set the PID controller to consider the input to be continuous, Rather then using the max and min in as constraints, it considers them to be the same point and automatically calculates the shortest route to the setpoint.

Parameters
continuousSet to true turns on continuous, false turns off continuous
void PIDController::SetInputRange ( float  minimumInput,
float  maximumInput 
)
virtual

Sets the maximum and minimum values expected from the input.

Parameters
minimumInputthe minimum value expected from the input
maximumInputthe maximum value expected from the output
void PIDController::SetOutputRange ( float  minimumOutput,
float  maximumOutput 
)
virtual

Sets the minimum and maximum values to write.

Parameters
minimumOutputthe minimum value to write to the output
maximumOutputthe maximum value to write to the output
void PIDController::SetPID ( float  p,
float  i,
float  d 
)
virtual

Set the PID Controller gain parameters. Set the proportional, integral, and differential coefficients.

Parameters
pProportional coefficient
iIntegral coefficient
dDifferential coefficient
void PIDController::SetPID ( float  p,
float  i,
float  d,
float  f 
)
virtual

Set the PID Controller gain parameters. Set the proportional, integral, and differential coefficients.

Parameters
pProportional coefficient
iIntegral coefficient
dDifferential coefficient
fFeed forward coefficient
void PIDController::SetSetpoint ( float  setpoint)
virtual

Set the setpoint for the PIDController

Parameters
setpointthe desired setpoint

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