1 | // created: 2012/04/18
|
---|
2 | // filename: main.cpp
|
---|
3 | //
|
---|
4 | // author: Guillaume Sanahuja
|
---|
5 | // Copyright Heudiasyc UMR UTC/CNRS 6599
|
---|
6 | //
|
---|
7 | // version: $Id: $
|
---|
8 | //
|
---|
9 | // purpose: main simulateur
|
---|
10 | //
|
---|
11 | //
|
---|
12 | /*********************************************************************/
|
---|
13 |
|
---|
14 | #include <tclap/CmdLine.h>
|
---|
15 | #include <Simulator.h>
|
---|
16 | #include <X4.h>
|
---|
17 | #include <X8.h>
|
---|
18 | #include <SimuImu.h>
|
---|
19 | #ifdef GL
|
---|
20 | #include <Parser.h>
|
---|
21 | #include <Man.h>
|
---|
22 | #include <SimuUsGL.h>
|
---|
23 | #endif
|
---|
24 |
|
---|
25 | using namespace TCLAP;
|
---|
26 | using namespace std;
|
---|
27 | using namespace flair::simulator;
|
---|
28 | using namespace flair::sensor;
|
---|
29 |
|
---|
30 | int port;
|
---|
31 | int opti_time;
|
---|
32 | string xml_file;
|
---|
33 | string media_path;
|
---|
34 | string scene_file;
|
---|
35 | string name;
|
---|
36 | string address;
|
---|
37 |
|
---|
38 | void parseOptions(int argc, char** argv)
|
---|
39 | {
|
---|
40 | try
|
---|
41 | {
|
---|
42 | CmdLine cmd("Command description message", ' ', "0.1");
|
---|
43 |
|
---|
44 | ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
|
---|
45 | cmd.add( nameArg );
|
---|
46 |
|
---|
47 | ValueArg<string> xmlArg("x","xml","xml file",true,"./reglages.xml","string");
|
---|
48 | cmd.add( xmlArg );
|
---|
49 |
|
---|
50 | ValueArg<int> portArg("p","port","ground station port",true,9002,"int");
|
---|
51 | cmd.add( portArg );
|
---|
52 |
|
---|
53 | ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int");
|
---|
54 | cmd.add( optiArg );
|
---|
55 | #ifdef GL
|
---|
56 | ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");
|
---|
57 | cmd.add( mediaArg );
|
---|
58 |
|
---|
59 | ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");
|
---|
60 | cmd.add( sceneArg );
|
---|
61 | #endif
|
---|
62 | ValueArg<string> addressArg("a","address","ground station address",true,"127.0.0.1","string");
|
---|
63 | cmd.add( addressArg );
|
---|
64 |
|
---|
65 | cmd.parse( argc, argv );
|
---|
66 |
|
---|
67 | // Get the value parsed by each arg.
|
---|
68 | port=portArg.getValue();
|
---|
69 | address=addressArg.getValue();
|
---|
70 | xml_file = xmlArg.getValue();
|
---|
71 | opti_time = optiArg.getValue();
|
---|
72 | name=nameArg.getValue();
|
---|
73 | #ifdef GL
|
---|
74 | media_path=mediaArg.getValue();
|
---|
75 | scene_file=sceneArg.getValue();
|
---|
76 | #endif
|
---|
77 |
|
---|
78 |
|
---|
79 | } catch (ArgException &e) // catch any exceptions
|
---|
80 | { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; }
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 | int main(int argc, char* argv[])
|
---|
85 | {
|
---|
86 | Simulator *simu;
|
---|
87 |
|
---|
88 | parseOptions(argc,argv);
|
---|
89 |
|
---|
90 | simu= new Simulator("simulator",opti_time,90);
|
---|
91 | simu->SetupConnection(address,port);
|
---|
92 | simu->SetupUserInterface(xml_file);
|
---|
93 | #ifdef GL
|
---|
94 | Parser *gui=new Parser(1024,768,1024,768,media_path,scene_file);
|
---|
95 | #endif
|
---|
96 | for(int i=0; i<2;i++) {
|
---|
97 | stringstream uavName;
|
---|
98 | uavName << name.c_str() << "_" << i;
|
---|
99 | Model *drone=new X8(uavName.str(),i);
|
---|
100 | #ifdef GL
|
---|
101 | SimuUsGL *us_gl=new SimuUsGL(drone,"us",i,0);
|
---|
102 | #endif
|
---|
103 | SimuImu *imu=new SimuImu(drone,"imu",i,0);
|
---|
104 | }
|
---|
105 |
|
---|
106 | simu->RunSimu();
|
---|
107 |
|
---|
108 | delete simu;
|
---|
109 |
|
---|
110 | return 0;
|
---|
111 | }
|
---|
112 |
|
---|