source: flair-src/trunk/demos/MixedReality/simulator_real/src/main.cpp@ 292

Last change on this file since 292 was 292, checked in by Sanahuja Guillaume, 3 years ago

add mixed reality demo

File size: 2.5 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#ifdef GL
14
15#include <tclap/CmdLine.h>
16#include <Simulator.h>
17#include <X4.h>
18#include <SimuImu.h>
19#include <Parser.h>
20#include <SimuUsGL.h>
21#include <SimuCameraGL.h>
22
23#define UAV_REAL_MODEL_ID 0
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 address;
36
37void parseOptions(int argc, char** argv)
38{
39 try {
40 CmdLine cmd("Command description message", ' ', "0.1");
41
42 ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string");
43 cmd.add(xmlArg);
44
45 ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int");
46 cmd.add(portArg);
47
48 ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string");
49 cmd.add(addressArg);
50
51 ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int");
52 cmd.add(optiArg);
53
54 ValueArg<string> mediaArg("m", "media", "path to media files", true, "./", "string");
55 cmd.add(mediaArg);
56
57 ValueArg<string> sceneArg("s", "scene", "path to scene file", true, "./voliere.xml", "string");
58 cmd.add(sceneArg);
59
60 cmd.parse(argc, argv);
61
62 // Get the value parsed by each arg.
63 port = portArg.getValue();
64 xml_file = xmlArg.getValue();
65 opti_time = optiArg.getValue();
66 address = addressArg.getValue();
67 media_path = mediaArg.getValue();
68 scene_file = sceneArg.getValue();
69 } catch(ArgException& e) {
70 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
71 exit(EXIT_FAILURE);
72 }
73}
74
75int main(int argc, char* argv[]) {
76 parseOptions(argc, argv);
77
78 Simulator* simu = new Simulator("simulator_real", opti_time, 90);
79 simu->SetupConnection(address, port);
80 simu->SetupUserInterface(xml_file);
81 Parser* gui = new Parser(960, 480, 640, 480, media_path, scene_file);
82
83 X4* uav_real = new X4("Drone_0", UAV_REAL_MODEL_ID);
84 SimuImu* imu = new SimuImu(uav_real, "imu", UAV_REAL_MODEL_ID,0);
85 SimuUsGL* us_gl = new SimuUsGL(uav_real, "us", UAV_REAL_MODEL_ID,0);
86 SimuCameraGL* cam_bas = new SimuCameraGL(uav_real, "bottom camera", 320, 240, 640, 0, UAV_REAL_MODEL_ID,0);
87
88 simu->RunSimu();
89
90 delete simu;
91 return 0;
92}
93
94#endif
Note: See TracBrowser for help on using the repository browser.