source: flair-src/trunk/demos/Skeletons/CustomReferenceAngles/src/main.cpp@ 132

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

modifs uav vrpn i686

File size: 2.7 KB
RevLine 
[43]1// created: 2015/10/27
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 "MyApp.h"
15#include <UavFactory.h>
16#include <FrameworkManager.h>
17#include <TargetEthController.h>
18#include <stdio.h>
19#include <tclap/CmdLine.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 name;
33string address;
34
35void parseOptions(int argc, char** argv);
36
37int main(int argc, char* argv[]) {
38 parseOptions(argc,argv);
39
40 FrameworkManager *manager;
41 manager= new FrameworkManager(name);
42 manager->SetupConnection(address,port);
43 manager->SetupUserInterface(xml_file);
44 manager->SetupLogger(log_path);
45
[122]46 Uav* drone=CreateUav(name,uav_type);
[43]47 TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
[122]48 MyApp* app=new MyApp(controller);
[43]49
50 app->Start();
51 app->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> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
62 cmd.add( nameArg );
63
64 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");
65 cmd.add( typeArg );
66
67 ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
68 cmd.add( xmlArg );
69
70 ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
71 cmd.add( logsArg );
72
73 ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
74 cmd.add( portArg );
75
76 ValueArg<string> addressArg("a","address","addresse station sol",true,"127.0.0.1","string");
77 cmd.add( addressArg );
78
79 ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
80 cmd.add( ds3portArg );
81
82 cmd.parse( argc, argv );
83
84 // Get the value parsed by each arg.
85 log_path = logsArg.getValue();
86 port=portArg.getValue();
87 ds3port=ds3portArg.getValue();
88 xml_file = xmlArg.getValue();
89 name=nameArg.getValue();
90 uav_type=typeArg.getValue();
91 address=addressArg.getValue();
92
93 } catch (ArgException &e) { // catch any exceptions
94 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
95 }
96}
Note: See TracBrowser for help on using the repository browser.