Changeset 1184
- Timestamp:
- 09/10/10 11:11:41 (14 years ago)
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/CMakeLists.txt
r1168 r1184 30 30 31 31 EXEC (pmsm_estim pmsmsim ekf_obj) 32 MEX (pmsm_estim pmsmsim ekf_obj) 32 33 #EXEC (sim pmsmsim) 33 34 #EXEC (sim_var pmsmsim) -
applications/pmsm/TR2245/CMakeLists.txt
r744 r1184 1 1 # Make sure the compiler can find include files from our Bdm library. 2 EXEC (unitsteps pmsmsim)3 EXEC (wishart pmsmsim)2 #EXEC (unitsteps pmsmsim) 3 #EXEC (wishart pmsmsim) 4 4 #EXEC (pmsm_wishart pmsmsim) -
applications/pmsm/pmsm.h
r1160 r1184 364 364 UIREGISTER ( OMpmsmRO ); 365 365 366 class OMpmsmROMz: public OMpmsmRO{ 367 public: 368 OMpmsmROMz() :OMpmsmRO() {dimy=2;dimx=5;dimu=0;}; 369 }; 370 UIREGISTER ( OMpmsmROMz ); 366 371 367 372 //! Observation model for PMSM drive and its derivative with respect to \f$x\f$ for full vector of observations -
applications/pmsm/pmsm_estim.cpp
r1174 r1184 15 15 16 16 using namespace bdm; 17 #ifdef MEX 18 #include <itpp/itmex.h> 19 #include <mex/mex_BM.h> 20 #include <mex/mex_logger.h> 21 #include <mex/mex_datasource.h> 22 #include <mex/mex_function.h> 23 24 void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { 25 // Check the number of inputs and output arguments 26 if ( n_input<2 ) mexErrMsgTxt ( "Usage:\n" 27 "[Res,estimators,Res2]=estimator(system, estimators, experiment, logger)\n" 28 " system = struct('class','datasource',...); % Estimated system\n" 29 " estimators = {struct('class','estimator',...), % Estimators\n" 30 " struct('class','estimator',...),...} \n" 31 " === optional ===" 32 " experiment = struct('ndat',10); % number of data in experiment, full length of finite datasources, 10 otherwise \n" 33 " logger = struct('class','mexlogger'); % How to store results, default=mexlog, i.e. matlab structure\n\n" 34 "Output:\n" 35 " Res Matlab structure with logged results, \n" 36 " estimators Array of estimators updated with data \n" 37 " Res2 When logfull log_level is on, this structure is filled with structures of posterior densities\n\n" 38 "see documentation of classes datasource, BM, and mexlogger and their offsprings in BDM." ); 39 40 RV::clear_all(); 41 //CONFIG 42 UImxArray F; 43 try { 44 F.addGroup ( input[0],"system" ); 45 F.addList ( input[1],"estimators" ); 46 if ( n_input>2 ) { 47 F.addGroup ( input[2],"experiment" ); 48 } 49 if ( n_input>3 ) { 50 F.addGroup ( input[3],"logger" ); 51 } 52 } catch ( SettingException e ) { 53 it_error ( "error: "+string ( e.getPath() ) ); 54 } 55 56 //DBG 57 F.writeFile ( "pmsm_estim.cfg" ); 58 59 #else 17 60 int main ( int argc, char* argv[] ) { 18 61 const char *fname; … … 20 63 else { cout << "Missing configuration file.\n Usage: \n $> estimator config_file.cfg"<<endl; abort(); } 21 64 UIFile F ( fname ); 22 65 #endif 66 23 67 shared_ptr<logger> L = UI::build <logger>( F, "logger" ); 24 68 shared_ptr<DS> pDS = UI::build<DS> ( F, "system" ); 25 69 Array<shared_ptr<BM> > Es; // array of estimators 26 UI::get( Es, F, "estimator " );70 UI::get( Es, F, "estimators" ); 27 71 int nE = Es.length(); //number of estimators 28 72 int Ndat; //number of data records 29 73 F.lookupValue ( "experiment.ndat",Ndat ); 30 74 75 if ( !L ) { 76 #ifdef MEX 77 //mex logger has only from_setting constructor - we have to fill it... 78 L=new mexlog ( Ndat ); 79 #else 80 L=new stdlog(); 81 #endif 82 } 31 83 pDS->log_register ( *L, "true" ); 32 84 string Ename; … … 67 119 68 120 L->finalize(); 121 #ifdef MEX 122 mexlog* mL=dynamic_cast<mexlog*> ( L.get() ); 123 124 if ( mL ) { // user wants output!! 125 if ( n_output<1 ) mexErrMsgTxt ( "Wrong number of output variables!" ); 126 output[0] = mL->toCell(); 127 if (n_output>1){ // write estimators 128 UImxArray Ests; 129 UI::save(Es, Ests,"estimators"); 130 output[1]=UImxArray::create_mxArray(Ests); 131 } 132 if (n_output>2) { 133 mL->_setting_conf().setAutoConvert(true); 134 output[2]= UImxArray::create_mxArray(mL->_setting_conf().getRoot()); 135 } 136 } 137 #endif 69 138 70 139 for (int i=0; i<nE; i++){ … … 72 141 delete Dlsc(i); 73 142 } 74 return 0;75 143 } 76 144 -
applications/pmsm/pmsm_estim_mex.cpp
r706 r1184 7 7 */ 8 8 9 #include " pmsm.h"10 #include " stat/loggers.h"9 #include "base/user_info.h" 10 #include "base/loggers.h" 11 11 #include "estim/kalman.h" 12 #include "pmsmDS.h" 13 #include "filters.h" 14 #include "base/datasources.h" 15 #include "simulator_zdenek/ekf_example/ekf_obj.h" 12 16 13 17 #include <itpp/itmex.h> 14 #include "../../library/mex/mex_logger.h" 15 #include "../../library/mex/mex_datasource.h" 16 #include "../../library/mex/mex_parser.h" 18 #include <mex/mex_BM.h> 19 #include <mex/mex_logger.h> 20 #include <mex/mex_datasource.h> 21 #include <mex/mex_function.h> 17 22 18 23 using namespace bdm; -
applications/pmsm/simulator_zdenek/ekf_example/matrix_vs.cpp
r1182 r1184 217 217 sigma += (((long)(*PSIU_ik)**PSIU_ik)>>15)*(*Dold_i); 218 218 } 219 sigma += *(Q+i+irows) ;219 sigma += *(Q+i+irows)<<15; 220 220 for (j=i+1, G_ik=G+irows+i+1; j<rows; j++,G_ik++) { 221 221 sigma += (((long)(*G_ik)**G_ik)>>13)**(Q+j+j*rows); -
library/bdm/math/functions.h
r1156 r1184 150 150 return dimu; 151 151 } 152 void validate(){dimc=dimx+dimu;}; 152 153 }; 153 154