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

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

add exit failure

File size: 3.0 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 <VisionFilter.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 if(!InitVisionFilter("file="+dsp_file)) {
44 exit(1);
45 }
46
47 FrameworkManager *manager;
48 manager= new FrameworkManager(name);
49 manager->SetupConnection(address,port);
50 manager->SetupUserInterface(xml_file);
51 manager->SetupLogger(log_path);
52
53 Uav* drone=CreateUav(name,uav_type);
54 TargetEthController *controller=new TargetEthController("Dualshock3",ds3port);
55 DemoOpticalFlow* demo=new DemoOpticalFlow(controller);
56
57 demo->Start();
58 demo->Join();
59
60 delete manager;
61
62 CloseVisionFilter();
63}
64
65void parseOptions(int argc, char** argv)
66{
67 try
68 {
69
70 CmdLine cmd("Command description message", ' ', "0.1");
71
72 ValueArg<string> nameArg("n","name","uav name",true,"x4","string");
73 cmd.add( nameArg );
74
75 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");
76 cmd.add( typeArg );
77
78 ValueArg<string> dspArg("v","dsp","executable dsp",true,"./dspcv_dsp.out","string");
79 cmd.add( dspArg );
80
81 ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
82 cmd.add( xmlArg );
83
84 ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
85 cmd.add( logsArg );
86
87 ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
88 cmd.add( portArg );
89
90 ValueArg<string> addressArg("a","address","addresse station sol",true,"127.0.0.1","string");
91 cmd.add( addressArg );
92
93 ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
94 cmd.add( ds3portArg );
95
96 cmd.parse( argc, argv );
97
98 // Get the value parsed by each arg.
99 uav_type=typeArg.getValue();
100 dsp_file = dspArg.getValue();
101 log_path = logsArg.getValue();
102 port=portArg.getValue();
103 ds3port=ds3portArg.getValue();
104 xml_file = xmlArg.getValue();
105 name=nameArg.getValue();
106 address=addressArg.getValue();
107
108 } catch (ArgException &e) {
109 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
110 exit(EXIT_FAILURE);
111 }
112}
Note: See TracBrowser for help on using the repository browser.