source: flair-src/trunk/demos/TwoWheelRobotSimpleFleet/simulator/src/main.cpp@ 390

Last change on this file since 390 was 390, checked in by Sanahuja Guillaume, 2 years ago

add simple fleet demo for 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#endif
20
21using namespace TCLAP;
22using namespace std;
23using namespace flair::simulator;
24using namespace flair::sensor;
25
26int port;
27int opti_time;
28string xml_file;
29string media_path;
30string scene_file;
31string name;
32string address;
33
34void parseOptions(int argc, char** argv)
35{
36 try {
37 CmdLine cmd("Command description message", ' ', "0.1");
38
39 ValueArg<string> nameArg("n", "name", "uav name, also used for vrpn", true, "x4", "string");
40 cmd.add(nameArg);
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#ifdef GL
55 ValueArg<string> mediaArg("m", "media", "path to media files", true, "./", "string");
56 cmd.add(mediaArg);
57
58 ValueArg<string> sceneArg("s", "scene", "path to scene file", true, "./voliere.xml", "string");
59 cmd.add(sceneArg);
60#endif
61
62 cmd.parse(argc, argv);
63
64 // Get the value parsed by each arg.
65 port = portArg.getValue();
66 xml_file = xmlArg.getValue();
67 opti_time = optiArg.getValue();
68 name = nameArg.getValue();
69 address = addressArg.getValue();
70#ifdef GL
71 media_path = mediaArg.getValue();
72 scene_file = sceneArg.getValue();
73#endif
74
75 } catch(ArgException& e) {
76 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
77 exit(EXIT_FAILURE);
78 }
79}
80
81int main(int argc, char* argv[]) {
82 Simulator* simu;
83#ifdef GL
84 Parser* gui;
85#endif
86 parseOptions(argc, argv);
87
88 simu = new Simulator("simulator", opti_time, 90);
89 simu->SetupConnection(address, port);
90 simu->SetupUserInterface(xml_file);
91
92#ifdef GL
93 gui = new Parser(960, 480, 960, 480, media_path, scene_file);
94#endif
95 for(int i=0; i<2;i++) {
96 stringstream ugvName;
97 Model *robot;
98 ugvName << name.c_str() << "_" << i;
99 robot = new TwoWheelRobot(ugvName.str(), i);
100 }
101
102 simu->RunSimu();
103
104 delete simu;
105
106 return 0;
107}
108
Note: See TracBrowser for help on using the repository browser.