NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgPIDController Class Reference

#include <tgPIDController.h>

Inheritance diagram for tgPIDController:
Collaboration diagram for tgPIDController:

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
 
tgControllablem_controllable
 

Detailed Description

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.

Constructor & Destructor Documentation

tgPIDController::tgPIDController ( tgControllable controllable,
tgPIDController::Config  config 
)

The only constructor.

Parameters
[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.

tgPIDController::~tgPIDController ( )
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.

Member Function Documentation

void tgPIDController::control ( double  dt)
virtual

Calls the main PID loop. Updates m_prevError and m_intError and calls setControlInput on m_controllable

Parameters
[in]dt- the timestep. Must be positive.
Todo:
determine whether this should be public

Integrate using trapezoid rule to reduce error in integration over rectangle

Reimplemented from tgBasicController.

Definition at line 80 of file tgPIDController.cpp.

Here is the call graph for this function:

void tgPIDController::control ( double  dt,
double  setPoint,
double  sensorData 
)
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)

Parameters
[in]dt- the timestep. Must be positive.
[in]setPoint- the setpoint to be used at this step.
[in]thevalue with which the setpoint will be compared

Reimplemented from tgBasicController.

Definition at line 100 of file tgPIDController.cpp.

const tgControllable* const tgBasicController::getControllable ( ) const
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.

void tgBasicController::setNewSetPoint ( double  newSetPoint)
virtualinherited

Updates m_setPoint to newSetpoint

Parameters
[in]newSetPoint,thenext desired setpoint for the controllable

Definition at line 72 of file tgBasicController.cpp.

void tgPIDController::setSensorData ( double  sensorData)
virtual

Need a higher level class to do this which knows more about the controllable for now

Todo:
upgrade once the messaging protocol is in place
Todo:
  • are there any sanity checks we can enforce here?

Definition at line 112 of file tgPIDController.cpp.

Here is the caller graph for this function:

Member Data Documentation

tgControllable* tgBasicController::m_controllable
protectedinherited

The system being controlled. We don't own this

Definition at line 97 of file tgBasicController.h.

double tgBasicController::m_setPoint
protectedinherited

The control setpoint. Updated via control or setNewSetPoint

Definition at line 92 of file tgBasicController.h.


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