signals-cpp
Loading...
Searching...
No Matches
Model< DynamicsType > Class Template Reference

Base type for all model simulators. More...

#include <Models.h>

Public Types

using InputSignalType = typename DynamicsType::InputSignalType
 
using StateDotSignalType = typename DynamicsType::StateDotSignalType
 
using StateSignalType = typename DynamicsType::StateSignalType
 
using ParamsType = typename DynamicsType::ParamsType
 

Public Member Functions

 Model ()
 Initialize a model with no parameters.
 
void setParams (const ParamsType &params)
 Initialize the model with any required parameters.
 
bool hasParams ()
 Verify that the model has parameters explicity set by setParams().
 
void reset ()
 Zero out the model state and derivative variables and reset simulation time to zero.
 
double t () const
 Get the current simulation time.
 
template<typename IntegratorType>
bool simulate (const InputSignalType &u, const double &tf, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
 Simulate the system response to an input over a specified time interval.
 
template<typename IntegratorType>
bool simulate (const InputSignalType &u, const double &tf, const double &dt, const bool &insertIntoHistory=false, const bool &calculateXddot=false)
 Simulate the system response to an input over a specified time interval, chunked up into smaller integration increments.
 

Public Attributes

StateSignalType x
 Model state signal.
 
StateDotSignalType xdot
 Time derivative of the model state signal.
 

Detailed Description

template<typename DynamicsType>
class Model< DynamicsType >

Base type for all model simulators.

Provides methods for initialization, reset, and simulation of dynamic models.

Derived types:

Member Typedef Documentation

◆ InputSignalType

template<typename DynamicsType>
using Model< DynamicsType >::InputSignalType = typename DynamicsType::InputSignalType

◆ ParamsType

template<typename DynamicsType>
using Model< DynamicsType >::ParamsType = typename DynamicsType::ParamsType

◆ StateDotSignalType

template<typename DynamicsType>
using Model< DynamicsType >::StateDotSignalType = typename DynamicsType::StateDotSignalType

◆ StateSignalType

template<typename DynamicsType>
using Model< DynamicsType >::StateSignalType = typename DynamicsType::StateSignalType

Constructor & Destructor Documentation

◆ Model()

template<typename DynamicsType>
Model< DynamicsType >::Model ( )
inline

Initialize a model with no parameters.

Member Function Documentation

◆ hasParams()

template<typename DynamicsType>
bool Model< DynamicsType >::hasParams ( )
inline

Verify that the model has parameters explicity set by setParams().

◆ reset()

template<typename DynamicsType>
void Model< DynamicsType >::reset ( )
inline

Zero out the model state and derivative variables and reset simulation time to zero.

◆ setParams()

template<typename DynamicsType>
void Model< DynamicsType >::setParams ( const ParamsType & params)
inline

Initialize the model with any required parameters.

The required parameters are determined by the model / dynamics specialization.

◆ simulate() [1/2]

template<typename DynamicsType>
template<typename IntegratorType>
bool Model< DynamicsType >::simulate ( const InputSignalType & u,
const double & tf,
const bool & insertIntoHistory = false,
const bool & calculateXddot = false )
inline

Simulate the system response to an input over a specified time interval.

Parameters
uThe input signal, which should be defined up to tf.
tfThe time to simulate to. Ideally the delta from the current time is small.
insertIntoHistoryWhether to store the result in state memory.
calculateXddotWhether to use finite differencing to calculate the second time derivative of the state.
Returns
Whether the simulation was successful.

◆ simulate() [2/2]

template<typename DynamicsType>
template<typename IntegratorType>
bool Model< DynamicsType >::simulate ( const InputSignalType & u,
const double & tf,
const double & dt,
const bool & insertIntoHistory = false,
const bool & calculateXddot = false )
inline

Simulate the system response to an input over a specified time interval, chunked up into smaller integration increments.

Parameters
uThe input signal, which should be defined up to tf.
tfThe time to simulate to.
dtTime delta length by which to chunk up the integrations. Ideally this is small.
insertIntoHistoryWhether to store the result in state memory.
calculateXddotWhether to use finite differencing to calculate the second time derivative of the state.
Returns
Whether the simulation was successful.

◆ t()

template<typename DynamicsType>
double Model< DynamicsType >::t ( ) const
inline

Get the current simulation time.

Member Data Documentation

◆ x

template<typename DynamicsType>
StateSignalType Model< DynamicsType >::x

Model state signal.

◆ xdot

template<typename DynamicsType>
StateDotSignalType Model< DynamicsType >::xdot

Time derivative of the model state signal.


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