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

Last change on this file since 248 was 239, checked in by Bayard Gildas, 7 years ago

tests

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