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

Last change on this file since 376 was 376, checked in by Sanahuja Guillaume, 9 months ago

up ugv

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