source: flair-src/trunk/demos/PidStandalone/uav/src/main.cpp@ 269

Last change on this file since 269 was 236, checked in by Sanahuja Guillaume, 7 years ago

change build directories for new architecture

File size: 3.6 KB
RevLine 
[44]1// created: 2016/06/01
2// filename: main.cpp
3//
4// author: Gildas Bayard
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: exemple de code x4
10//
11//
12/*********************************************************************/
13
14#include "PidUav.h"
15#include <UavFactory.h>
16#include <FrameworkManager.h>
17#include <stdio.h>
18#include <tclap/CmdLine.h>
19#include <TargetEthController.h>
20#include <EmulatedController.h>
21
22using namespace TCLAP;
23using namespace std;
[105]24using namespace flair::core;
25using namespace flair::meta;
26using namespace flair::sensor;
[44]27
28string uav_type;
29string dsp_file;
30string log_path;
31bool headless;
32int port;
33string xml_file;
34string name;
35string address;
36
[105]37void parseOptions(int argc, char **argv);
[44]38
[105]39int main(int argc, char *argv[]) {
40 parseOptions(argc, argv);
[44]41
[105]42 FrameworkManager *manager;
43 manager = new FrameworkManager(name);
44 if (!headless) {
45 manager->SetupConnection(address, port);
46 }
47 manager->SetupUserInterface(xml_file);
48 manager->SetupLogger(log_path);
[44]49
[236]50 Uav *drone = CreateUav(name, uav_type);
[105]51 TargetEthController *controller =
[236]52 new TargetEthController("Dualshock3", 20000);
[105]53 // EmulatedController *controller=new EmulatedController(manager,"Emulated
54 // Controller");
55 // controller->AddStep(10000,"Waiting for AHRS
56 // stabilization",0,0.,0.,0.,0.);
57 // controller->AddStep(500,"Takeoff",(uint16_t)EmulatedController::ButtonType::start,0.,0.,0.,0.);
58 // controller->AddStep(3000,"Waiting for flight
59 // stabilization",0,0.,0.,0.,0.);
60 /* controller->AddStep(2000,"fly left",0,-0.3,0.,0.,0.);
61 controller->AddStep(1000,"fly right",0,0.3,0.,0.,0.);*/
62 // controller->AddStep(500,"Land",(uint16_t)EmulatedController::ButtonType::start,0.,0.,0.,0.);
63 // controller->AddStep(3000,"Waiting for landing",0,0.,0.,0.,0.);
64 // controller->AddStep(500,"Stop",(uint16_t)EmulatedController::ButtonType::select,0.,0.,0.,0.);
65 PidUav *app = new PidUav(drone, controller);
[44]66
[105]67 app->Start();
68 app->Join();
[44]69
[105]70 delete manager;
[44]71}
72
[105]73void parseOptions(int argc, char **argv) {
74 try {
[44]75
[105]76 CmdLine cmd("Command description message", ' ', "0.1");
[44]77
[105]78 ValueArg<string> nameArg("n", "name", "uav name", true, "x4", "string");
79 cmd.add(nameArg);
[44]80
[105]81 ValueArg<string> typeArg(
82 "t", "type", "uav type: ardrone2, hds_x4, hds_x8, hds_xufo, hds_simu "
83 "or hds_simux (with x the number of the simulated uav)",
84 true, "hds_x4", "string");
85 cmd.add(typeArg);
[44]86
[105]87 ValueArg<string> xmlArg("x", "xml", "fichier xml", true, "./reglages.xml",
88 "string");
89 cmd.add(xmlArg);
[44]90
[105]91 ValueArg<string> logsArg("l", "logs", "repertoire des logs", true,
92 "/media/ram", "string");
93 cmd.add(logsArg);
[44]94
[105]95 ValueArg<int> portArg("p", "port", "port pour station sol", true, 9000,
96 "int");
97 cmd.add(portArg);
[44]98
[105]99 ValueArg<string> addressArg("a", "address", "addresse station sol", true,
100 "127.0.0.1", "string");
101 cmd.add(addressArg);
[44]102
[105]103 SwitchArg headlessArg("e", "headless", "headless mode", false);
104 cmd.add(headlessArg);
[44]105
[105]106 cmd.parse(argc, argv);
[44]107
[105]108 // Get the value parsed by each arg.
109 uav_type = typeArg.getValue();
110 log_path = logsArg.getValue();
111 port = portArg.getValue();
112 xml_file = xmlArg.getValue();
113 name = nameArg.getValue();
114 address = addressArg.getValue();
115 headless = headlessArg.getValue();
[44]116
[105]117 } catch (ArgException &e) // catch any exceptions
118 {
119 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
120 }
[44]121}
Note: See TracBrowser for help on using the repository browser.