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 |
|
---|
22 | using namespace TCLAP;
|
---|
23 | using namespace std;
|
---|
24 | using namespace flair::simulator;
|
---|
25 | using namespace flair::sensor;
|
---|
26 |
|
---|
27 | int port;
|
---|
28 | int opti_time;
|
---|
29 | string xml_file;
|
---|
30 | string media_path;
|
---|
31 | string scene_file;
|
---|
32 | string name;
|
---|
33 | string address;
|
---|
34 |
|
---|
35 | void 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 |
|
---|
82 | int 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 |
|
---|