source: flair-src/trunk/demos/OpticalFlow/uav/src/main.cpp@ 122

Last change on this file since 122 was 122, checked in by Sanahuja Guillaume, 6 years ago

modifs uav vrpn i686

File size: 2.9 KB
Line 
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 x4
10//
11//
12/*********************************************************************/
13
14#include "DemoOpticalFlow.h"
15#include <UavFactory.h>
16#include <FrameworkManager.h>
17#include <stdio.h>
18#include <tclap/CmdLine.h>
19#include <TargetEthController.h>
20#include <init.h>
21
22using namespace TCLAP;
23using namespace std;
24using namespace flair::core;
25using namespace flair::meta;
26using namespace flair::sensor;
27
28string uav_type;
29string dsp_file;
30string log_path;
31int port;
32int ds3port;
33string xml_file;
34string name;
35string address;
36
37void parseOptions(int argc, char** argv);
38
39
40int main(int argc, char* argv[]) {
41 parseOptions(argc,argv);
42
43 FrameworkManager *manager;
44 manager= new FrameworkManager(name);
45 manager->SetupConnection(address,port);
46 manager->SetupUserInterface(xml_file);
47 manager->SetupLogger(log_path);
48 SetupDSP(dsp_file);
49
50 Uav* drone=CreateUav(name,uav_type);
51 TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
52 DemoOpticalFlow* demo=new DemoOpticalFlow(controller);
53
54 demo->Start();
55 demo->Join();
56
57 delete manager;
58
59 CloseDSP();
60}
61
62void parseOptions(int argc, char** argv)
63{
64 try
65 {
66
67 CmdLine cmd("Command description message", ' ', "0.1");
68
69 ValueArg<string> nameArg("n","name","uav name",true,"x4","string");
70 cmd.add( nameArg );
71
72 ValueArg<string> typeArg("t","type","uav type: ardrone2, hds_x4, hds_x8, hds_xufo, hds_simu or hds_simux (with x the number of the simulated uav)",true,"hds_x4","string");
73 cmd.add( typeArg );
74
75 ValueArg<string> dspArg("v","dsp","executable dsp",true,"./dspcv_dsp.out","string");
76 cmd.add( dspArg );
77
78 ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
79 cmd.add( xmlArg );
80
81 ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
82 cmd.add( logsArg );
83
84 ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
85 cmd.add( portArg );
86
87 ValueArg<string> addressArg("a","address","addresse station sol",true,"127.0.0.1","string");
88 cmd.add( addressArg );
89
90 ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
91 cmd.add( ds3portArg );
92
93 cmd.parse( argc, argv );
94
95 // Get the value parsed by each arg.
96 uav_type=typeArg.getValue();
97 dsp_file = dspArg.getValue();
98 log_path = logsArg.getValue();
99 port=portArg.getValue();
100 ds3port=ds3portArg.getValue();
101 xml_file = xmlArg.getValue();
102 name=nameArg.getValue();
103 address=addressArg.getValue();
104
105 } catch (ArgException &e) // catch any exceptions
106 { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; }
107}
Note: See TracBrowser for help on using the repository browser.