Base class for interfacing online feedback laws to be used within a Controller. More...
#include <control_law.hpp>
Base class for interfacing online feedback laws to be used within a Controller.
The class ControlLaw serves as a base class for interfacing online control laws to be used within a Controller. Most prominently, the control law can be a RealTimeAlgorithm solving dynamic optimization problems. But also classical feedback laws like LQR or PID controller or feedforward laws can be interfaced.
After initialization, the ControlLaw is evaluated with a given fixed sampling time by calling the step-routines. Additionally, the steps can be divided into a preparation step and a feedback step that actually computes the feedback. This feature has mainly been added to deal with RealTimeAlgorithm can make use of this division in order to reduce the feedback delay.
Definition at line 64 of file control_law.hpp.
Default constructor.
Definition at line 45 of file control_law.cpp.
ControlLaw::ControlLaw | ( | double | _samplingTime | ) |
Constructor which takes the sampling time.
[in] | _samplingTime | Sampling time. |
Definition at line 50 of file control_law.cpp.
ControlLaw::ControlLaw | ( | const ControlLaw & | rhs | ) |
Copy constructor (deep copy).
[in] | rhs | Right-hand side object. |
Definition at line 56 of file control_law.cpp.
ControlLaw::~ControlLaw | ( | ) | [virtual] |
Destructor.
Definition at line 63 of file control_law.cpp.
virtual ControlLaw* ControlLaw::clone | ( | ) | const [pure virtual] |
Clone constructor (deep copy).
Implemented in PIDcontroller, FeedforwardLaw, LinearStateFeedback, and RealTimeAlgorithm.
returnValue ControlLaw::feedbackStep | ( | double | currentTime, |
const DVector & | _x, | ||
const DVector & | _p = emptyConstVector , |
||
const VariablesGrid & | _yRef = emptyConstVariablesGrid |
||
) | [virtual] |
Performs next feedback step of the control law based on given inputs.
[in] | currentTime | Current time. |
[in] | _x | Most recent value for differential states. |
[in] | _p | Most recent value for parameters. |
[in] | _yRef | Current piece of reference trajectory (if not specified during previous preparationStep). |
Definition at line 119 of file control_law.cpp.
double ControlLaw::getLengthControlHorizon | ( | ) | const [virtual] |
Returns length of the control horizon (for the case a predictive control law is used).
Reimplemented in RealTimeAlgorithm.
Definition at line 190 of file control_law.cpp.
double ControlLaw::getLengthPredictionHorizon | ( | ) | const [virtual] |
Returns length of the prediction horizon (for the case a predictive control law is used).
Reimplemented in RealTimeAlgorithm.
Definition at line 184 of file control_law.cpp.
uint ControlLaw::getNP | ( | ) | const [virtual] |
Returns number of parameters.
Reimplemented in RealTimeAlgorithm, PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
Definition at line 166 of file control_law.cpp.
uint ControlLaw::getNU | ( | ) | const [virtual] |
Returns number of controls.
Reimplemented in RealTimeAlgorithm, PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
Definition at line 160 of file control_law.cpp.
uint ControlLaw::getNW | ( | ) | const [virtual] |
Returns number of (estimated) disturbances.
Reimplemented in RealTimeAlgorithm, PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
Definition at line 172 of file control_law.cpp.
uint ControlLaw::getNX | ( | ) | const [virtual] |
Returns number of (estimated) differential states.
Reimplemented in RealTimeAlgorithm, PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
Definition at line 148 of file control_law.cpp.
uint ControlLaw::getNXA | ( | ) | const [virtual] |
Returns number of (estimated) algebraic states.
Reimplemented in RealTimeAlgorithm, PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
Definition at line 154 of file control_law.cpp.
uint ControlLaw::getNY | ( | ) | const [virtual] |
Returns number of process outputs.
Reimplemented in RealTimeAlgorithm, PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
Definition at line 178 of file control_law.cpp.
returnValue ControlLaw::getP | ( | DVector & | _p | ) | const [inline] |
Returns parameter signal as determined by the control law.
[out] | _p | Parameter signal as determined by the control law. |
returnValue ControlLaw::getU | ( | DVector & | _u | ) | const [inline] |
Returns control signal as determined by the control law.
[out] | _u | Control signal as determined by the control law. |
virtual returnValue ControlLaw::init | ( | double | startTime = 0.0 , |
const DVector & | _x = emptyConstVector , |
||
const DVector & | _p = emptyConstVector , |
||
const VariablesGrid & | _yRef = emptyConstVariablesGrid |
||
) | [pure virtual] |
Initializes the control law with given start values and performs a number of consistency checks.
[in] | _startTime | Start time. |
[in] | _x | Initial value for differential states. |
[in] | _p | Initial value for parameters. |
[in] | _yRef | Initial value for reference trajectory. |
Implemented in PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
returnValue ControlLaw::initializeAlgebraicStates | ( | const VariablesGrid & | _xa_init | ) | [virtual] |
Initializes algebraic states of the control law.
[in] | _xa_init | Initial value for algebraic states. |
Reimplemented in RealTimeAlgorithm.
Definition at line 83 of file control_law.cpp.
returnValue ControlLaw::initializeAlgebraicStates | ( | const char * | fileName | ) | [virtual] |
Initializes algebraic states of the control law from data file.
[in] | fileName | Name of file containing initial value for algebraic states. |
Reimplemented in RealTimeAlgorithm.
Definition at line 89 of file control_law.cpp.
returnValue ControlLaw::initializeControls | ( | const VariablesGrid & | _u_init | ) | [virtual] |
Initializes controls of the control law.
[in] | _u_init | Initial value for controls. |
Reimplemented in RealTimeAlgorithm.
Definition at line 96 of file control_law.cpp.
returnValue ControlLaw::initializeControls | ( | const char * | fileName | ) | [virtual] |
Initializes controls of the control law from data file.
[in] | fileName | Name of file containing initial value for controls. |
Reimplemented in RealTimeAlgorithm.
Definition at line 102 of file control_law.cpp.
virtual BooleanType ControlLaw::isDynamic | ( | ) | const [pure virtual] |
Returns whether the control law is based on dynamic optimization or a static one.
Implemented in RealTimeAlgorithm, PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
BooleanType ControlLaw::isInRealTimeMode | ( | ) | const [virtual] |
Returns whether the control law is working in real-time mode.
Reimplemented in RealTimeAlgorithm.
Definition at line 200 of file control_law.cpp.
virtual BooleanType ControlLaw::isStatic | ( | ) | const [pure virtual] |
Returns whether the control law is a static one or based on dynamic optimization.
Implemented in RealTimeAlgorithm, PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
ControlLaw & ControlLaw::operator= | ( | const ControlLaw & | rhs | ) |
Assignment operator (deep copy).
[in] | rhs | Right-hand side object. |
Definition at line 68 of file control_law.cpp.
returnValue ControlLaw::preparationStep | ( | double | nextTime = 0.0 , |
const VariablesGrid & | _yRef = emptyConstVariablesGrid |
||
) | [virtual] |
Performs next preparation step of the control law based on given inputs.
[in] | nextTime | Time at next step. |
[in] | _yRef | Piece of reference trajectory for next step (required for hotstarting). |
Reimplemented in RealTimeAlgorithm.
Definition at line 130 of file control_law.cpp.
returnValue ControlLaw::shift | ( | double | timeShift = -1.0 | ) | [virtual] |
Shifts the data for preparating the next real-time step.
Reimplemented in RealTimeAlgorithm.
Definition at line 140 of file control_law.cpp.
virtual returnValue ControlLaw::step | ( | double | currentTime, |
const DVector & | _x, | ||
const DVector & | _p = emptyConstVector , |
||
const VariablesGrid & | _yRef = emptyConstVariablesGrid |
||
) | [pure virtual] |
Performs next step of the control law based on given inputs.
[in] | currentTime | Current time. |
[in] | _x | Most recent value for differential states. |
[in] | _p | Most recent value for parameters. |
[in] | _yRef | Current piece of reference trajectory or piece of reference trajectory for next step (required for hotstarting). |
Implemented in PIDcontroller, FeedforwardLaw, and LinearStateFeedback.
returnValue ControlLaw::step | ( | const DVector & | _x, |
const DVector & | _p = emptyConstVector , |
||
const VariablesGrid & | _yRef = emptyConstVariablesGrid |
||
) | [virtual] |
Performs next step of the control law based on given inputs.
[in] | _x | Most recent value for differential states. |
[in] | _p | Most recent value for parameters. |
[in] | _yRef | Current piece of reference trajectory or piece of reference trajectory for next step (required for hotstarting). |
Definition at line 110 of file control_law.cpp.
DVector ControlLaw::p [protected] |
Time-constant parameter signals as determined by the control law.
Definition at line 342 of file control_law.hpp.
DVector ControlLaw::u [protected] |
First piece of time-varying control signals as determined by the control law.
Definition at line 341 of file control_law.hpp.