Changeset 135 for pmsm/sim_var.cpp
- Timestamp:
- 07/25/08 15:04:05 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pmsm/sim_var.cpp
r131 r135 40 40 vec dt ( 2 ); 41 41 vec ut ( 2 ); 42 vec dut ( 4);42 vec dut ( 2 ); 43 43 vec dit (2); 44 44 vec xtm=zeros ( 4 ); 45 vec xte=zeros ( 4 ); 45 46 vec xdif=zeros ( 4 ); 46 47 vec xt ( 4 ); … … 95 96 //Number of steps of a simulator for one step of Kalman 96 97 for ( int ii=0; ii<Nsimstep;ii++ ) { 97 sim_profile_steps1 ( Ww , true);98 sim_profile_steps1 ( Ww , false); 98 99 pmsmsim_step ( Ww ); 99 100 }; … … 105 106 dut ( 0 ) = KalmanObs[4]; 106 107 dut ( 1 ) = KalmanObs[5]; 107 dut ( 2 ) = KalmanObs[6];108 dut ( 3 ) = KalmanObs[7];109 108 dit ( 0 ) = KalmanObs[8]; 110 109 dit ( 1 ) = KalmanObs[9]; 111 110 112 xt = fxu.eval ( xtm,ut );111 xte = fxu.eval ( xtm,ut ); 113 112 //Results: 114 // in xt we have simulat on according to the model113 // in xt we have simulation according to the model 115 114 // in x we have "reality" 116 xt m ( 0 ) =x[0];xtm ( 1 ) =x[1];xtm ( 2 ) =x[2];xtm( 3 ) =x[3];117 xdif = xt m-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[] 118 117 if (xdif(0)>3.0){ 119 118 cout << "here" <<endl; … … 122 121 if ( xdif ( 3 ) <-pi ) xdif ( 3 ) +=2*pi; 123 122 124 ddif = hxu.eval(xt m,ut) - dt;123 ddif = hxu.eval(xt,ut) - dit; 125 124 126 125 //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 131 137 132 138 //ESTIMATE 133 139 Efix.bayes(concat(dt,ut)); 134 140 // 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))); 136 142 Eop.bayes(concat(dt,ut)); 137 143 // … … 154 160 155 161 L.step(true); 156 //L.itsave("sim_var.it");162 //L.itsave("sim_var.it"); 157 163 158 164