YANE-Framework 1.1.0
Public Member Functions | Protected Member Functions | Protected Attributes

yane::NetworkedControl::MPCController Class Reference

Class for simulating the controller in a distributed plant - sensor - controller - actuator setting with simulated network connection.

Inheritance diagram for yane::NetworkedControl::MPCController:
[legend]
Collaboration diagram for yane::NetworkedControl::MPCController:
[legend]

List of all members.

Public Member Functions

void calc (int seq)
 Function to execute the computation of a control sequence.
void implementControl (int seq)
 Function to execute the implementation of a computed control sequence on the process connected via the simulated network connection.
void initialize ()
 Function to initialize the controller.
yane::Model::Modelmodel ()
 Function to return the used class yane::Model::Model object.
int mpcCallCounter ()
 Function to return the number of execute MPC calculations.
std::vector< std::vector
< double > > 
mpcCallStates ()
 Function to return the state vectore used as initial values for each MPC computation executed.
std::vector< double > mpcCallTimes ()
 Function to return the time instances upon which an MPC computation was executed.
 MPCController (yane::Model::Model *model_controller, yane::MPC::ModelShootingData *shootingdata, int horizon, int prediction, yane::MinProg::NLP *minimizer, yane::MPC::OdeManager *odemanager, IOInterfaceLocal *iface, yane::Utils::DebugMaster *debugmaster=0, yane::Utils::StatisticsMaster *statisticsmaster=0, yane::NetworkedControl::T_DISTANCEFUNC distancefunction=0, double statedistanceTolerance=0.0)
 Constructor.
void setMaximalOpenLoopIterations (int maximalOpenLoopIterations)
 Function to set the maximal number of allowed open loop iterations.
void setMaxIter (int seqmax)
 Function to set the maximal number of MPC iterations to be computed.
void setSaveMPCCallData (bool saveMPCCallData)
 Function to set the decision variable to save the computed MPC data.
virtual void start ()
 Function to start the controller.
 ~MPCController ()
 Destructor.

Protected Member Functions

void actuatorInputToController (yane::Utils::DebugMaster *debugmaster, yane::Utils::DebugClient *debugclient, yane::Utils::StatisticsMaster *statisticsmaster)
 Function to handle actuator input data and provide it to be used by the MPC controller.
void computePrediction (double *state, int from_seq, int to_seq, double *timesteps)
 Function to predict the state vector using the internally buffered control sequences.
void controllerOutputToActuator (int seq, yane::Utils::DebugMaster *debugmaster, yane::Utils::DebugClient *debugclient, yane::Utils::StatisticsMaster *statisticsmaster)
 Function to handle the output data of the MPC controller and provide it to be used by the actuator.
void initializeModelHandler ()
 Funtion to initialize the implementation connected components of the networked MPC controller scheme.
void initializeMPCController ()
 Function to initialize the computing connected components of the networked MPC controller scheme.
void initializeMPCControllerInput ()
 Function to initialize the input connected components of the networked MPC controller scheme.
void initializeMPCControllerOutput ()
 Function to initialize the output connected components of the networked MPC controller scheme.
void predictInternalState (double *state, int from_seq, int to_seq)
 Function to compute/predict the state vector to the sampling instant used by the MPC controller.
void predictSensorValues (double *peekedx, int to_seq)
 Function to compute/predict the state vector to the next sampling instant.
void sensorInputToController (int seq, yane::Utils::DebugMaster *debugmaster, yane::Utils::DebugClient *debugclient, yane::Utils::StatisticsMaster *statisticsmaster)
 Function to handle sensor input data and provide it to be used by the MPC controller.
void setActuatorErrorVariables (int lastnonerrorcycle, int currentcycle)
 Function to set the actuator error variables $ \sigma_{\mbox{err}}, \sigma_{\mbox{cor}} $.
void setControllerOutputPacket (int preseq, int seq, int horizon, double *u)
 Function to set the output packet of the MPC controller.
