Changeset 342 for applications/pmsm/pmsmDS.h
- Timestamp:
- 05/14/09 17:16:45 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/pmsmDS.h
r332 r342 35 35 public: 36 36 //! Constructor with fixed sampling period 37 pmsmDS () {Dt=125; Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th }" );}37 pmsmDS () {Dt=125; Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" );} 38 38 void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) { 39 39 pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 ); … … 41 41 //! parse options: "modelu" => opt_modu=true; 42 42 void set_options ( string &opt ) { 43 opt_modu = ( opt.find ( "modelu" ) ==string::npos );44 } 45 void getdata ( vec &dt ) {dt.set_subvector(0,vec ( KalmanObs,6 ));dt(6)=x[2];dt(7)=x[3]; }43 opt_modu = ( opt.find ( "modelu" ) !=string::npos ); 44 } 45 void getdata ( vec &dt ) {dt.set_subvector(0,vec ( KalmanObs,6 ));dt(6)=x[2];dt(7)=x[3];dt(8)=x[8];} 46 46 void write ( vec &ut ) {} 47 47 … … 82 82 83 83 //discretization 84 double ustep= 0.6;84 double ustep=1.2; 85 85 KalmanObs [ 0 ] = ustep*itpp::round( KalmanObs [ 0 ]/ ustep) ; 86 86 KalmanObs [ 1 ] = ustep*itpp::round(KalmanObs [ 1 ]/ ustep); … … 177 177 } 178 178 }; 179 180 //! This class behaves like BM but it is evaluating EKF 181 class pmsmCRBMz : public EKFfull{ 182 protected: 183 int L_CRB; 184 public: 185 //! constructor 186 pmsmCRBMz():EKFfull(){} 187 188 void bayes(const vec &dt){ 189 //assume we know state exactly: 190 vec true_state(5); 191 true_state.set_subvector(0,vec(x,4)); // read from pmsm 192 true_state(4)=x[8]; 193 194 E.set_mu(true_state); 195 mu = true_state; 196 //hack for ut 197 EKFfull::bayes(dt); 198 } 199 200 void log_add(logger &L, const string &name="" ){ 201 L_CRB=L.add(concat(rx,RV("Mz",1,0)),"crb"); 202 } 203 void logit(logger &L){ 204 L.logit(L_CRB,diag(_R())); 205 } 206 };