source: flair-src/trunk/demos/Gps/simulator/src/main.cpp@ 89

Last change on this file since 89 was 89, checked in by Sanahuja Guillaume, 5 years ago

demo gps, not fully fonctionnal

File size: 3.2 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#include <SimuGps.h>
20#ifdef GL
21#include <SimuCameraGL.h>
22#include <Parser.h>
23#include <Man.h>
24#include <SimuUsGL.h>
25#endif
26
27
28using namespace TCLAP;
29using namespace std;
30using namespace flair::simulator;
31using namespace flair::sensor;
32
33int port;
34int opti_time;
35string xml_file;
36string media_path;
37string scene_file;
38string type;
39string name;
40string address;
41
42void parseOptions(int argc, char** argv) {
43 try {
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 ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int");
62 cmd.add( optiArg );
63
64#ifdef GL
65 ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");
66 cmd.add( mediaArg );
67
68 ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");
69 cmd.add( sceneArg );
70#endif
71
72 cmd.parse( argc, argv );
73
74 // Get the value parsed by each arg.
75 port=portArg.getValue();
76 xml_file = xmlArg.getValue();
77 opti_time = optiArg.getValue();
78 type = typeArg.getValue();
79 name=nameArg.getValue();
80 address=addressArg.getValue();
81#ifdef GL
82 media_path=mediaArg.getValue();
83 scene_file=sceneArg.getValue();
84#endif
85
86 } catch (ArgException &e) {
87 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
88 }
89}
90
91int main(int argc, char* argv[]) {
92 Simulator *simu;
93 Model *drone;
94 SimuImu *imu;
95 SimuGps *gps;
96#ifdef GL
97 SimuUsGL *us_gl;
98
99 Camera *cam_av,*cam_bas;
100 Parser *gui;
101 Man *man;
102#endif
103 parseOptions(argc,argv);
104
105 simu= new Simulator("simulator",opti_time,0);
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 drone=new X4(simu,name,0);
115 } else {
116 drone=new X8(simu,name,0);
117 }
118
119 imu=new SimuImu(drone,"imu",90);
120
121#ifdef GL
122 us_gl=new SimuUsGL(drone,"us",0);
123 cam_bas=new SimuCameraGL(drone,"bottom camera",320,240,640,0,0);
124 cam_av=new SimuCameraGL(drone,"front camera",320,240,640,240,1);
125
126 man=new Man(simu,"target");
127#endif
128 gps=new SimuGps(drone,"gps",0);
129
130 simu->RunSimu();
131
132 delete simu;
133
134 return 0;
135}
136
Note: See TracBrowser for help on using the repository browser.