Changeset 1298 for applications/pmsm/pmsm_ctrl.h
- Timestamp:
- 03/15/11 17:15:51 (13 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/pmsm_ctrl.h
r1294 r1298 2 2 #define PMSM_CTR_H 3 3 4 #include <estim/particles.h> 4 5 #include <design/ctrlbase.h> 5 6 #include <design/lq_ctrl.h> … … 44 45 * I.e. it must have rv={ia, ib} and rvc={ua,ub}, any other BM will not work. 45 46 * 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. 46 51 */ 47 52 class PMSMCtrl: public Controller{ … … 63 68 PMSMCtrl():Controller() { 64 69 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 }"); 66 71 } 67 72 … … 70 75 vec y=data.get(0,1); 71 76 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 73 88 } 74 89 } … … 78 93 79 94 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 { 80 102 vec x_est=Est->posterior().mean(); 81 103 isa=x_est(0); … … 83 105 ome=x_est(2); 84 106 the=x_est(3); 107 } 85 108 } else { 86 109 isa=cond(0);//x_est(0);