- Timestamp:
- 01/15/09 10:53:54 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pmsm/mpf_test.cpp
r227 r229 15 15 #include <estim/libKF.h> 16 16 #include <estim/libPF.h> 17 #include <estim/ekf_templ.h> 17 18 #include <stat/libFN.h> 18 19 … … 22 23 23 24 using namespace itpp; 24 //!Extended Kalman filter with unknown \c Q25 class EKF_unQ : public EKFCh , public BMcond {26 public:27 //! Default constructor28 EKF_unQ ( RV rx, RV ry,RV ru,RV rQ ) :EKFCh ( rx,ry,ru ),BMcond ( rQ ) {};29 void condition ( const vec &Q0 ) {30 Q.setD ( Q0,0 );31 //from EKF32 preA.set_submatrix ( dimy+dimx,dimy,Q._Ch() );33 };34 };35 36 25 37 26 int main() { … … 59 48 60 49 RV rQ ( "{Q }","4" ); 61 EKF _unQ KFEp ( rx,ry,ru,rQ );50 EKFCh_unQ KFEp ( rx,ry,ru,rQ ); 62 51 KFEp.set_parameters ( &fxu,&hxu,Q,R ); 63 52 KFEp.set_est ( mu0, chmat ( zeros ( 4 ) ) ); … … 65 54 //mgamma_fix evolQ ( rQ,rQ ); 66 55 migamma_fix evolQ ( rQ,rQ ); 67 MPF<EKF _unQ> M ( rx,rQ,evolQ,evolQ,Npart,KFEp );56 MPF<EKFCh_unQ> M ( rx,rQ,evolQ,evolQ,Npart,KFEp ); 68 57 // initialize 69 58 evolQ.set_parameters ( 0.1, Qdiag, 1.0); //sigma = 1/10 mu … … 85 74 mat Dt=zeros ( Ndat,2+2 ); //observation 86 75 mat XtE=zeros ( Ndat, 4 ); 76 mat VarE=zeros ( Ndat, 4 ); 87 77 mat Qtr=zeros ( Ndat, 4 ); 88 78 mat XtM=zeros ( Ndat,4+4 ); //Q + x 79 mat VarM=zeros ( Ndat,4+4 ); //Q + x 89 80 90 81 // SET SIMULATOR … … 129 120 Qtr.set_row ( tK, Qdiag); 130 121 XtE.set_row ( tK,KFEep.mean() ); 122 VarE.set_row ( tK,KFEep.variance() ); 131 123 XtM.set_row ( tK,Mep.mean() ); 124 VarM.set_row ( tK,Mep.variance() ); 132 125 } 133 126 … … 139 132 fou << Name ( "xthE" ) << XtE; 140 133 fou << Name ( "xthM" ) << XtM; 134 fou << Name ( "VarE" ) << VarE; 135 fou << Name ( "VarM" ) << VarM; 141 136 //Exit program: 142 137