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