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 |
|
---|
21 | using namespace TCLAP;
|
---|
22 | using namespace std;
|
---|
23 | using namespace flair::core;
|
---|
24 | using namespace flair::meta;
|
---|
25 | using namespace flair::sensor;
|
---|
26 |
|
---|
27 | string uav_type;
|
---|
28 | string log_path;
|
---|
29 | int port;
|
---|
30 | int ds3port;
|
---|
31 | string xml_file;
|
---|
32 | string name;
|
---|
33 | string broadcast;
|
---|
34 | string address;
|
---|
35 |
|
---|
36 | void parseOptions(int argc, char** argv);
|
---|
37 |
|
---|
38 |
|
---|
39 | int 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(manager,"Dualshock3",ds3port);
|
---|
50 | SimpleFleet* demo=new SimpleFleet(broadcast,controller);
|
---|
51 |
|
---|
52 | demo->Start();
|
---|
53 | demo->Join();
|
---|
54 |
|
---|
55 | delete manager;
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | void 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 | }
|
---|
103 | }
|
---|