void setNewState (double t, double *state)
 Function to set the internal state vector of the MPC controller.

Protected Attributes

yane::NetworkedControl::T_ACTORPACKET _actuatorpacket
 Controller packet.
yane::NetworkedControl::ControlClipboard_cb
 Pointer of the used control clipboard of class yane::NetworkedControl::ControlClipboard.
yane::NetworkedControl::T_OUTPUTPACKET _controllerpacket
 Sensor input packet.
double * _controllerpacket_data
 Pointer of the output packet to be sent from the controller to the actuator.
int _controllerpacket_horizon
 Length of the control sequence to be sent.
yane::Utils::DebugClient_debugclient
 Pointer of the debug client of class yane::Utils::DebugClient.
yane::Utils::DebugMaster_debugmaster
 Pointer of the class yane::Utils::DebugMaster object used for debugging.
yane::NetworkedControl::T_DISTANCEFUNC _distancefunction
 Acutator packet.
bool _error_received
 Distance function.
bool _has_actorpacket
 Decision variable whether an actuator packet has been received.
int _horizon
 Length of the control sequence to be computed.
double * _inputx
 Pointer of the internal state vector.
bool _inputxchanged
 Decision variable whether the internal state vector has been updated.
double _inputxtime
 Time of the last sensor measurement.
yane::NetworkedControl::IOInterfaceLocal_interface
 Pointer of the used network interface of class yane::NetworkedControl::IOInterfaceLocal.
int _last_sensor_seq
 Sampling instant following the time of the latest sensor measurement.
int _last_seq
 Sampling instant of the latest MPC calculation.
int _maximalOpenLoopIterations
 Maximal number of allowed open loop iterations.
yane::MinProg::NLP_minimizer
 Pointer of the used minimizer of class yane::MinProgl::NLP.
yane::Model::Model_model
 Pointer of the class yane::Model::Model object used for optimization and simulation.
yane::MPC::MPC_mpc
 Pointer of the used controller of class yane::MPC::MPC.
std::vector< std::vector
< double > > 
_mpcCallStates
 Array of the initial state connected to the sampling times upon which the MPC routine was executed.
std::vector< double > _mpcCallTimes
 Array of the sampling times upon which the MPC routine was executed.
yane::MPC::OdeManager_odemanager
 Pointer of the used odemanager of class yane::MPC::OdeManager.
int _prediction
 Length of the prediction between current time and the first time instant the computed control shall be valid.
int _preseq
 Value of $ \sigma_{\mbox{pre}} $, the sampling instant of the last correct control sequence upon which the sent control sequence was computed.
double _samplingTime
 Sampling time.
bool _saveMPCCallData
 Decision variable to save the computed MPC data.
yane::NetworkedControl::T_INPUTPACKET _sensorpacket
 Pointer of the timer of class yane::Utils::RTClock.
double * _sensorvalues
 Pointer of the sensor state vector.
int _seqmax
 Maximal number of MPC iterations to be computed.
yane::MPC::ModelShootingData_shootingdata
 Pointer of the used shooting data of class yane::MPC::ModelShootingData.
int _sigma_cor
 Value of $ \sigma_{\mbox{cor}} $, the sampling instant of the last correct control sequence.
int _sigma_err
 Value of $ \sigma_{\mbox{err}} $, the sampling instant of the latest error within the scheme.
yane::Model::Simulator_simulator_controller
 Pointer of the used simulator of class yane::Model::Simulator.
bool _skipMPC
 Decision variable whether an MPC step is skipped.
yane::Utils::StatisticsClientIntCounter_stat_actuator_received
 Statistics collector for received actuator sequences.
yane::Utils::StatisticsClientIntCounter_stat_mpc_alreadycomputed
 Statistics collector for already computed control sequences.
yane::Utils::StatisticsClientAverage_stat_mpc_calcduration
 Statistics collector for average computing time.
yane::Utils::StatisticsClientIntCounter_stat_mpc_computedseq
 Statistics collector for computed control sequences.
