source: flair-src/trunk/demos/TwoWheelRobotCircleFollower/ugv/src/main.cpp@ 380

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

ugv update

  • Property svn:eol-style set to native
File size: 2.7 KB
RevLine 
[376]1// created: 2020/12/09
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 "CircleFollower.h"
15#include <FrameworkManager.h>
[377]16#include <UgvFactory.h>
[376]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
[377]27string ugv_type;
[376]28string log_path;
29int port;
30int ds3port;
31string xml_file;
32string name;
33string address;
34
35void parseOptions(int argc, char** argv);
36
37
38int main(int argc, char* argv[]) {
39 parseOptions(argc,argv);
40
41 FrameworkManager *manager;
42 manager= new FrameworkManager(name);
43 manager->SetupConnection(address,port);
44 manager->SetupUserInterface(xml_file);
45 manager->SetupLogger(log_path);
46
[377]47 Ugv* ugv=CreateUgv(name,ugv_type);
[376]48 TargetEthController *controller=new TargetEthController("Dualshock3",ds3port);
49 CircleFollower* demo=new CircleFollower(name,controller);
50
51 demo->Start();
52 demo->Join();
53
54 delete manager;
55}
56
57void parseOptions(int argc, char** argv) {
58 try {
59
60 CmdLine cmd("Command description message", ' ', "0.1");
61
62 ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
63 cmd.add( nameArg );
[377]64
65 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");
66 cmd.add( typeArg );
[376]67
68 ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
69 cmd.add( xmlArg );
70
71 ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
72 cmd.add( logsArg );
73
74 ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
75 cmd.add( portArg );
76
77 ValueArg<string> addressArg("a","address","adresse station sol",true,"127.0.0.1","string");
78 cmd.add( addressArg );
79
80 ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
81 cmd.add( ds3portArg );
82
83 cmd.parse( argc, argv );
84
85 // Get the value parsed by each arg.
86 log_path = logsArg.getValue();
87 port=portArg.getValue();
88 ds3port=ds3portArg.getValue();
89 xml_file = xmlArg.getValue();
90 name=nameArg.getValue();
91 address=addressArg.getValue();
[377]92 ugv_type=typeArg.getValue();
[376]93
94 } catch (ArgException &e) { // catch any exceptions
95 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
96 exit(EXIT_FAILURE);
97 }
98}
Note: See TracBrowser for help on using the repository browser.