KalmanFilter
Public Member Functions | List of all members
discreteModel< T > Class Template Referenceabstract

#include <model.h>

Inheritance diagram for discreteModel< T >:
Inheritance graph
[legend]
Collaboration diagram for discreteModel< T >:
Collaboration graph
[legend]

Public Member Functions

virtual T function (const T &val, const int index) const =0
 

Detailed Description

template<typename T>
class discreteModel< T >

Abstract discreteModel inherits from model<int> and thus specifies that time is 'discrete'. Class only declares single pure virtual method 'function' that describes an incremental function where the current state at time k that is T_k is given by function(T_{k-1},k-1). T is the data type whether double, Eigen or custom implemented.

Example using double

#include <iostream>
#include "../../include/model.h"
int main(){
//class will model an object travelling at constant speed of 0.1 per time unit
class discreteSimpleExample: public discreteModel<double>{
//implementing the pure virtual function
public:
double function(const double & val, const int time) const override{
return val + 0.1;
}
};
discreteSimpleExample dse;//actual instance of class
double timeEvaluatedAt = 10;
double valueAtTime = 1;
std::cout<<dse.function(valueAtTime,timeEvaluatedAt)<<std::endl;
/* produces the output:
* 1.1
*/
};

Example using Eigen

#include <Eigen/Dense>
#include <iostream>
#include "../../include/model.h"
int main(){
//using the Eigen library to implement the exact same class (conceptually) as above
class discreteSimpleExampleEigen: public discreteModel<Eigen::VectorXd>{
private:
Eigen::VectorXd velocity;
public:
//can add constructor to make your model more adjustable and reusable
discreteSimpleExampleEigen(double vel){
Eigen::VectorXd tmp(1);
tmp<<vel;
velocity = tmp;
}
Eigen::VectorXd function(const Eigen::VectorXd & val, const int time) const override{
return val+velocity;
}
};
double velocity = 0.1;
discreteSimpleExampleEigen dse2(velocity);
int timeEvaluatedAt = 10;
double valueAtTime = 1;
Eigen::VectorXd tmp(1); tmp<<valueAtTime;
std::cout<<dse2.function(tmp,timeEvaluatedAt)<<std::endl;
/* produces the output:
* 1.1
*/
};

Member Function Documentation

◆ function()

template<typename T>
virtual T discreteModel< T >::function ( const T &  val,
const int  index 
) const
pure virtual

Pure virtual function. User is responsible for implementing this method in inherited class. The function returns rhs (right hand side) where rhs = T{k} = function(T_{k-1},k-1) where rhs is the next model state after state being T_{k-1} at time k-1.

User is also responsible for specifying data type T.


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