source: flair-src/trunk/demos/MixedReality/simulator_simu/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.9 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#include <UavVrpnObject.h>
23#include <VrpnClient.h>
24
25#define UAV_SIMU_MODEL_ID 1
26
27using namespace TCLAP;
28using namespace std;
29using namespace flair::simulator;
30using namespace flair::sensor;
31
32int port;
33int opti_time;
34string xml_file;
35string media_path;
36string scene_file;
37string address;
38string vrpn;
39
40void parseOptions(int argc, char** argv)
41{
42 try {
43 CmdLine cmd("Command description message", ' ', "0.1");
44
45 ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string");
46 cmd.add(xmlArg);
47
48 ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int");
49 cmd.add(portArg);
50
51 ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string");
52 cmd.add(addressArg);
53
54 ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int");
55 cmd.add(optiArg);
56
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
63 ValueArg<string> vrpnArg("v","vrpn","simu vrpn address and port",true,"127.0.0.1:3884","string");
64 cmd.add( vrpnArg );
65
66 cmd.parse(argc, argv);
67
68 // Get the value parsed by each arg.
69 port = portArg.getValue();
70 xml_file = xmlArg.getValue();
71 opti_time = optiArg.getValue();
72 address = addressArg.getValue();
73 media_path = mediaArg.getValue();
74 scene_file = sceneArg.getValue();
75 vrpn=vrpnArg.getValue();
76
77 } catch(ArgException& e) {
78 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
79 exit(EXIT_FAILURE);
80 }
81}
82
83int main(int argc, char* argv[]) {
84 parseOptions(argc, argv);
85
86 Simulator* simu = new Simulator("simulator_simu", opti_time, 90,3884);
87 simu->SetupConnection(address, port);
88 simu->SetupUserInterface(xml_file);
89 Parser*gui = new Parser(960, 480, 640, 480, media_path, scene_file);
90
91 X4* uav_simu = new X4("Drone_1", UAV_SIMU_MODEL_ID);
92 SimuImu* imu = new SimuImu(uav_simu, "imu", UAV_SIMU_MODEL_ID,0);
93 SimuUsGL* us_gl = new SimuUsGL(uav_simu, "us", UAV_SIMU_MODEL_ID,0);
94 SimuCameraGL* cam_bas = new SimuCameraGL(uav_simu, "bottom camera", 320, 240, 640, 0,UAV_SIMU_MODEL_ID,0);
95
96 VrpnClient* vrpnclient=new VrpnClient("vrpn", vrpn,80);//simu_real or real vrpn server
97 UavVrpnObject* uav_real=new UavVrpnObject("Drone_0",vrpnclient);
98
99 vrpnclient->Start();
100 simu->RunSimu();
101
102 delete simu;
103 return 0;
104}
105
106#endif
Note: See TracBrowser for help on using the repository browser.