Changeset 135 for pmsm/sim_var.cpp

Show
Ignore:
Timestamp:
07/25/08 15:04:05 (16 years ago)
Author:
smidl
Message:

oprava simulatoru

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pmsm/sim_var.cpp

    r131 r135  
    4040        vec dt ( 2 ); 
    4141        vec ut ( 2 ); 
    42         vec dut ( 4 ); 
     42        vec dut ( 2 ); 
    4343        vec dit (2); 
    4444        vec xtm=zeros ( 4 ); 
     45        vec xte=zeros ( 4 ); 
    4546        vec xdif=zeros ( 4 ); 
    4647        vec xt ( 4 ); 
     
    9596                //Number of steps of a simulator for one step of Kalman 
    9697                for ( int ii=0; ii<Nsimstep;ii++ ) { 
    97                         sim_profile_steps1 ( Ww , true); 
     98                        sim_profile_steps1 ( Ww , false); 
    9899                        pmsmsim_step ( Ww ); 
    99100                }; 
     
    105106                dut ( 0 ) = KalmanObs[4]; 
    106107                dut ( 1 ) = KalmanObs[5]; 
    107                 dut ( 2 ) = KalmanObs[6]; 
    108                 dut ( 3 ) = KalmanObs[7]; 
    109108                dit ( 0 ) = KalmanObs[8]; 
    110109                dit ( 1 ) = KalmanObs[9]; 
    111110 
    112                 xt = fxu.eval ( xtm,ut ); 
     111                xte = fxu.eval ( xtm,ut ); 
    113112                //Results: 
    114                 // in xt we have simulaton according to the model 
     113                // in xt we have simulation according to the model 
    115114                // in x we have "reality" 
    116                 xtm ( 0 ) =x[0];xtm ( 1 ) =x[1];xtm ( 2 ) =x[2];xtm ( 3 ) =x[3]; 
    117                 xdif = xtm-xt; 
     115                xt ( 0 ) =x[0];xt ( 1 ) =x[1];xt ( 2 ) =x[2];xt ( 3 ) =x[3]; 
     116                xdif = xt-xte; //xtm is a copy of x[] 
    118117                if (xdif(0)>3.0){ 
    119118                        cout << "here" <<endl; 
     
    122121                if ( xdif ( 3 ) <-pi ) xdif ( 3 ) +=2*pi; 
    123122                 
    124                 ddif = hxu.eval(xtm,ut) - dt; 
     123                ddif = hxu.eval(xt,ut) - dit; 
    125124 
    126125                //Rt = 0.9*Rt + xdif^2 
    127                 Qt*=0.01; 
    128                 Qt += outer_product ( xdif,xdif ); //(x-xt)^2 
    129                 Rt*=0.01; 
    130                 Rt += outer_product ( ddif,ddif ); //(x-xt)^2 
     126                Qt*=0.1; 
     127                Qt += 10*outer_product ( xdif,xdif ); //(x-xt)^2 
     128 
     129                if (Qt(0,0)>3.0){ 
     130                        cout << "here" <<endl; 
     131                        } 
     132                // For future ref. 
     133                xtm = xt; 
     134 
     135                Rt*=0.1; 
     136//              Rt += 10*outer_product ( ddif,ddif ); //(x-xt)^2 
    131137 
    132138                //ESTIMATE 
    133139                Efix.bayes(concat(dt,ut)); 
    134140                // 
    135                 Eop.set_parameters ( &fxu,&hxu,(Qt+1e-16*eye(4)),(Rt+1e-3*eye(2))); 
     141                Eop.set_parameters ( &fxu,&hxu,(Qt+1e-8*eye(4)),(Rt+1e-6*eye(2))); 
    136142                Eop.bayes(concat(dt,ut)); 
    137143                // 
     
    154160 
    155161        L.step(true); 
    156 //      L.itsave("sim_var.it");  
     162        //L.itsave("sim_var.it");        
    157163         
    158164