- 3.0.2 optimal control module.
ct::optcon::tpl::MpcTimeKeeper< SCALAR > Class Template Reference

Time Keeper Class for Model Predictive Control. More...

#include <MpcTimeKeeper.h>

Public Member Functions

 MpcTimeKeeper ()
 Standard Constructor MpcTimeKeeper. More...
 
 MpcTimeKeeper (std::shared_ptr< MpcTimeHorizon< SCALAR >> timeHorizonStrategy, const mpc_settings &mpc_settings)
 Constructor for Mpc Time Keeper class. More...
 
void initialize ()
 initialize the Mpc Time Keeper (mandatory) More...
 
void computeNewTimings (const SCALAR externalTime, const SCALAR current_T, SCALAR &new_T, SCALAR &t_forw_start, SCALAR &t_forw_stop)
 compute new mpc timings, based on current time horizon and the given time horizon strategy More...
 
const bool finalPointReached () const
 query this in order to find out if the final time horizon has been reached. More...
 
void updateSettings (const mpc_settings &settings)
 update mpc settings More...
 
void startDelayMeasurement (const SCALAR &externalTime)
 start measuring time elapsed during planning / solving the optimal control problem More...
 
void stopDelayMeasurement (const SCALAR &externalTime)
 stop measuring time elapsed during solving the optimal control problem More...
 
SCALAR timeSincePreviousSuccessfulSolve (const SCALAR &externalTime)
 retrieve the time that elapsed since the last successful solve() call to an Optimal Control Problem More...
 
const SCALAR timeSinceFirstSuccessfulSolve (const SCALAR &externalTime)
 retrieve the time that elapsed since the first successful solve() call to an Optimal Control Problem More...
 
const SCALARgetMeasuredDelay () const
 obtain the delay which was measured during solving the optimal control problem More...
 
const SCALARgetMaxMeasuredDelay () const
 get the maximum measured delay (maximum over all cycles) More...
 
const SCALARgetMinMeasuredDelay () const
 get the smallest measured delay (minimum over all cycles) More...
 
const SCALARgetSummedDelay () const
 get the sum of all measured delays More...
 

Detailed Description

template<typename SCALAR = double>
class ct::optcon::tpl::MpcTimeKeeper< SCALAR >

Time Keeper Class for Model Predictive Control.

  • uses an internal clock for bookkeeping of times between MPC clycles
  • this class is based on the assumption that all Optimal Control Problems start at t = 0. All times computed here are expressed as relative times w.r.t. the start of the Optimal Control Problem.
  • calculates the required shifting times between iterations and due to forward integration (initial state prediction)
  • update Time Horizons accordingly

Constructor & Destructor Documentation

◆ MpcTimeKeeper() [1/2]

template<typename SCALAR = double>
ct::optcon::tpl::MpcTimeKeeper< SCALAR >::MpcTimeKeeper ( )
inline

Standard Constructor MpcTimeKeeper.

this constructor should not be used by the normal user. Todo: get rid of MpcTimeKeeper default constructor

◆ MpcTimeKeeper() [2/2]

template<typename SCALAR = double>
ct::optcon::tpl::MpcTimeKeeper< SCALAR >::MpcTimeKeeper ( std::shared_ptr< MpcTimeHorizon< SCALAR >>  timeHorizonStrategy,
const mpc_settings mpc_settings 
)
inline

Constructor for Mpc Time Keeper class.

Parameters
timeHorizonStrategythe user-specified time horizon strategy, for example fixed time horizon
mpc_settingsthe mpc_settings as specified by the user

Member Function Documentation

◆ initialize()

template<typename SCALAR = double>
void ct::optcon::tpl::MpcTimeKeeper< SCALAR >::initialize ( )
inline

initialize the Mpc Time Keeper (mandatory)

resets the TimeKeeper, needs to be called whenever MPC starts over from the beginning.

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::prepareIteration(), and ct::optcon::MPC< OPTCON_SOLVER >::resetMpc().

◆ computeNewTimings()

