Show
Ignore:
Timestamp:
04/28/11 22:18:55 (13 years ago)
Author:
smidl
Message:

extended reduced model for unknown Torque

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/simulator_zdenek/ekf_example/ekf_obj.h

    r1326 r1341  
    270270 
    271271/*! 
     272 * \brief Extended Kalman Filter with UD matrices in fixed point16 arithmetic 
     273 *  
     274 * An approximation of the exact Bayesian filter with Gaussian noices and non-linear evolutions of their mean. 
     275 */ 
     276class EKFfixedUD3 : public BM { 
     277public: 
     278        LOG_LEVEL(EKFfixedUD3,logU, logG, logD, logA, logC, logP); 
     279         
     280        void init_ekf3(double Tv); 
     281        void ekf3(double ux, double uy, double isxd, double isyd); 
     282         
     283        /* Constants - definovat jako konstanty ?? ?kde je vyhodnejsi aby v pameti byli?*/ 
     284        int16 Q[9]; /* matrix [4,4] */ 
     285        int16 R[4]; /* matrix [2,2] */ 
     286         
     287        int16 x_est[3]; /* estimate and prediction */ 
     288        int16 y_est[2]; /* estimate and prediction */ 
     289        int16 y_old[2]; /* estimate and prediction */ 
     290         
     291        int16 PSI[9]; /* matrix [4,4] */ 
     292        int16 PSIU[9]; /* matrix PIS*U, [4,4] */ 
     293        int16 C[6]; /* matrix [4,4] */ 
     294         
     295        int16 Uf[9]; // upper triangular of covariance (inplace) 
     296        int16 Df[3];  // diagonal covariance 
     297        int16 Dfold[3]; // temp of D 
     298        int16 G[9];  // temp for bierman 
     299         
     300        int16 cA, cB, cC, cG, cF, cH;  // cD, cE, cF, cI ... nepouzivane 
     301         
     302        enorm<fsqmat> E; 
     303        mat Ry; 
     304         
     305public: 
     306        //! Default constructor 
     307        EKFfixedUD3 ():BM(),E(),Ry(2,2){ 
     308                int16 i; 
     309                for(i=0;i<9;i++){Q[i]=0;} 
     310                for(i=0;i<4;i++){R[i]=0;} 
     311                 
     312                for(i=0;i<3;i++){x_est[i]=0;} 
     313                for(i=0;i<2;i++){y_est[i]=0;} 
     314                for(i=0;i<2;i++){y_old[i]=0;} 
     315                for(i=0;i<9;i++){Uf[i]=0;} 
     316                for(i=0;i<3;i++){Df[i]=0;} 
     317                for(i=0;i<4;i++){G[i]=0;} 
     318                for(i=0;i<3;i++){Dfold[i]=0;} 
     319                 
     320                for(i=0;i<9;i++){PSI[i]=0;} 
     321                for(i=0;i<6;i++){C[i]=0;} 
     322                 
     323                set_dim(3); 
     324                dimc = 2; 
     325                dimy = 2; 
     326                E._mu()=zeros(3); 
     327                E._R()=zeros(3,3); 
     328                init_ekf3(0.000125); 
     329        }; 
     330        //! Here dt = [yt;ut] of appropriate dimensions 
     331        void bayes ( const vec &yt, const vec &ut ); 
     332        //!dummy! 
     333        const epdf& posterior() const {return E;}; 
     334        void log_register(logger &L, const string &prefix){ 
     335                BM::log_register ( L, prefix );          
     336        }; 
     337        //void from_setting(); 
     338}; 
     339 
     340UIREGISTER(EKFfixedUD3); 
     341 
     342/*! 
    272343 * \brief Extended Kalman Filter with Chol matrices in fixed point16 arithmetic 
    273344 *