source: flair-src/trunk/demos/CircleFollower/simulator/src/main.cpp@ 174

Last change on this file since 174 was 158, checked in by Sanahuja Guillaume, 7 years ago

corrected simu/device id for sensors

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