template<typename SCALAR = double>
void ct::optcon::tpl::MpcTimeKeeper< SCALAR >::computeNewTimings ( const SCALAR  externalTime,
const SCALAR  current_T,
SCALAR new_T,
SCALAR t_forw_start,
SCALAR t_forw_stop 
)
inline

compute new mpc timings, based on current time horizon and the given time horizon strategy

Parameters
externalTimethe external timing, optional.
current_Tthe currently active problem time horizon
new_Tthe new, updated problem time horizon, which gets computed by the time horizon strategy
t_forw_starttime where to start the forward propagation of the state measurement based on delays
t_forw_stoptime where to stop the forward propagation of the state measurement based on delays

estimate the delay from planning, etc.

check for compliance of t_forward_stop and t_forward_start with time horizon of the current controller

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::prepareIteration().

◆ finalPointReached()

template<typename SCALAR = double>
const bool ct::optcon::tpl::MpcTimeKeeper< SCALAR >::finalPointReached ( ) const
inline

query this in order to find out if the final time horizon has been reached.

May be used to trigger corresponding events, such as stopping the control loop.

Returns
bool, true if final time horizon has been reached

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::timeHorizonReached().

◆ updateSettings()

template<typename SCALAR = double>
void ct::optcon::tpl::MpcTimeKeeper< SCALAR >::updateSettings ( const mpc_settings settings)
inline

update mpc settings

Parameters
settingsthe new settings to be handed over

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::updateSettings().

◆ startDelayMeasurement()

template<typename SCALAR = double>
void ct::optcon::tpl::MpcTimeKeeper< SCALAR >::startDelayMeasurement ( const SCALAR externalTime)
inline

start measuring time elapsed during planning / solving the optimal control problem

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::finishIteration().

◆ stopDelayMeasurement()

template<typename SCALAR = double>
void ct::optcon::tpl::MpcTimeKeeper< SCALAR >::stopDelayMeasurement ( const SCALAR externalTime)
inline

stop measuring time elapsed during solving the optimal control problem

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::finishIteration().

◆ timeSincePreviousSuccessfulSolve()

template<typename SCALAR = double>
SCALAR ct::optcon::tpl::MpcTimeKeeper< SCALAR >::timeSincePreviousSuccessfulSolve ( const SCALAR externalTime)
inline

retrieve the time that elapsed since the last successful solve() call to an Optimal Control Problem

the returned time can be used to synchronize the calls to optimal control problems

Returns
time elapsed

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::finishIteration().

◆ timeSinceFirstSuccessfulSolve()

template<typename SCALAR = double>
const SCALAR ct::optcon::tpl::MpcTimeKeeper< SCALAR >::timeSinceFirstSuccessfulSolve ( const SCALAR externalTime)
inline

retrieve the time that elapsed since the first successful solve() call to an Optimal Control Problem

the returned time can be used externally, for example to update cost functions

Returns
time elapsed

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::timeSinceFirstSuccessfulSolve().

◆ getMeasuredDelay()

template<typename SCALAR = double>
const SCALAR& ct::optcon::tpl::MpcTimeKeeper< SCALAR >::getMeasuredDelay ( ) const
inline

obtain the delay which was measured during solving the optimal control problem

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::finishIteration().

◆ getMaxMeasuredDelay()

template<typename SCALAR = double>
const SCALAR& ct::optcon::tpl::MpcTimeKeeper< SCALAR >::getMaxMeasuredDelay ( ) const
inline

get the maximum measured delay (maximum over all cycles)

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::printMpcSummary().

◆ getMinMeasuredDelay()

template<typename SCALAR = double>
const SCALAR& ct::optcon::tpl::MpcTimeKeeper< SCALAR >::getMinMeasuredDelay ( ) const
inline

get the smallest measured delay (minimum over all cycles)

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::printMpcSummary().

◆ getSummedDelay()

template<typename SCALAR = double>
const SCALAR& ct::optcon::tpl::MpcTimeKeeper< SCALAR >::getSummedDelay ( ) const
inline

get the sum of all measured delays

Referenced by ct::optcon::MPC< OPTCON_SOLVER >::printMpcSummary().


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