source: flair-src/trunk/demos/TwoWheelRobotCircleFollower/simulator/src/main.cpp@ 377

Last change on this file since 377 was 375, checked in by Sanahuja Guillaume, 4 years ago

update ugv

File size: 2.5 KB
Line 
1// created: 2020/11/20
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 <TwoWheelRobot.h>
17#ifdef GL
18#include <Parser.h>
19#include <Man.h>
20#endif
21
22using namespace TCLAP;
23using namespace std;
24using namespace flair::simulator;
25using namespace flair::sensor;
26
27int port;
28int opti_time;
29string xml_file;
30string media_path;
31string scene_file;
32string name;
33string address;
34
35void parseOptions(int argc, char** argv)
36{
37 try {
38 CmdLine cmd("Command description message", ' ', "0.1");
39
40 ValueArg<string> nameArg("n", "name", "uav name, also used for vrpn", true, "x4", "string");
41 cmd.add(nameArg);
42
43 ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string");
44 cmd.add(xmlArg);
45
46 ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int");
47 cmd.add(portArg);
48
49 ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string");
50 cmd.add(addressArg);
51
52 ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int");
53 cmd.add(optiArg);
54
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
63 cmd.parse(argc, argv);
64
65 // Get the value parsed by each arg.
66 port = portArg.getValue();
67 xml_file = xmlArg.getValue();
68 opti_time = optiArg.getValue();
69 name = nameArg.getValue();
70 address = addressArg.getValue();
71#ifdef GL
72 media_path = mediaArg.getValue();
73 scene_file = sceneArg.getValue();
74#endif
75
76 } catch(ArgException& e) {
77 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
78 exit(EXIT_FAILURE);
79 }
80}
81
82int main(int argc, char* argv[]) {
83 Simulator* simu;
84 Model* robot;
85#ifdef GL
86 Parser* gui;
87 Man* man;
88#endif
89 parseOptions(argc, argv);
90
91 simu = new Simulator("simulator", opti_time, 90);
92 simu->SetupConnection(address, port);
93 simu->SetupUserInterface(xml_file);
94
95#ifdef GL
96 gui = new Parser(960, 480, 960, 480, media_path, scene_file);
97#endif
98
99
100 robot = new TwoWheelRobot(name, 0);
101
102
103#ifdef GL
104 //man = new Man("target",1);
105#endif
106
107 simu->RunSimu();
108
109 delete simu;
110
111 return 0;
112}
113
Note: See TracBrowser for help on using the repository browser.