Changeset 71 in flair-src for branches


Ignore:
Timestamp:
Sep 8, 2016, 3:51:25 PM (8 years ago)
Author:
Thomas Fuhrmann
Message:

Add class for MavlinkPlanner

Location:
branches/mavlink/tools/Controller/Mavlink/src
Files:
9 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/mavlink/tools/Controller/Mavlink/src/main.cpp

    r46 r71  
    1717
    1818#include "FrameworkManager.h"
    19 #include "Mavlink_test.h"
    2019#include <stdio.h>
    2120#include <tclap/CmdLine.h>
     21
     22#include "GuiFlair.h"
     23#include "GuiGcs.h"
     24#include "Forwarder.h"
     25
     26//todo remove for tests
     27#include <iostream>
    2228
    2329using namespace TCLAP;
    2430using namespace std;
    2531using namespace flair::core;
    26 using namespace flair::sensor;
    2732
    28 string receiverAddress;
    29 int receiverPort;
    30 int port;
    31 string xml_file;
     33string xmlFile;
     34string mode;
     35string inputAddress;
     36int inputPort;
     37string outputAddress;
     38int outputPort;
     39string flairAddress;
     40int flairPort;
    3241
    3342void parseOptions(int argc, char **argv);
    3443
    3544int main(int argc, char *argv[]) {
     45  std::cout << "avant parseOptions" << std::endl;
    3646  parseOptions(argc, argv);
    3747
     48  std::cout << "parseOptions ok" << std::endl;
     49
    3850  FrameworkManager *manager;
    39   Mavlink *mavlink_handler;
     51  manager = new FrameworkManager("mavlink");
     52  manager->SetupConnection(flairAddress, flairPort);
     53  manager->SetupUserInterface(xmlFile);
    4054
    41   manager = new FrameworkManager("mavlink");
    42   manager->SetupConnection("127.0.0.1", port);
    43   manager->SetupUserInterface(xml_file);
     55  std::cout << "MavPlanner mode : " << mode << std::endl;
    4456
    45   mavlink_handler = new Mavlink(manager, "mavlink", receiverAddress,
    46                                    receiverPort);
    47 
    48   if (!manager->ErrorOccured()) {
    49     mavlink_handler->Start();
    50     mavlink_handler->Join();
     57  if(mode == "forward") {
     58    Forwarder *guiForwarder = new Forwarder(manager, "Forwarder",
     59                                           inputAddress, inputPort,
     60                                           outputAddress, outputPort);
     61    if (!manager->ErrorOccured()) {
     62      guiForwarder->Start();
     63      guiForwarder->Join();
     64    }
     65  } else {
     66    GuiInterface *guiHandler;
     67    if(mode == "flair") {
     68      guiHandler = new GuiFlair(manager, "GuiFlair");
     69    } else if (mode == "gcs") {
     70      guiHandler = new GuiGcs(manager, "GuiGcs", outputAddress, outputPort);
     71    } else {
     72      //ERROR
     73    }
     74    if (!manager->ErrorOccured()) {
     75      guiHandler->Start();
     76      guiHandler->Join();
     77    }
    5178  }
    5279
     
    5885    CmdLine cmd("Command description message", ' ', "0.1");
    5986
    60     ValueArg<string> addressArg("a", "address",
    61                                 "data receiver address (ex: uav)", true,
    62                                 "127.0.0.1:20000", "string");
    63     cmd.add(addressArg);
     87    ValueArg<string> inputAddressArg("", "inputAddress",
     88                                "input IP address", false,
     89                                "127.0.0.1", "string");
     90    cmd.add(inputAddressArg);
    6491
    65     ValueArg<int> portArg("p", "port",
    66                           "local port used to connect to the ground station",
    67                           false, 9000, "int");
    68     cmd.add(portArg);
     92    ValueArg<int> inputPortArg("", "inputPort",
     93                          "input IP port", false,
     94                          9000, "int");
     95    cmd.add(inputPortArg);
     96
     97    ValueArg<string> outputAddressArg("", "outputAddress",
     98                                      "output IP address", false,
     99                                      "127.0.0.1", "string");
     100    cmd.add(outputAddressArg);
     101
     102    ValueArg<int> outputPortArg("", "outputPort",
     103                               "output IP port", false,
     104                               9000, "int");
     105    cmd.add(outputPortArg);
     106
     107    ValueArg<string> flairAddressArg("a", "flairAddress",
     108                                      "flair IP address", true,
     109                                      "127.0.0.1", "string");
     110    cmd.add(flairAddressArg);
     111
     112    ValueArg<int> flairPortArg("p", "flairPort",
     113                               "flair IP port", true,
     114                               9000, "int");
     115    cmd.add(flairPortArg);
    69116
    70117    ValueArg<string> xmlArg("x", "xml", "xml file", true, "./settings.xml",
     
    72119    cmd.add(xmlArg);
    73120
     121    ValueArg<string> modeArg("m", "mode", "application mode (forward, flair, gcs)",
     122                             true, "flair", "string");
     123    cmd.add(modeArg);
     124
    74125    cmd.parse(argc, argv);
    75126
     127    // string receiverAddressWithPort = inputAddressArg.getValue();
     128    // int semiColonPosition = receiverAddressWithPort.find(":");
     129    // receiverAddress = receiverAddressWithPort.substr(0, semiColonPosition);
     130    // receiverPort =
     131    //     atoi(receiverAddressWithPort.substr(semiColonPosition + 1).c_str());
     132   
    76133    // Get the value parsed by each arg.
    77     string receiverAddressWithPort = addressArg.getValue();
    78     int semiColonPosition = receiverAddressWithPort.find(":");
    79     receiverAddress = receiverAddressWithPort.substr(0, semiColonPosition);
    80     receiverPort =
    81         atoi(receiverAddressWithPort.substr(semiColonPosition + 1).c_str());
    82     port = portArg.getValue();
    83     xml_file = xmlArg.getValue();
     134    inputAddress = inputAddressArg.getValue();
     135    inputPort = inputPortArg.getValue();
     136    outputAddress = outputAddressArg.getValue();
     137    outputPort = outputPortArg.getValue();
     138    flairAddress = flairAddressArg.getValue();
     139    flairPort = flairPortArg.getValue();
     140    xmlFile = xmlArg.getValue();
     141    mode = modeArg.getValue();
    84142
    85143  } catch (ArgException &e) { // catch any exceptions
Note: See TracChangeset for help on using the changeset viewer.