[21] | 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>
|
---|
[38] | 19 | #include <TargetEthController.h>
|
---|
[263] | 20 | //#include <VisionFilter.h>
|
---|
[21] | 21 |
|
---|
| 22 | using namespace TCLAP;
|
---|
| 23 | using namespace std;
|
---|
[23] | 24 | using namespace flair::core;
|
---|
| 25 | using namespace flair::meta;
|
---|
[38] | 26 | using namespace flair::sensor;
|
---|
[21] | 27 |
|
---|
| 28 | string uav_type;
|
---|
| 29 | string log_path;
|
---|
| 30 | int port;
|
---|
[38] | 31 | int ds3port;
|
---|
[21] | 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 |
|
---|
[122] | 48 | Uav* drone=CreateUav(name,uav_type);
|
---|
[137] | 49 | TargetEthController *controller=new TargetEthController("Dualshock3",ds3port);
|
---|
[122] | 50 | CircleFollower* demo=new CircleFollower(controller);
|
---|
[21] | 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 |
|
---|
[232] | 78 | ValueArg<string> addressArg("a","address","adresse station sol",true,"127.0.0.1","string");
|
---|
[21] | 79 | cmd.add( addressArg );
|
---|
| 80 |
|
---|
[38] | 81 | ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
|
---|
| 82 | cmd.add( ds3portArg );
|
---|
| 83 |
|
---|
[21] | 84 | cmd.parse( argc, argv );
|
---|
| 85 |
|
---|
| 86 | // Get the value parsed by each arg.
|
---|
| 87 | log_path = logsArg.getValue();
|
---|
| 88 | port=portArg.getValue();
|
---|
[38] | 89 | ds3port=ds3portArg.getValue();
|
---|
[21] | 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 | }
|
---|
| 98 | }
|
---|