BotNavSim  v0.4.3
Mobile Robot Simulation
Pid Class Reference

Pid encapsulates PID control for floating point variables. More...

Public Member Functions

float output (float target, float actual)
 Pid control from actual to target. Uses Time.fixedDeltaTime for delta time values More...
 
void Reset ()
 Set error, previous_error, integral and derivative to 0. More...
 
void CopySettings (Pid pid)
 Copies the gain values from param to this instance More...
 

Public Attributes

float kp
 

Properties

float error [get, private set]
 
float previous_error [get, private set]
 
float integral [get, private set]
 
float derivative [get, private set]
 

Private Attributes

float ki
 
float kd
 

Detailed Description

Pid encapsulates PID control for floating point variables.

Definition at line 8 of file Pid.cs.

Member Function Documentation

void Pid.CopySettings ( Pid  pid)

Copies the gain values from param to this instance

Parameters
pidPid controller to copy gain values from.

Definition at line 43 of file Pid.cs.

43  {
44  kp = pid.kp;
45  ki = pid.ki;
46  kd = pid.kd;
47  }
float kd
Definition: Pid.cs:10
float ki
Definition: Pid.cs:10
float kp
Definition: Pid.cs:10
float Pid.output ( float  target,
float  actual 
)

Pid control from actual to target. Uses Time.fixedDeltaTime for delta time values

Parameters
targetTarget value.
actualActual value.

Definition at line 21 of file Pid.cs.

21  {
22  error = target - actual;
23  integral += error * Time.fixedDeltaTime;
24  derivative = (error - previous_error) / Time.fixedDeltaTime;
26  return (kp*error) + (ki*integral) + (kd*derivative);
27  }
float error
Definition: Pid.cs:11
float kd
Definition: Pid.cs:10
float integral
Definition: Pid.cs:13
float derivative
Definition: Pid.cs:14
float previous_error
Definition: Pid.cs:12
float ki
Definition: Pid.cs:10
float kp
Definition: Pid.cs:10

Here is the caller graph for this function:

void Pid.Reset ( )

Set error, previous_error, integral and derivative to 0.

Definition at line 32 of file Pid.cs.

32  {
33  error = 0f;
34  previous_error = 0f;
35  integral = 0f;
36  derivative = 0f;
37  }
float error
Definition: Pid.cs:11
float integral
Definition: Pid.cs:13
float derivative
Definition: Pid.cs:14
float previous_error
Definition: Pid.cs:12

Here is the caller graph for this function:

Member Data Documentation

float Pid.kd
private

Definition at line 10 of file Pid.cs.

float Pid.ki
private

Definition at line 10 of file Pid.cs.

float Pid.kp

Definition at line 10 of file Pid.cs.

Property Documentation

float Pid.derivative
getprivate set

Definition at line 14 of file Pid.cs.

float Pid.error
getprivate set

Definition at line 11 of file Pid.cs.

float Pid.integral
getprivate set

Definition at line 13 of file Pid.cs.

float Pid.previous_error
getprivate set

Definition at line 12 of file Pid.cs.


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