Show
Ignore:
Timestamp:
07/23/12 11:03:24 (12 years ago)
Author:
smidl
Message:

upravy choleskiho + nove qmath

Files:
1 modified

Legend:

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

    r1463 r1464  
    2323#include "mpf_double.h" 
    2424#include "fast_exp.h" 
     25#include "ekf_mm.h" 
     26#include "qmath.h" 
    2527 
    2628using namespace bdm; 
     
    413415class EKFfixedCh2 : public BM { 
    414416public: 
    415         LOG_LEVEL(EKFfixedCh2,logCh, logA, logC, logP); 
     417        LOG_LEVEL(EKFfixedCh2,logCh, logA, logC, logP, logDet, logRem); 
    416418         
    417419        void init_ekf2(double Tv); 
     
    470472                L.add_vector ( log_level, logC, RV ("C2", 4 ), prefix ); 
    471473                L.add_vector ( log_level, logP, RV ("P2", 4 ), prefix ); 
    472                  
    473         }; 
    474         //void from_setting(); 
     474                L.add_vector ( log_level, logDet, RV ("Det", 1 ), prefix ); 
     475                L.add_vector ( log_level, logRem, RV ("Rem", 1 ), prefix ); 
     476                 
     477        }; 
     478        void from_setting ( const Setting &set ){ 
     479                BM::from_setting(set); 
     480                vec dQ,dR; 
     481                UI::get ( dQ, set, "dQ", UI::optional ); 
     482                UI::get ( dQ, set, "dR", UI::optional ); 
     483                if (dQ.length()==2){ 
     484                        Q[0]=prevod(dQ[0],15);      // 1e-3 
     485                        Q[3]=prevod(dQ[1],15);      // 1e-3 
     486                } 
     487                if (dR.length()==2){ 
     488                        R[0]=prevod(dR[0],15);      // 1e-3 
     489                        R[3]=prevod(dR[1],15);      // 1e-3 
     490                } 
     491        } 
    475492}; 
    476493 
     
    711728 
    712729 
     730class ekfChfix: public BM{ 
     731         
     732        ekf_data E; 
     733public: 
     734        ekfChfix(){ 
     735                init_ekfCh2(&E,0.000125);set_dim(2);    dimc = 2; 
     736                dimy = 2; 
     737        }  
     738        void bayes ( const vec &val, const vec &cond ) { 
     739                int16 ux,uy; 
     740                ux=prevod(cond[0]/Uref,15); 
     741                uy=prevod(cond[1]/Uref,15); 
     742                 
     743                int16 yx,yy; 
     744                // zadani mereni 
     745                yx=prevod(val[0]/Iref,15); 
     746                yy=prevod(val[1]/Iref,15); 
     747                 
     748                int16 detS, rem; 
     749                ekfCh2(&E, ux,uy,yx,yy, &detS, &rem); 
     750                 
     751                Est._mu()=vec_2(E.x_est[0]*Uref/32768., E.x_est[1]*Uref/32768.); 
     752                 
     753                ll = -0.5*qlog(detS)-0.5*rem; 
     754        } 
     755        const epdf& posterior() const {return Est;}; 
     756        void from_setting ( const Setting &set ){ 
     757                BM::from_setting(set); 
     758                vec dQ,dR; 
     759                UI::get ( dQ, set, "dQ", UI::optional ); 
     760                UI::get ( dQ, set, "dR", UI::optional ); 
     761                if (dQ.length()==2){ 
     762                        E.Q[0]=prevod(dQ[0],15);      // 1e-3 
     763                        E.Q[3]=prevod(dQ[1],15);      // 1e-3 
     764                } 
     765                if (dR.length()==2){ 
     766                        E.dR[0]=prevod(dR[0],15);      // 1e-3 
     767                        E.dR[1]=prevod(dR[1],15);      // 1e-3 
     768                } 
     769        } 
     770         
     771        enorm<fsqmat> Est; 
     772        mat Ry; 
     773}; 
     774UIREGISTER(ekfChfix); 
     775 
    713776#endif // KF_H 
    714777