source: flair-src/trunk/demos/PidStandalone/simulator/src/main.cpp@ 222

Last change on this file since 222 was 105, checked in by Bayard Gildas, 8 years ago

Passage du "framework" à flair

File size: 3.0 KB
Line 
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 <SimuCameraGL.h>
21#include <Parser.h>
22#include <SimuUsGL.h>
23#endif
24
25
26using namespace TCLAP;
27using namespace std;
28using namespace flair::simulator;
29using namespace flair::sensor;
30
31int port;
32int opti_time;
33string xml_file;
34string media_path;
35string scene_file;
36string type;
37string name;
38string address;
39
40void parseOptions(int argc, char** argv)
41{
42 try
43 {
44 CmdLine cmd("Command description message", ' ', "0.1");
45
46 ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
47 cmd.add( nameArg );
48
49 ValueArg<string> xmlArg("x","xml","xml file",true,"./reglages.xml","string");
50 cmd.add( xmlArg );
51
52 ValueArg<int> portArg("p","port","ground station port",true,9002,"int");
53 cmd.add( portArg );
54
55 ValueArg<string> addressArg("a","address","ground station address",true,"127.0.0.1","string");
56 cmd.add( addressArg );
57
58 ValueArg<string> typeArg("t","type","uav type, x4 or x8",true,"x4","string");
59 cmd.add( typeArg );
60
61
62 ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int");
63 cmd.add( optiArg );
64
65#ifdef GL
66 ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");
67 cmd.add( mediaArg );
68
69 ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");
70 cmd.add( sceneArg );
71#endif
72
73 cmd.parse( argc, argv );
74
75 // Get the value parsed by each arg.
76 port=portArg.getValue();
77 xml_file = xmlArg.getValue();
78 opti_time = optiArg.getValue();
79 type = typeArg.getValue();
80 name=nameArg.getValue();
81 address=addressArg.getValue();
82#ifdef GL
83 media_path=mediaArg.getValue();
84 scene_file=sceneArg.getValue();
85#endif
86
87 } catch (ArgException &e) // catch any exceptions
88 { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; }
89}
90
91
92int main(int argc, char* argv[])
93{
94 Simulator *simu;
95 Model *drone;
96 SimuImu* imu;
97#ifdef GL
98 SimuUsGL* us_gl;
99
100 SimuCameraGL *cam_bas;
101 Parser *gui;
102#endif
103 parseOptions(argc,argv);
104
105 simu= new Simulator("simulator",opti_time,90);
106 simu->SetupConnection(address,port);
107 simu->SetupUserInterface(xml_file);
108
109#ifdef GL
110 gui=new Parser(simu,960,480,640,480,media_path,scene_file);
111#endif
112
113 if(type=="x4")
114 {
115 drone=new X4(simu,name,0);
116 }
117 else
118 {
119 drone=new X8(simu,name,0);
120 }
121 imu=new SimuImu(drone,"imu",0);
122
123#ifdef GL
124 us_gl=new SimuUsGL(drone,"us",0);
125 cam_bas=new SimuCameraGL(drone,"bottom camera",320,240,640,0,0);
126#endif
127
128 simu->RunSimu();
129
130 delete simu;
131
132 return 0;
133}
134
Note: See TracBrowser for help on using the repository browser.