yane::Utils::StatisticsClientIntCounter_stat_mpc_invalidateseq
 Statistics collector for invalidated control sequences.
yane::Utils::StatisticsClientIntCounter_stat_mpc_skipseq
 Statistics collector for skipped control sequences.
yane::Utils::StatisticsClientIntCounter_stat_mpcoutput_sent
 Statistics collector for sent control sequences.
yane::Utils::StatisticsClientIntCounter_stat_sensorinput_sent
 Statistics collector for received sensor input sequences.
double _stateDistanceTolerance
 Maximal tolerance of the state deviation to skip the MPC control computation.
yane::Utils::StatisticsMaster_statisticsmaster
 Pointer of the class yane::Utils::StatisticsMaster object used for producing statistics.
double * _t
 Pointer of the time grid.
double * _trajectory
 Pointer of the state trajectory.
double * _u
 Pointer of the control sequence.
double * _x
 Pointer of the state vector.

Constructor & Destructor Documentation

yane::NetworkedControl::MPCController::MPCController ( yane::Model::Model model_controller,
yane::MPC::ModelShootingData shootingdata,
int  horizon,
int  prediction,
yane::MinProg::NLP minimizer,
yane::MPC::OdeManager odemanager,
IOInterfaceLocal iface,
yane::Utils::DebugMaster debugmaster = 0,
yane::Utils::StatisticsMaster statisticsmaster = 0,
yane::NetworkedControl::T_DISTANCEFUNC  distancefunction = 0,
double  statedistanceTolerance = 0.0 
)

Constructor

Parameters:
model_controllerPointer of the class yane::Model::Model object used for optimization
shootingdataPointer of the yane::Model::ModelShootingData object used for optimization
horizonLength of the horizon
predictionNumber of preceding prediction steps
minimizerPointer of the minimization routine of class yane::MinProg::NLP
odemanagerPointer of the differential equation manager of class yane::MPC::OdeManager
ifacePointer of the input/output interface of class yane::MPC::IOInterface
debugmasterPointer of the debugmanager of class yane::Utils::DebugMaster
statisticsmasterPointer of the statistics manager of class yane::Utils::StatisticsMaster

Member Function Documentation

void yane::NetworkedControl::MPCController::actuatorInputToController ( yane::Utils::DebugMaster debugmaster,
yane::Utils::DebugClient debugclient,
yane::Utils::StatisticsMaster statisticsmaster 
) [protected]

Function to handle actuator input data and provide it to be used by the MPC controller

Parameters:
seqCurrent samling instant
debugmasterPointer of the debug master of class yane::Utils::DebugMaster
debugclientPointer of the debug client of class yane::Utils::DebugClient
statisticsmasterPointer of the statistics master of class yane::Utils::StatisticsMaster
void yane::NetworkedControl::MPCController::calc ( int  seq)

Function to execute the computation of a control sequence

Parameters:
seqNumber of the sampling instant for which the control sequence is computed
void yane::NetworkedControl::MPCController::computePrediction ( double *  state,
int  from_seq,
int  to_seq,
double *  timesteps 
) [protected]

Function to predict the state vector using the internally buffered control sequences

Parameters:
stateState vector
from_seqInitial sampling instant
to_seqTerminal sampling instant
timestepsTime grid
void yane::NetworkedControl::MPCController::controllerOutputToActuator ( int  seq,
yane::Utils::DebugMaster debugmaster,
yane::Utils::DebugClient debugclient,
yane::Utils::StatisticsMaster statisticsmaster 
) [protected]

Function to handle the output data of the MPC controller and provide it to be used by the actuator

Parameters:
seqCurrent samling instant
debugmasterPointer of the debug master of class yane::Utils::DebugMaster
debugclientPointer of the debug client of class yane::Utils::DebugClient
statisticsmasterPointer of the statistics master of class yane::Utils::StatisticsMaster
void yane::NetworkedControl::MPCController::implementControl ( int  seq)

