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

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

m

File size: 2.8 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
20using namespace TCLAP;
21using namespace std;
22using namespace flair::core;
23using namespace flair::meta;
24
25string uav_type;
26string log_path;
27int port;
28int ds3port;
29string xml_file;
30string name;
31string broadcast;
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(name);
42 manager->SetupLogger(log_path);
43 manager->SetupConnection(address,port);
44 manager->SetupUserInterface(xml_file);
45
46 Uav* drone=CreateUav(manager,name,uav_type);
47 SimpleFleet* demo=new SimpleFleet(drone,broadcast,ds3port);
48
49 demo->Start();
50 demo->Join();
51
52 delete manager;
53}
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 ValueArg<string> broadcastArg("b","broadcast","broadcast ip address and port,",true,"127.255.255.255:20001","string");
83 cmd.add( broadcastArg );
84
85 cmd.parse( argc, argv );
86
87 // Get the value parsed by each arg.
88 log_path = logsArg.getValue();
89 port=portArg.getValue();
90 ds3port=ds3portArg.getValue();
91 xml_file = xmlArg.getValue();
92 name=nameArg.getValue();
93 broadcast=broadcastArg.getValue();
94 uav_type=typeArg.getValue();
95 address=addressArg.getValue();
96
97 } catch (ArgException &e) { // catch any exceptions
98 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
99 }
100}
Note: See TracBrowser for help on using the repository browser.