Show
Ignore:
Timestamp:
05/14/09 17:16:45 (15 years ago)
Author:
smidl
Message:

Barcelona

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/pmsmDS.h

    r332 r342  
    3535public: 
    3636        //! 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 }" );} 
    3838        void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) { 
    3939                pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 ); 
     
    4141        //! parse options: "modelu" => opt_modu=true; 
    4242        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];} 
    4646        void write ( vec &ut ) {} 
    4747 
     
    8282                 
    8383                //discretization 
    84                 double ustep=0.6; 
     84                double ustep=1.2; 
    8585                KalmanObs [ 0 ] = ustep*itpp::round( KalmanObs [ 0 ]/ ustep) ; 
    8686                KalmanObs [ 1 ] = ustep*itpp::round(KalmanObs [ 1 ]/ ustep); 
     
    177177        } 
    178178}; 
     179 
     180//! This class behaves like BM but it is evaluating EKF 
     181class 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};