source: flair-src/trunk/demos/TwoWheelRobotSimpleFleet/ugv/src/main.cpp@ 397

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

add simple fleet demo for ugv

File size: 2.9 KB
RevLine 
[390]1// created: 2020/12/21
2// filename: main.cpp
3//
4// author: Guillaume Sanahuja
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: exemple de code ugv
10//
11//
12/*********************************************************************/
13
14#include "SimpleFleet.h"
15#include <FrameworkManager.h>
16#include <UgvFactory.h>
17#include <stdio.h>
18#include <tclap/CmdLine.h>
19#include <TargetEthController.h>
20
21using namespace TCLAP;
22using namespace std;
23using namespace flair::core;
24using namespace flair::meta;
25using namespace flair::sensor;
26
27string ugv_type;
28string log_path;
29int port;
30int ds3port;
31string xml_file;
32string name;
33string broadcast;
34string address;
35
36void parseOptions(int argc, char** argv);
37
38
39int main(int argc, char* argv[]) {
40 parseOptions(argc,argv);
41
42 FrameworkManager *manager;
43 manager= new FrameworkManager(name);
44 manager->SetupConnection(address,port);
45 manager->SetupUserInterface(xml_file);
46 manager->SetupLogger(log_path);
47
48 Ugv* ugv=CreateUgv(name,ugv_type);
49 TargetEthController *controller=new TargetEthController("Dualshock3",ds3port);
50 SimpleFleet* demo=new SimpleFleet(name,broadcast,controller);
51
52 demo->Start();
53 demo->Join();
54
55 delete manager;
56}
57
58void parseOptions(int argc, char** argv) {
59 try {
60
61 CmdLine cmd("Command description message", ' ', "0.1");
62
63 ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
64 cmd.add( nameArg );
65
66 ValueArg<string> typeArg("t","type","ugv type: sumo, ugv_simu or ugv_simux (with x the number of the simulated ugv)",true,"ugv_sumo","string");
67 cmd.add( typeArg );
68
69 ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
70 cmd.add( xmlArg );
71
72 ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
73 cmd.add( logsArg );
74
75 ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
76 cmd.add( portArg );
77
78 ValueArg<string> addressArg("a","address","adresse station sol",true,"127.0.0.1","string");
79 cmd.add( addressArg );
80
81 ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
82 cmd.add( ds3portArg );
83
84 ValueArg<string> broadcastArg("b","broadcast","broadcast ip address and port,",true,"127.255.255.255:20001","string");
85 cmd.add( broadcastArg );
86
87 cmd.parse( argc, argv );
88
89 // Get the value parsed by each arg.
90 log_path = logsArg.getValue();
91 port=portArg.getValue();
92 ds3port=ds3portArg.getValue();
93 xml_file = xmlArg.getValue();
94 name=nameArg.getValue();
95 broadcast=broadcastArg.getValue();
96 address=addressArg.getValue();
97 ugv_type=typeArg.getValue();
98
99 } catch (ArgException &e) { // catch any exceptions
100 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
101 exit(EXIT_FAILURE);
102 }
103}
Note: See TracBrowser for help on using the repository browser.