WPILib 2012
WPILibRoboticsLibraryforFRC
Public Member Functions
PIDController Class Reference

#include <PIDController.h>

Inheritance diagram for PIDController:
SendablePIDController

List of all members.

Public Member Functions

 PIDController (float p, float i, float d, 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 float GetP ()
virtual float GetI ()
virtual float GetD ()
virtual void SetSetpoint (float setpoint)
virtual float GetSetpoint ()
virtual float GetError ()
virtual void SetTolerance (float percent)
virtual bool OnTarget ()
virtual void Enable ()
virtual void Disable ()
virtual bool IsEnabled ()
virtual void Reset ()

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 ( ) [virtual]

Free the PID object


Member Function Documentation

void PIDController::Disable ( ) [virtual]

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

Reimplemented in SendablePIDController.

void PIDController::Enable ( ) [virtual]

Begin running the PIDController

Reimplemented in SendablePIDController.

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::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::SetSetpoint ( float  setpoint) [virtual]

Set the setpoint for the PIDController

Parameters:
setpointthe desired setpoint

Reimplemented in SendablePIDController.


The documentation for this class was generated from the following files:
 All Classes Functions Variables