source: flair-src/branches/sanscv/demos/SimpleFleet/simulator/src/main.cpp@ 441

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

removing opencv dependency

File size: 2.7 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 <Parser.h>
21#include <Man.h>
22#include <SimuUsGL.h>
23#endif
24
25using namespace TCLAP;
26using namespace std;
27using namespace flair::simulator;
28using namespace flair::sensor;
29
30int port;
31int opti_time;
32string xml_file;
33string media_path;
34string scene_file;
35string name;
36string address;
37
38void 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) {
80 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
81 exit(EXIT_FAILURE);
82 }
83}
84
85
86int main(int argc, char* argv[])
87{
88 Simulator *simu;
89
90 parseOptions(argc,argv);
91
92 simu= new Simulator("simulator",opti_time,90);
93 simu->SetupConnection(address,port);
94 simu->SetupUserInterface(xml_file);
95 #ifdef GL
96 Parser *gui=new Parser(1024,768,1024,768,media_path,scene_file);
97 #endif
98 for(int i=0; i<2;i++) {
99 stringstream uavName;
100 uavName << name.c_str() << "_" << i;
101 Model *drone=new X8(uavName.str(),i);
102#ifdef GL
103 SimuUsGL *us_gl=new SimuUsGL(drone,"us",i,0);
104#endif
105 SimuImu *imu=new SimuImu(drone,"imu",i,0);
106 }
107
108 simu->RunSimu();
109
110 delete simu;
111
112 return 0;
113}
114
Note: See TracBrowser for help on using the repository browser.