00001
00002
00003 #ifndef FILTER_OBSERVE_MODEL_HPP
00004 #define FILTER_OBSERVE_MODEL_HPP
00005
00006 #include "kernel/jafarException.hpp"
00007
00008 #include "jmath/jblas.hpp"
00009
00010 namespace jafar {
00011 namespace filter {
00012
00017 class BaseObserveModel {
00018
00019 public:
00020
00021 BaseObserveModel(std::size_t sizeObs_, std::size_t sizeState_);
00022 BaseObserveModel(std::size_t sizeObs_, std::size_t sizeState_, std::size_t sizeInnovation_, std::size_t sizePrediction_);
00023
00024 virtual ~BaseObserveModel();
00025
00026 inline std::size_t sizeObs() const {return p_sizeObs;}
00027 inline std::size_t sizeState() const {return p_sizeState;}
00028 inline std::size_t sizeInnovation() const {return p_sizeInnovation;}
00029 inline std::size_t sizePrediction() const {return p_sizePrediction;}
00030 inline bool isCorrelated() const {return p_isCorrelated;}
00031
00032 virtual jblas::sym_mat const& getR() const {return R;}
00033
00035 void setCorrelatedR(jblas::sym_mat const& R_);
00036
00038 void setUncorrelatedR(jblas::vec const& R_);
00039
00040
00041
00042
00043
00044
00045 protected:
00046 std::size_t p_sizeObs;
00047 std::size_t p_sizeState;
00048 std::size_t p_sizeInnovation;
00049 std::size_t p_sizePrediction;
00050
00051 bool p_isCorrelated;
00052
00054 jblas::sym_mat R;
00055
00057 mutable jblas::vec z;
00058
00059 };
00060
00061
00062
00067 class LinearObserveModel : public BaseObserveModel {
00068
00069 public:
00070
00072 jblas::mat H;
00073
00074 LinearObserveModel(std::size_t sizeObs_, std::size_t sizeState_);
00075 LinearObserveModel(jblas::mat const& H_);
00076
00077 ~LinearObserveModel();
00078
00079 virtual jblas::vec const& predictObservation(const jblas::vec& x_) const;
00080
00081
00082
00083
00084
00085
00086 };
00087
00088
00089
00095 class JacobianObserveModel : public BaseObserveModel {
00096
00097 public:
00098
00104 jblas::mat Jobs;
00105
00106 JacobianObserveModel(std::size_t sizeObs_, std::size_t sizeState_);
00107
00108 virtual ~JacobianObserveModel();
00109
00122 virtual jblas::vec const& predictObservation(jblas::vec const & x_) = 0;
00123
00126 virtual jblas::vec const& computeInnovation(jblas::vec const& z_,
00127 jblas::vec const& zPred_)
00128 {
00129 JFR_PRECOND(z_.size() == sizeObs(),
00130 "JacobianObserveModel::computeInnovation: size of z_ does not match");
00131 JFR_PRECOND(zPred_.size() == sizeObs(),
00132 "JacobianObserveModel::computeInnovation: size of zPred_ does not match");
00133 z = z_ - zPred_;
00134 return z;
00135 }
00136
00138 virtual void predictObservationJac(const jblas::vec& x_) = 0;
00139
00140
00141 };
00142
00143
00144
00145
00146
00154 class JacobianImplicitObserveModel : public BaseObserveModel {
00155
00156 public:
00157
00163 jblas::mat Jobs_X;
00164
00170 jblas::mat Jobs_Z;
00171
00172
00182 JacobianImplicitObserveModel(std::size_t sizeObs_,
00183 std::size_t sizeState_,
00184 std::size_t functionCompenent);
00185
00186 virtual ~JacobianImplicitObserveModel();
00187
00188
00189
00190 virtual jblas::vec const& computeInnovation(const jblas::vec& x_,
00191 const jblas::vec& z_) = 0;
00192
00196 virtual void computeJacobian(const jblas::vec& x_,
00197 const jblas::vec& z_) = 0;
00198
00199 };
00200
00201
00202
00203
00204
00205
00213 class BlockObserveModel : public BaseObserveModel {
00214
00215 protected:
00216
00217 std::size_t _sizeState1;
00218 std::size_t _sizeState2;
00219
00220 public:
00221
00226 jblas::mat Jobs1;
00227
00232 jblas::mat Jobs2;
00233
00234 BlockObserveModel(std::size_t sizeObs_,
00235 std::size_t sizeState1_, std::size_t sizeState2_);
00236 BlockObserveModel(std::size_t sizeObs_,
00237 std::size_t sizeState1_, std::size_t sizeState2_, std::size_t sizeInnovation_, std::size_t sizePrediction_);
00238
00239 virtual ~BlockObserveModel();
00240
00241 inline std::size_t sizeState1() const {return _sizeState1;};
00242 inline std::size_t sizeState2() const {return _sizeState2;};
00243
00244
00259 virtual jblas::vec const& predictObservation(const jblas::vec_range& x1_,
00260 const jblas::vec_range& x2_) = 0;
00261
00270 virtual jblas::vec const& computeInnovation(jblas::vec const& y_,
00271 jblas::vec const& zPred_)
00272 {
00273 JFR_PRECOND(y_.size() == sizeObs(), "BlockObserveModel::computeInnovation: size of z_ does not match");
00274 JFR_PRECOND(zPred_.size() == sizeObs(), "BlockObserveModel::computeInnovation: size of zPred_ does not match");
00275 z = y_ - zPred_;
00276 return z;
00277 }
00278
00279 virtual void predictObservationJac(const jblas::vec_range& x1_,
00280 const jblas::vec_range& x2_) = 0;
00281
00282 };
00283
00284 }
00285 }
00286
00287 #endif // FILTER_OBSERVE_MODEL_HPP