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 | //#include <VisionFilter.h>
|
---|
21 |
|
---|
22 | using namespace TCLAP;
|
---|
23 | using namespace std;
|
---|
24 | using namespace flair::core;
|
---|
25 | using namespace flair::meta;
|
---|
26 | using namespace flair::sensor;
|
---|
27 |
|
---|
28 | string uav_type;
|
---|
29 | string log_path;
|
---|
30 | int port;
|
---|
31 | int ds3port;
|
---|
32 | string xml_file;
|
---|
33 | string name;
|
---|
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->SetupConnection(address,port);
|
---|
45 | manager->SetupUserInterface(xml_file);
|
---|
46 | manager->SetupLogger(log_path);
|
---|
47 |
|
---|
48 | Uav* drone=CreateUav(name,uav_type);
|
---|
49 | TargetEthController *controller=new TargetEthController("Dualshock3",ds3port);
|
---|
50 | CircleFollower* demo=new CircleFollower(controller);
|
---|
51 |
|
---|
52 | demo->Start();
|
---|
53 | demo->Join();
|
---|
54 |
|
---|
55 | delete manager;
|
---|
56 | }
|
---|
57 |
|
---|
58 | void parseOptions(int argc, char** argv) {
|
---|
59 | try {
|
---|
60 |
|
---|
61 | CmdLine cmd("Command description message", ' ', "0.1");
|
---|
62 |
|
---|
63 | ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
|
---|
64 | cmd.add( nameArg );
|
---|
65 |
|
---|
66 | 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");
|
---|
67 | cmd.add( typeArg );
|
---|
68 |
|
---|
69 | ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
|
---|
70 | cmd.add( xmlArg );
|
---|
71 |
|
---|
72 | ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
|
---|
73 | cmd.add( logsArg );
|
---|
74 |
|
---|
75 | ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
|
---|
76 | cmd.add( portArg );
|
---|
77 |
|
---|
78 | ValueArg<string> addressArg("a","address","adresse station sol",true,"127.0.0.1","string");
|
---|
79 | cmd.add( addressArg );
|
---|
80 |
|
---|
81 | ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
|
---|
82 | cmd.add( ds3portArg );
|
---|
83 |
|
---|
84 | cmd.parse( argc, argv );
|
---|
85 |
|
---|
86 | // Get the value parsed by each arg.
|
---|
87 | log_path = logsArg.getValue();
|
---|
88 | port=portArg.getValue();
|
---|
89 | ds3port=ds3portArg.getValue();
|
---|
90 | xml_file = xmlArg.getValue();
|
---|
91 | name=nameArg.getValue();
|
---|
92 | uav_type=typeArg.getValue();
|
---|
93 | address=addressArg.getValue();
|
---|
94 |
|
---|
95 | } catch (ArgException &e) { // catch any exceptions
|
---|
96 | cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
|
---|
97 | exit(EXIT_FAILURE);
|
---|
98 | }
|
---|
99 | }
|
---|