Function to execute the implementation of a computed control sequence on the process connected via the simulated network connection

Parameters:
seqNumber of the sampling instant for which the control sequence is to be applied
yane::Model::Model * yane::NetworkedControl::Controller::model ( ) [inherited]

Function to return the used class yane::Model::Model object

Returns:
Used class yane::Model::Model object
int yane::NetworkedControl::MPCController::mpcCallCounter ( )

Function to return the number of executed MPC calculations. This function requires _saveMPCCallData to be set to true.

std::vector< std::vector< double > > yane::NetworkedControl::MPCController::mpcCallStates ( )

Function to return the state vectore used as initial values for each MPC computation executed. This function requires _saveMPCCallData to be set to true.

std::vector< double > yane::NetworkedControl::MPCController::mpcCallTimes ( )

Function to return the time instances upon which an MPC computation was executed. This function requires _saveMPCCallData to be set to true.

void yane::NetworkedControl::MPCController::predictInternalState ( double *  state,
int  from_seq,
int  to_seq 
) [protected]

Function to compute/predict the state vector to the sampling instant used by the MPC controller

Parameters:
peededxComputed initial value
to_seqSampling instant the initial value is computed for
void yane::NetworkedControl::MPCController::predictSensorValues ( double *  peekedx,
int  to_seq 
) [protected]

Function to compute/predict the state vector measured by sensors to the next sampling instant

Parameters:
peededxComputed initial value
to_seqSampling instant the initial value is computed for
void yane::NetworkedControl::MPCController::sensorInputToController ( int  seq,
yane::Utils::DebugMaster debugmaster,
yane::Utils::DebugClient debugclient,
yane::Utils::StatisticsMaster statisticsmaster 
) [protected]

Function to handle sensor input data and provide it to be used by the MPC controller

Parameters:
seqCurrent samling instant
debugmasterPointer of the debug master of class yane::Utils::DebugMaster
debugclientPointer of the debug client of class yane::Utils::DebugClient
statisticsmasterPointer of the statistics master of class yane::Utils::StatisticsMaster
void yane::NetworkedControl::MPCController::setActuatorErrorVariables ( int  lastnonerrorcycle,
int  currentcycle 
) [protected]

Function to set the actuator error variables $ \sigma_{\mbox{err}}, \sigma_{\mbox{cor}} $ upon receiving an actuator error

Parameters:
lastnoerrorcycleValue of $ \sigma_{\mbox{cor}} $
currentcycleValue of $ \sigma_{\mbox{err}} $
void yane::NetworkedControl::MPCController::setControllerOutputPacket ( int  preseq,
int  seq,
int  horizon,
double *  u 
) [protected]

Function to set the output packet of the MPC controller

Parameters:
preseqValue of $ \sigma_{\mbox{pre}} $, the sampling instant of the last correct control sequence upon which the sent control sequence was computed
seqValue of $ \sigma $, the initial sampling instant for which the control was computed
uControl sequence
void yane::NetworkedControl::MPCController::setMaximalOpenLoopIterations ( int  maximalOpenLoopIterations)

Function to set the maximal number of allowed open loop iterations

Parameters:
maximalOpenLoopIterationsMaximal number of allowed open loop iterations
void yane::NetworkedControl::MPCController::setMaxIter ( int  seqmax)

Function to set the maximal number of MPC iterations to be computed

Parameters:
seqmaxMaximal number of MPC iterations to be computed
void yane::NetworkedControl::MPCController::setNewState ( double  t,
double *  state 
) [protected]

Function to set the internal state vector of the MPC controller

Parameters:
tTime instant of the state vector to be set
stateState vector
void yane::NetworkedControl::MPCController::setSaveMPCCallData ( bool  saveMPCCallData)

Function to set the decision variable to save the computed MPC data

Parameters:
saveMPCCallDataDecision variable to save the computed MPC data

Member Data Documentation

Decision variable whether an error has been received