source: flair-src/trunk/demos/CircleFollower/uav/src/main.cpp@ 30

Last change on this file since 30 was 23, checked in by Sanahuja Guillaume, 9 years ago

igep to flair

File size: 2.4 KB
RevLine 
[21]1// created: 2011/05/01
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 uav
10//
11//
12/*********************************************************************/
13
14#include "CircleFollower.h"
15#include <UavFactory.h>
16#include <FrameworkManager.h>
17#include <stdio.h>
18#include <tclap/CmdLine.h>
19
20using namespace TCLAP;
21using namespace std;
[23]22using namespace flair::core;
23using namespace flair::meta;
[21]24
25string uav_type;
26string log_path;
27int port;
28string xml_file;
29string name;
30string address;
31
32void parseOptions(int argc, char** argv);
33
34
35int main(int argc, char* argv[]) {
36 parseOptions(argc,argv);
37
38 FrameworkManager *manager;
39 manager= new FrameworkManager(name);
40 manager->SetupConnection(address,port);
41 manager->SetupUserInterface(xml_file);
42 manager->SetupLogger(log_path);
43
44 Uav* drone=CreateUav(manager,name,uav_type);
45 CircleFollower* demo=new CircleFollower(drone);
46
47 demo->Start();
48 demo->Join();
49
50 delete manager;
51}
52
53void parseOptions(int argc, char** argv) {
54 try {
55
56 CmdLine cmd("Command description message", ' ', "0.1");
57
58 ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
59 cmd.add( nameArg );
60
61 ValueArg<string> typeArg("t","type","uav type: ardrone2, hds_x4, hds_x8, hds_xufo, x4_simu, x8_simu or x4_simux (with x the number of the simulated uav)",true,"hds_x4","string");
62 cmd.add( typeArg );
63
64 ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
65 cmd.add( xmlArg );
66
67 ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
68 cmd.add( logsArg );
69
70 ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
71 cmd.add( portArg );
72
73 ValueArg<string> addressArg("a","address","addresse station sol",true,"127.0.0.1","string");
74 cmd.add( addressArg );
75
76 cmd.parse( argc, argv );
77
78 // Get the value parsed by each arg.
79 log_path = logsArg.getValue();
80 port=portArg.getValue();
81 xml_file = xmlArg.getValue();
82 name=nameArg.getValue();
83 uav_type=typeArg.getValue();
84 address=addressArg.getValue();
85
86 } catch (ArgException &e) { // catch any exceptions
87 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
88 }
89}
Note: See TracBrowser for help on using the repository browser.