Changeset 744 for applications/pmsm
- Timestamp:
- 11/28/09 14:38:48 (15 years ago)
- Location:
- applications/pmsm
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/CMakeLists.txt
r654 r744 33 33 #EXEC (sim_var pmsmsim) 34 34 35 #add_subdirectory (TR2245)35 add_subdirectory (TR2245) -
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 } -
applications/pmsm/pmsmDS.h
r686 r744 118 118 void log_register ( logger &L ) 119 119 { 120 L_x = L.add ( rx, "x" );121 L_oy = L.add ( ry, "o" );122 L_ou = L.add ( ru, "o" );123 L_iu = L.add ( ru, "t" );120 L_x = L.add_vector ( rx, "x" ); 121 L_oy = L.add_vector ( ry, "o" ); 122 L_ou = L.add_vector ( ru, "o" ); 123 L_iu = L.add_vector ( ru, "t" ); 124 124 // log differences 125 125 if ( opt_modu ) 126 126 { 127 L_optu = L.add ( ru, "model" );127 L_optu = L.add_vector ( ru, "model" ); 128 128 } 129 129 } … … 131 131 void log_write ( logger &L ) 132 132 { 133 L.log it( L_x, vec ( x,4 ) );134 L.log it( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) );135 L.log it( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) );136 L.log it( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) );133 L.log_vector ( L_x, vec ( x,4 ) ); 134 L.log_vector ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) ); 135 L.log_vector ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) ); 136 L.log_vector ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) ); 137 137 if ( opt_modu ) 138 138 { … … 151 151 ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0; 152 152 ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3; 153 L.log it( L_optu , vec_2 ( ua,ub ) );153 L.log_vector ( L_optu , vec_2 ( ua,ub ) ); 154 154 } 155 155 … … 238 238 void log_add(logger &L, const string &name="" ) 239 239 { 240 L_CRB=L.add (rx,"crb");241 L_err=L.add (rx,"err");242 L_sec=L.add (rx,"d2");240 L_CRB=L.add_vector(rx,"crb"); 241 L_err=L.add_vector(rx,"err"); 242 L_sec=L.add_vector(rx,"d2"); 243 243 } 244 244 void logit(logger &L) 245 245 { 246 L.log it(L_err, interr);247 L.log it(L_CRB,diag(_R()));248 L.log it(L_sec,secder);246 L.log_vector(L_err, interr); 247 L.log_vector(L_CRB,diag(_R())); 248 L.log_vector(L_sec,secder); 249 249 } 250 250 … … 322 322 void log_add(logger &L, const string &name="" ) 323 323 { 324 L_CRB=L.add (concat(rx,RV("Mz",1,0)),"crbz");324 L_CRB=L.add_vector(concat(rx,RV("Mz",1,0)),"crbz"); 325 325 } 326 326 void logit(logger &L) 327 327 { 328 L.log it(L_CRB,diag(_R()));328 L.log_vector(L_CRB,diag(_R())); 329 329 } 330 330