NTRT Simulator
v1.1
|
#include <tgPIDController.h>
Classes | |
struct | Config |
Public Member Functions | |
tgPIDController (tgControllable *controllable, tgPIDController::Config config) | |
virtual | ~tgPIDController () |
virtual void | control (double dt) |
virtual void | control (double dt, double setPoint, double sensorData) |
virtual void | setSensorData (double sensorData) |
virtual void | setNewSetPoint (double newSetPoint) |
const tgControllable *const | getControllable () const |
Protected Attributes | |
double | m_setPoint |
tgControllable * | m_controllable |
Applies PID control to its tgControllable. Will work for any controllable for which we can get an approprate sensor input. Depending on the system it may be necessary to invert the output, this is done within the config file upon construction.
Definition at line 41 of file tgPIDController.h.
tgPIDController::tgPIDController | ( | tgControllable * | controllable, |
tgPIDController::Config | config | ||
) |
The only constructor.
[in] | controllable. | The system to be controlled. One to one mapping with PID controller, since history is kept in the controller through the previous error and integral parameters |
[in] | config. | Contains the gains for the PID control and a starting setpoint |
Definition at line 65 of file tgPIDController.cpp.
|
virtual |
This destructor has nothing to do. The parent class will set the pointer for m_controllable to NULL
Definition at line 75 of file tgPIDController.cpp.
|
virtual |
Calls the main PID loop. Updates m_prevError and m_intError and calls setControlInput on m_controllable
[in] | dt | - the timestep. Must be positive. |
Integrate using trapezoid rule to reduce error in integration over rectangle
Reimplemented from tgBasicController.
Definition at line 80 of file tgPIDController.cpp.
|
virtual |
The standard public call for running the PID loop and applying the output to the controlled system Calls setSensorData(sensorData), then sets m_setPoint equal to setpoint and calls control(dt)
[in] | dt | - the timestep. Must be positive. |
[in] | setPoint | - the setpoint to be used at this step. |
[in] | the | value with which the setpoint will be compared |
Reimplemented from tgBasicController.
Definition at line 100 of file tgPIDController.cpp.
|
inlineinherited |
Return a const pointer to a const tgControllable. Current solution to obtaining sensor data (requires casting at a higher level)
Definition at line 82 of file tgBasicController.h.
|
virtualinherited |
Updates m_setPoint to newSetpoint
[in] | newSetPoint,the | next desired setpoint for the controllable |
Definition at line 72 of file tgBasicController.cpp.
|
virtual |
Need a higher level class to do this which knows more about the controllable for now
Definition at line 112 of file tgPIDController.cpp.
|
protectedinherited |
The system being controlled. We don't own this
Definition at line 97 of file tgBasicController.h.
|
protectedinherited |
The control setpoint. Updated via control or setNewSetPoint
Definition at line 92 of file tgBasicController.h.