bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
kf_model_base.h
Go to the documentation of this file.
1#ifndef KF_MODEL_BASE_H
2#define KF_MODEL_BASE_H
3
4#include <map>
5#include <string>
6#include <stdexcept> //for std::invalid_argument
7
8namespace bitrl{
9namespace estimation{
10
11template<typename MatrixType>
13{
14public:
15
16 typedef MatrixType matrix_type;
17
18 virtual void add_matrix(const std::string& name, matrix_type& mat);
19 virtual matrix_type& get_matrix(const std::string& mat);
20 virtual const matrix_type& get_matrix(const std::string& mat)const;
21
22protected:
23
24 std::map<std::string, matrix_type> matrices_;
25
26};
27
28template<typename MatrixType>
29void
30KFModelBase<MatrixType>::add_matrix(const std::string& name, matrix_type& mat){
31 matrices_.insert_or_assign(name, mat);
32}
33
34template<typename MatrixType>
36KFModelBase<MatrixType>::get_matrix(const std::string& name){
37
38 auto itr = matrices_.find(name);
39 if(itr != matrices_.end()){
40 return itr->second;
41 }
42
43 throw std::invalid_argument("Matrix not found");
44}
45
46template<typename MatrixType>
48KFModelBase<MatrixType>::get_matrix(const std::string& name)const{
49
50 auto itr = matrices_.find(name);
51 if(itr != matrices_.end()){
52 return itr->second;
53 }
54
55 throw std::invalid_argument("Matrix not found");
56}
57
58template<typename MatrixType, typename StateType>
59class KFMotionModelBase: public KFModelBase<MatrixType>
60{
61public:
62
63 typedef MatrixType matrix_type;
64 typedef StateType state_type;
65
66 virtual state_type& get_state(){return state_;}
67 virtual const state_type& get_state()const{return state_;}
68 virtual void set_state(const state_type& state){state_ = state;}
69
70protected:
71
72 // the state
74};
75
76
77}
78}
79
80#endif
Definition kf_model_base.h:13
MatrixType matrix_type
Definition kf_model_base.h:16
virtual void add_matrix(const std::string &name, matrix_type &mat)
Definition kf_model_base.h:30
std::map< std::string, matrix_type > matrices_
Definition kf_model_base.h:24
virtual matrix_type & get_matrix(const std::string &mat)
Definition kf_model_base.h:36
virtual const matrix_type & get_matrix(const std::string &mat) const
Definition kf_model_base.h:48
Definition kf_model_base.h:60
MatrixType matrix_type
Definition kf_model_base.h:63
state_type state_
Definition kf_model_base.h:73
StateType state_type
Definition kf_model_base.h:64
virtual const state_type & get_state() const
Definition kf_model_base.h:67
virtual void set_state(const state_type &state)
Definition kf_model_base.h:68
virtual state_type & get_state()
Definition kf_model_base.h:66
Definition bitrl_consts.h:14