Changeset 1168 for applications/pmsm/simulator_zdenek
- Timestamp:
- 08/27/10 17:05:55 (14 years ago)
- Location:
- applications/pmsm/simulator_zdenek/ekf_example
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/simulator_zdenek/ekf_example/ekf_obj.cpp
r384 r1168 8 8 9 9 /////////////// 10 void EKFfixed::bayes(const vec &dt){ 11 ekf(dt(2),dt(3),dt(0),dt(1)); 10 void EKFfixed::bayes(const vec &yt, const vec &ut){ 11 ekf(yt(0),yt(1),ut(0),ut(1)); 12 12 13 vec xhat(4); 13 14 //UGLY HACK!!! reliance on a predictor!! … … 15 16 xhat(1)=zprevod(x_est[1],Qm)*Iref; 16 17 xhat(2)=zprevod(x_est[2],Qm)*Wref; 17 xhat(3)=zprevod(x_est[3],15) ;18 xhat(3)=zprevod(x_est[3],15)*Thetaref; 18 19 19 20 E.set_mu(xhat); … … 33 34 double* Pp=Pfull._data(); 34 35 for(int i=0;i<16;i++){*(Pp++) = zprevod(P_est[i],15);} 36 37 E._R()._M()=Pfull; 38 35 39 36 40 BM::ll = -0.5* ( 4 * 1.83787706640935 +log ( det ( Pfull ) ) +xdif* ( inv(Pfull)*xdif ) ); -
applications/pmsm/simulator_zdenek/ekf_example/ekf_obj.h
r384 r1168 65 65 //! Default constructor 66 66 EKFfixed ():BM(),E(),Ry(2,2){ 67 int i;68 69 67 int i; 68 for(i=0;i<16;i++){Q[i]=0;} 69 for(i=0;i<4;i++){R[i]=0;} 70 70 71 72 73 74 75 76 77 78 79 80 81 71 for(i=0;i<4;i++){x_est[i]=0;} 72 for(i=0;i<4;i++){x_pred[i]=0;} 73 for(i=0;i<16;i++){P_pred[i]=0;} 74 for(i=0;i<16;i++){P_est[i]=0;} 75 P_est[0]=0x7FFF; 76 P_est[5]=0x7FFF; 77 P_est[10]=0x7FFF; 78 P_est[15]=0x7FFF; 79 for(i=0;i<2;i++){Y_mes[i]=0;} 80 for(i=0;i<2;i++){ukalm[i]=0;} 81 for(i=0;i<8;i++){Kalm[i]=0;} 82 82 83 for(i=0;i<16;i++){PSI[i]=0;} 84 }; 83 for(i=0;i<16;i++){PSI[i]=0;} 84 85 set_dim(4); 86 E._mu()=zeros(4); 87 E._R()=zeros(4,4); 88 init_ekf(0.000125); 89 }; 85 90 //! Here dt = [yt;ut] of appropriate dimensions 86 void bayes ( const vec & dt );91 void bayes ( const vec &yt, const vec &ut ); 87 92 //!dummy! 88 epdf& posterior(){return E;}; 89 void condition ( const vec &Q0 ) { 90 91 Q[0]=prevod(minQ(Q0(0)),15); // 0.05 92 Q[5]=prevod(minQ(Q0(1)),15); 93 Q[10]=prevod(minQ(Q0(2)),15); // 1e-3 94 Q[15]=prevod(minQ(Q0(3)),15); // 1e-3 95 96 } 93 const epdf& posterior() const {return E;}; 94 97 95 }; 98 96 97 UIREGISTER(EKFfixed); 99 98 100 99 #endif // KF_H