source: flair-src/branches/sanscv/demos/MixedReality/virtual/uav/src/main.cpp@ 464

Last change on this file since 464 was 324, checked in by Sanahuja Guillaume, 5 years ago

removing opencv dependency

File size: 2.5 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 uav
10//
11//
12/*********************************************************************/
13
14#include "App.h"
15#include <UavFactory.h>
16#include <FrameworkManager.h>
17#include <stdio.h>
18#include <tclap/CmdLine.h>
19#include <TargetEthController.h>
20
21using namespace TCLAP;
22using namespace std;
23using namespace flair::core;
24using namespace flair::meta;
25using namespace flair::sensor;
26
27string uav_type;
28string log_path;
29int port;
30int ds3port;
31string xml_file;
32string address;
33
34void parseOptions(int argc, char** argv);
35
36
37int main(int argc, char* argv[]) {
38 parseOptions(argc,argv);
39
40 FrameworkManager *manager;
41 manager= new FrameworkManager("Drone_1");
42 manager->SetupConnection(address,port);
43 manager->SetupUserInterface(xml_file);
44 manager->SetupLogger(log_path);
45
46 Uav* drone=CreateUav("Drone_1",uav_type);
47 TargetEthController *controller=new TargetEthController("Dualshock3",ds3port);
48 App* demo=new App(controller);
49
50 demo->Start();
51 demo->Join();
52
53 delete manager;
54}
55
56void parseOptions(int argc, char** argv) {
57 try {
58
59 CmdLine cmd("Command description message", ' ', "0.1");
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","adresse station sol",true,"127.0.0.1","string");
74 cmd.add( addressArg );
75
76 ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
77 cmd.add( ds3portArg );
78
79 cmd.parse( argc, argv );
80
81 // Get the value parsed by each arg.
82 log_path = logsArg.getValue();
83 port=portArg.getValue();
84 ds3port=ds3portArg.getValue();
85 xml_file = xmlArg.getValue();
86 uav_type=typeArg.getValue();
87 address=addressArg.getValue();
88
89 } catch (ArgException &e) { // catch any exceptions
90 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
91 exit(EXIT_FAILURE);
92 }
93}
Note: See TracBrowser for help on using the repository browser.