00001 #ifndef _BAYES_FILTER_INDIRECT
00002 #define _BAYES_FILTER_INDIRECT
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 namespace Bayesian_filter
00021 {
00022
00023
00024 template <typename Error_base>
00025 class Indirect_state_filter : public State_filter {
00026
00027
00028
00029
00030 public:
00031 Indirect_state_filter (Error_base& error_filter)
00032 : State_filter(error_filter.x.size()), direct(error_filter)
00033 {
00034 direct.x.clear();
00035 }
00036
00037 template <typename P_model>
00038 void predict (P_model& f)
00039 {
00040 x = f.f(x);
00041 direct.predict(f);
00042 };
00043
00044 template <typename O_model>
00045 void observe (O_model& h, const FM::Vec& z)
00046 {
00047
00048 FM::Vec z_error(z.size());
00049 z_error = h.h(x);
00050 z_error -= z;
00051 direct.observe (h, z_error);
00052
00053 x -= direct.x;
00054
00055 direct.x.clear();
00056 }
00057
00058 template <typename O_model>
00059 void observe_error (O_model& h, const FM::Vec& z_error)
00060 {
00061 direct.observe (h, z_error);
00062
00063 x -= direct.x;
00064
00065 direct.x.clear();
00066 }
00067
00068 void update ()
00069
00070
00071
00072 {}
00073
00074 private:
00075 Error_base& direct;
00076 };
00077
00078
00079 template <typename Error_base>
00080 class Indirect_kalman_filter : public Kalman_state_filter {
00081
00082
00083
00084
00085 public:
00086 Indirect_kalman_filter (Error_base& error_filter)
00087 : Kalman_state_filter(error_filter.x.size()), direct(error_filter)
00088 {
00089 }
00090
00091 void init ()
00092
00093
00094 {
00095 direct.x.clear();
00096 direct.X = X;
00097 direct.init();
00098 }
00099
00100 template <typename P_model>
00101 void predict (P_model& f)
00102 {
00103 x = f.f(x);
00104 direct.predict(f);
00105 };
00106
00107 template <typename O_model>
00108 void observe (O_model& h, const FM::Vec& z)
00109 {
00110
00111 FM::Vec z_error(z.size());
00112 z_error = h.h(x);
00113 z_error -= z;
00114 direct.observe (h, z_error);
00115 direct.update();
00116
00117 x -= direct.x;
00118
00119 direct.x.clear();
00120 direct.init ();
00121 }
00122
00123 template <typename O_model>
00124 void observe_error (O_model& h, const FM::Vec& z_error)
00125 {
00126 direct.observe (h, z_error);
00127
00128 x -= direct.x;
00129
00130 direct.clear();
00131 }
00132
00133 void update ()
00134
00135
00136
00137 {
00138 direct.update();
00139 X = direct.X;
00140 }
00141
00142 private:
00143 Error_base& direct;
00144 };
00145
00146
00147 }
00148 #endif