Changeset 744 for applications/pmsm/TR2245
- Timestamp:
- 11/28/09 14:38:48 (15 years ago)
- Location:
- applications/pmsm/TR2245
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/TR2245/CMakeLists.txt
r294 r744 2 2 EXEC (unitsteps pmsmsim) 3 3 EXEC (wishart pmsmsim) 4 EXEC (pmsm_wishart pmsmsim)4 #EXEC (pmsm_wishart pmsmsim) -
applications/pmsm/TR2245/unitsteps.cfg
r294 r744 1 1 ndat = 9000; 2 Npart = 100 0;2 Npart = 100; 3 3 4 4 //simulator 5 5 profile = [1,2,4,9,4,2,0,-4,-9,-16,-4,0,0]; 6 6 7 logger = { type="dirfilelog"; dirname="exp/unitstep"; maxlen=100;};7 logger = {class="dirfilelog"; dirname="kst/unitstep"; maxlen=100;}; 8 8 9 Qrw = { type="migamma_ref";10 ref = [1e- 6, 1e-6, 1e-3, 1e-4];9 Qrw = {class="migamma_ref"; 10 ref = [1e-4, 1e-4, 1e-3, 1e-4]; 11 11 l = 0.999; 12 k = 0. 1;12 k = 0.06; 13 13 }; 14 14 // For EKF 15 15 dQ=[1e-5, 1e-5, 1e-4, 1e-5]; 16 dR=[1e- 8, 1e-8];16 dR=[1e-10, 1e-10]; 17 17 -
applications/pmsm/TR2245/unitsteps.cpp
r706 r744 15 15 #include <estim/particles.h> 16 16 #include <estim/ekf_template.h> 17 #include < stat/functions.h>17 #include <base/loggers.h> 18 18 19 19 … … 21 21 #include "simulator.h" 22 22 #include "../sim_profiles.h" 23 #include "user_info.h"24 #include "stat/loggers.h"25 23 26 24 using namespace bdm; … … 41 39 F.lookupValue ( "ndat", Ndat ); 42 40 F.lookupValue ( "Npart",Npart ); 43 pdf*evolQ = UI::build<pdf>( F, "Qrw" );41 shared_ptr<pdf> evolQ = UI::build<pdf>( F, "Qrw" ); 44 42 vec Qdiag; 45 43 vec Rdiag; … … 49 47 // internal model 50 48 51 IMpmsm fxu;49 shared_ptr<IMpmsm> fxu= new IMpmsm; 52 50 // Rs Ls dt Fmag(Ypm) kp p J Bf(Mz) 53 fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );51 fxu->set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 ); 54 52 // observation model 55 OMpmsm hxu;53 shared_ptr<OMpmsm> hxu=new OMpmsm; 56 54 57 55 vec mu0= "0.0 0.0 0.0 0.0"; … … 59 57 chmat R ( Rdiag ); 60 58 EKFCh KFE ; 61 KFE.set_parameters ( &fxu,&hxu,Q,R );62 KFE.set_ est( mu0, chmat ( zeros ( 4 ) ) );59 KFE.set_parameters ( fxu,hxu,Q,R ); 60 KFE.set_statistics ( mu0, chmat ( zeros ( 4 ) ) ); 63 61 KFE.set_rv ( rx ); 62 KFE.validate(); 64 63 65 64 RV rQ ( "{Q }","4" ); 65 RV rU ("{u }","2"); 66 RV rY ("{y }","2"); 66 67 EKFCh_dQ KFEp ; 67 KFEp.set_parameters ( &fxu,&hxu,Q,R ); 68 KFEp.set_est ( mu0, chmat ( zeros ( 4 ) ) ); 68 KFEp.set_parameters ( fxu,hxu,Q,R ); 69 KFEp.set_statistics ( mu0, chmat ( zeros ( 4 ) ) ); 70 KFEp.set_rv(rx); 71 KFEp.set_yrv(rY); 72 KFEp.set_rvc(concat(rU, rQ)); 73 KFEp.validate(); 69 74 70 MPF<EKFCh_dQ> M; 71 M.set_parameters ( evolQ,evolQ,Npart ); 72 // initialize 73 evolQ->condition ( 10*Qdiag ); //Zdenek default 74 M.set_statistics ( evolQ->_e() , &KFEp ); 75 // 75 MPF M; 76 evolQ->set_rv(rQ); 77 M.set_pf ( evolQ,Npart ); 78 M._pf().set_statistics(ones(Npart), euni(zeros(4),2*Qdiag)); 79 M.set_BM(KFEp); 80 M.set_yrv ( rY ); 81 M.set_rvc ( rU ); 82 M.validate(); 76 83 77 M.set_rv ( concat ( rQ,rx ) ); 78 79 dirfilelog *L = UI::build<dirfilelog>( F, "logger" );// ( "exp/mpf_test",100 ); 80 int l_X = L->add ( rx, "xt" ); 81 int l_D = L->add ( concat ( ry,ru ), "" ); 82 int l_Q= L->add ( rQ, "" ); 84 shared_ptr<dirfilelog> L = UI::build<dirfilelog>( F, "logger" );// ( "exp/mpf_test",100 ); 85 int l_X = L->add_vector ( rx, "xt" ); 86 int l_D = L->add_vector ( concat ( ry,ru ), "" ); 87 int l_Q= L->add_vector ( rQ, "" ); 83 88 84 89 KFE.set_options ( "logbounds" ); 85 KFE.log_ add( *L,"KF" );90 KFE.log_register ( *L,"KF" ); 86 91 M.set_options ( "logbounds" ); 87 M.log_ add( *L,"M" );92 M.log_register ( *L,"M" ); 88 93 L->init(); 89 94 … … 107 112 ut ( 0 ) = KalmanObs[4]; 108 113 ut ( 1 ) = KalmanObs[5]; 109 xt = fxu .eval ( xtm,ut ) + diag ( sqrt ( Qdiag ) ) *randn ( 4 );110 dt = hxu .eval ( xt,ut);114 xt = fxu->eval ( xtm,ut ) + diag ( sqrt ( Qdiag ) ) *randn ( 4 ); 115 dt = hxu->eval ( xt,ut ) + diag(sqrt(Rdiag))*randn(2); 111 116 xtm = xt; 112 117 … … 122 127 123 128 //estimator 124 KFE.bayes ( concat ( dt,ut ));125 M.bayes ( concat ( dt,ut ));129 KFE.bayes ( dt,ut ); 130 M.bayes ( dt,ut ); 126 131 127 L->log it( l_X,xt );128 L->log it( l_D,concat ( dt,ut ) );129 L->log it( l_Q,Qdiag );132 L->log_vector ( l_X,xt ); 133 L->log_vector ( l_D,concat ( dt,ut ) ); 134 L->log_vector ( l_Q,Qdiag ); 130 135 131 KFE.log it ( *L);132 M.log it ( *L);136 KFE.log_write ( ); 137 M.log_write ( ); 133 138 L->step(); 134 139 } … … 136 141 //Exit program: 137 142 138 delete L;139 143 return 0; 140 144 }