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 |
|
---|
21 | using namespace TCLAP;
|
---|
22 | using namespace std;
|
---|
23 | using namespace flair::core;
|
---|
24 | using namespace flair::meta;
|
---|
25 | using namespace flair::sensor;
|
---|
26 |
|
---|
27 | string ugv_type;
|
---|
28 | string log_path;
|
---|
29 | int port;
|
---|
30 | int ds3port;
|
---|
31 | string xml_file;
|
---|
32 | string name;
|
---|
33 | string broadcast;
|
---|
34 | string address;
|
---|
35 |
|
---|
36 | void parseOptions(int argc, char** argv);
|
---|
37 |
|
---|
38 |
|
---|
39 | int 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 |
|
---|
58 | void 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 | }
|
---|