root/applications/pmsm/pmsm_estim.cpp @ 654

Revision 654, 1.5 kB (checked in by smidl, 15 years ago)

PMSM compiles again

Line 
1
2/*!
3\file
4\brief Multi-Estimator (developped for PMSM)
5
6
7 */
8
9#include "base/user_info.h"
10#include "base/loggers.h"
11#include "estim/kalman.h"
12#include "pmsmDS.h"
13#include "filters.h"
14
15
16using namespace bdm;
17int main ( int argc, char* argv[] ) {
18        const char *fname;
19        if ( argc>1 ) {fname = argv[1]; }
20        else { cout << "Missing configuration file.\n Usage: \n $> estimator config_file.cfg"<<endl; abort(); }
21        UIFile F ( fname );
22
23        shared_ptr<logger> L = UI::build <logger>( F, "logger" );
24        shared_ptr<DS>  pDS = UI::build<DS> ( F, "system" );
25        Array<shared_ptr<BM> > Es;                      // array of estimators
26        UI::get( Es, F, "estimator" );
27        int nE = Es.length();   //number of estimators
28        int Ndat;                               //number of data records
29        F.lookupValue ( "experiment.ndat",Ndat );
30               
31        pDS->log_add ( *L );
32        string nic="";
33        for (int i=0; i<nE; i++){
34                Es(i)->log_add(*L,nic); // estimate
35        }
36        L->init();
37
38        vec dt=zeros ( pDS->_drv()._dsize() );   //data variable
39        Array<datalink*> Dls(nE); 
40        for (int i=0; i<nE; i++){
41                Dls(i)=new datalink( Es(i)->_drv(),pDS->_drv() ); //datalink between a datasource and estimator
42        }
43       
44        // Main cycle
45        for ( int tK=1;tK<Ndat;tK++ ) {
46                // Data Source
47                pDS->step();                                                    // simulator step
48                pDS->getdata ( dt );                                    // read data
49                pDS->logit ( *L );
50               
51                // Estimators
52                for (int i=0; i<nE; i++){
53                        Es(i)->bayes ( Dls(i)->pushdown ( dt ) );               // update estimates
54
55                        Es(i)->logit (*L);
56                }
57                // Regulators
58                L->step();
59        }
60
61        L->finalize();
62
63        for (int i=0; i<nE; i++){
64                delete Dls(i);
65        }
66        return 0;
67}
Note: See TracBrowser for help on using the browser.