Changeset 1298 for applications

Show
Ignore:
Timestamp:
03/15/11 17:15:51 (13 years ago)
Author:
smidl
Message:

zmena PMSM_CTRL - akceptuje 2d modely
Pokusy v lq_dq2.cfg

Location:
applications/pmsm
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/experiments/ctrl_lq_dq2.cfg

    r1290 r1298  
    22 
    33experiment={ 
    4         Ndat = 20000; 
     4        Ndat = 120000; 
    55}; 
    66 
     
    99        params = "pmsm107@./cfg/zcu.cfg"; 
    1010        tstep = 1; // steps for profile in [s] 
    11         profileW = [0, 10, 0, 2 ]; 
     11//      profileW = [0, 10, 0, 2 ]; 
    1212//      profileW = [0, -10, 30, 60, 90, 60, 30, 0, -30, -60, -30]; 
    13 //      profileW = [1, 10, 50, 200, 200, 30, 0, 0, -30, -30, -100, -100, -40, 0, 0]; 
     13        profileW = [1, 10, 50, 200, 200, 30, 0, 0, -30, -30, -100, -100, -40, 0, 0]; 
    1414//      profileM = [0, 30, 0, 0, 30, 0, 0, 0, 0, 0, 10, 0, 0]; 
    1515        profileM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; 
     
    2828         }; 
    2929 
     30OT= {class="EKFfull"; 
     31         IM = {class="IMpmsmOT"; 
     32                params = "pmsm107@./cfg/zcu.cfg"; 
     33         }; 
     34         name = "ekf"; 
     35         OM = {class="OMpmsmOT"; 
     36                params = "pmsm107@./cfg/zcu.cfg"; 
     37        }; 
     38        dQ=[0.1, 0.01]; ///////// <====== OK 
     39        dR=[0.5, 0.5]; 
     40        dP0=[0.1, 0.1]; 
     41         //connect 
     42         log_level="logmean,logevidence,logbounds"; 
     43         }; 
     44 
     45PF= {class = "PF";name="pf"; 
     46          particle = {class ="BootstrapParticle"; 
     47                parameter_pdf = {class="mgnorm<ldmat>"; 
     48                  g={class="IMpmsmOT"; 
     49                        params = "pmsm107@./cfg/zcu.cfg"; 
     50                  }; 
     51                  dR=[0.001,0.0001]; 
     52                  rv ={class="RV";names=("om","th");}; 
     53                  rvc ={class="RV";names=("om","th","o_ua","o_ub","o_ia","o_ib");times=[-1,-1,0,0,-1,-1];}; 
     54                }; 
     55                observation_pdf= {class="mgnorm<ldmat>"; 
     56                  g={class="OMpmsmOT"; 
     57                        params = "pmsm107@./cfg/zcu.cfg"; 
     58                  };  
     59                  dR=[0.5,0.5];  
     60                  rv ={class="RV";names=("o_ia","o_ib");}; 
     61                  rvc = {class="RV";names=("om","th","o_ua","o_ub","o_ia","o_ib");times=[0,0,0,0,-1,-1];}; 
     62                }; 
     63          }; 
     64          n = 100; 
     65          log_level="logbounds,logmean"; 
     66          prior = {class="euni"; 
     67                high = [ 0.1, 1.0]; 
     68                low = [ -0.1, -1.0]; 
     69                rv ={class="RV";names=("om","th");}; 
     70          }; 
     71}; 
     72 
     73          
     74          
    3075controllers=({ 
     76//              class = "PMSM_PICtrl"; 
    3177                class = "PMSM_LQCtrl_dq2"; 
    32                 estim = "UD"; 
     78//              estim = "UD"; 
     79                estim = "PF"; 
    3380                r = 0.0001; 
    3481                h = 10; 
  • applications/pmsm/pmsm_ctrl.h

    r1294 r1298  
    22#define PMSM_CTR_H 
    33 
     4#include <estim/particles.h> 
    45#include <design/ctrlbase.h> 
    56#include <design/lq_ctrl.h> 
     
    4445 * I.e. it must have rv={ia, ib} and rvc={ua,ub}, any other BM will not work. 
    4546 *  
     47 * Two cases are considered:  
     48 *  - 4 dimensional rv={ia, ib, om, th} and rvc={ua,ub} 
     49 *  - 2 dimensional rv={om, th} and rvc={ua,ub,ia_{t-1}, ib_{t-1} } 
     50 *  These are hardcoded and sitched based on dimensionality. 
    4651 */ 
    4752class PMSMCtrl: public Controller{ 
     
    6368        PMSMCtrl():Controller() { 
    6469                rv = RV("{ua ub }"); 
    65                 rvc = RV("{o_ia o_ib o_ua o_ub o_om o_th Ww }"); 
     70                rvc = RV("{o_ia o_ib t_ua t_ub o_om o_th Ww }"); 
    6671        } 
    6772         
     
    7075                        vec y=data.get(0,1); 
    7176                        vec u=data.get(2,3); 
    72                         Est->bayes(y,u); 
     77                        if (Est->dimension()==2){ 
     78                                static vec cond(4); // 
     79                                cond.set_subvector(0,1,u); 
     80                                Est->bayes(y,cond); 
     81                                cond.set_subvector(2,3,y); // save 1-step delayed vectors  
     82                                 
     83                        } else { 
     84                                Est->bayes(y,u); 
     85                                 
     86                        } 
     87                         
    7388                } 
    7489        } 
     
    7893                 
    7994                if (estim){ 
     95                        if (Est->dimension()==2){ 
     96                                vec x_est=Est->posterior().mean(); 
     97                                isa=cond(0); 
     98                                isb=cond(1); 
     99                                ome=x_est(0); 
     100                                the=x_est(1); 
     101                        } else { 
    80102                        vec x_est=Est->posterior().mean(); 
    81103                        isa=x_est(0); 
     
    83105                        ome=x_est(2); 
    84106                        the=x_est(3); 
     107                        } 
    85108                } else { 
    86109                        isa=cond(0);//x_est(0);