source: flair-src/trunk/demos/SimpleFleet/simulator/src/main.cpp@ 358

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

add x4 to simple fleet

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 <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;
37string type;
38
39void parseOptions(int argc, char** argv)
40{
41 try
42 {
43 CmdLine cmd("Command description message", ' ', "0.1");
44
45 ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
46 cmd.add( nameArg );
47
48 ValueArg<string> xmlArg("x","xml","xml file",true,"./reglages.xml","string");
49 cmd.add( xmlArg );
50
51 ValueArg<int> portArg("p","port","ground station port",true,9002,"int");
52 cmd.add( portArg );
53
54 ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int");
55 cmd.add( optiArg );
56#ifdef GL
57 ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");
58 cmd.add( mediaArg );
59
60 ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");
61 cmd.add( sceneArg );
62#endif
63 ValueArg<string> addressArg("a","address","ground station address",true,"127.0.0.1","string");
64 cmd.add( addressArg );
65
66 ValueArg<string> typeArg("t", "type", "uav type, x4 or x8", true, "x4", "string");
67 cmd.add(typeArg);
68
69 cmd.parse( argc, argv );
70
71 // Get the value parsed by each arg.
72 port=portArg.getValue();
73 address=addressArg.getValue();
74 xml_file = xmlArg.getValue();
75 opti_time = optiArg.getValue();
76 name=nameArg.getValue();
77 type = typeArg.getValue();
78#ifdef GL
79 media_path=mediaArg.getValue();
80 scene_file=sceneArg.getValue();
81#endif
82
83
84 } catch (ArgException &e) {
85 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
86 exit(EXIT_FAILURE);
87 }
88}
89
90
91int main(int argc, char* argv[]) {
92 Simulator *simu;
93
94 parseOptions(argc,argv);
95
96 simu= new Simulator("simulator",opti_time,90);
97 simu->SetupConnection(address,port);
98 simu->SetupUserInterface(xml_file);
99 #ifdef GL
100 Parser *gui=new Parser(1024,768,1024,768,media_path,scene_file);
101 #endif
102 for(int i=0; i<2;i++) {
103 stringstream uavName;
104 Model *drone;
105 uavName << name.c_str() << "_" << i;
106 if(type == "x4") {
107 drone = new X4(uavName.str(),i);
108 } else {
109 drone = new X8(uavName.str(),i);
110 }
111
112#ifdef GL
113 SimuUsGL *us_gl=new SimuUsGL(drone,"us",i,0);
114#endif
115 SimuImu *imu=new SimuImu(drone,"imu",i,0);
116 }
117
118 simu->RunSimu();
119
120 delete simu;
121
122 return 0;
123}
124
Note: See TracBrowser for help on using the repository browser.