source: flair-src/trunk/demos/SimpleFleet/uav/src/main.cpp@ 420

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

add exit failure

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 uav
10//
11//
12/*********************************************************************/
13
14#include "SimpleFleet.h"
15#include <FrameworkManager.h>
16#include <UavFactory.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 name;
33string broadcast;
34string address;
35
36void parseOptions(int argc, char** argv);
37
38
39int main(int argc, char* argv[]) {
40 parseOptions(argc,argv);
41
42 FrameworkManager *manager;
43 manager= new FrameworkManager(name);
44 manager->SetupLogger(log_path);
45 manager->SetupConnection(address,port);
46 manager->SetupUserInterface(xml_file);
47
48 Uav* drone=CreateUav(name,uav_type);
49 TargetEthController *controller=new TargetEthController("Dualshock3",ds3port);
50 SimpleFleet* demo=new SimpleFleet(broadcast,controller);
51
52 demo->Start();
53 demo->Join();
54
55 delete manager;
56}
57
58
59void parseOptions(int argc, char** argv) {
60 try {
61
62 CmdLine cmd("Command description message", ' ', "0.1");
63
64 ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
65 cmd.add( nameArg );
66
67 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");
68 cmd.add( typeArg );
69
70 ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
71 cmd.add( xmlArg );
72
73 ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
74 cmd.add( logsArg );
75
76 ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
77 cmd.add( portArg );
78
79 ValueArg<string> addressArg("a","address","addresse station sol",true,"127.0.0.1","string");
80 cmd.add( addressArg );
81
82 ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
83 cmd.add( ds3portArg );
84
85 ValueArg<string> broadcastArg("b","broadcast","broadcast ip address and port,",true,"127.255.255.255:20001","string");
86 cmd.add( broadcastArg );
87
88 cmd.parse( argc, argv );
89
90 // Get the value parsed by each arg.
91 log_path = logsArg.getValue();
92 port=portArg.getValue();
93 ds3port=ds3portArg.getValue();
94 xml_file = xmlArg.getValue();
95 name=nameArg.getValue();
96 broadcast=broadcastArg.getValue();
97 uav_type=typeArg.getValue();
98 address=addressArg.getValue();
99
100 } catch (ArgException &e) { // catch any exceptions
101 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
102 exit(EXIT_FAILURE);
103 }
104}
Note: See TracBrowser for help on using the repository browser.