[308] | 1 | // created: 2019/03/12
|
---|
| 2 | // filename: main.cpp
|
---|
| 3 | //
|
---|
| 4 | // author: Guillaume Sanahuja
|
---|
| 5 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 6 | //
|
---|
| 7 | // version: $Id: $
|
---|
| 8 | //
|
---|
| 9 | // purpose: vrpnlite, to forward it to bth for exemple
|
---|
| 10 | // usefull to reduce vrpn frame size
|
---|
| 11 | //
|
---|
| 12 | /*********************************************************************/
|
---|
| 13 |
|
---|
| 14 | #include "FrameworkManager.h"
|
---|
| 15 | #include "VrpnLite.h"
|
---|
| 16 | #include <stdio.h>
|
---|
| 17 | #include <tclap/CmdLine.h>
|
---|
| 18 |
|
---|
| 19 | using namespace TCLAP;
|
---|
| 20 | using namespace std;
|
---|
| 21 | using namespace flair::core;
|
---|
| 22 |
|
---|
| 23 | string xml_file;
|
---|
[330] | 24 | string vrpnServerAddress;
|
---|
| 25 | int gcsPort,vrpnLitePort;
|
---|
[446] | 26 | bool headless;
|
---|
[308] | 27 |
|
---|
| 28 | void parseOptions(int argc, char **argv);
|
---|
| 29 |
|
---|
| 30 | int main (int argc, char ** argv) {
|
---|
| 31 | parseOptions(argc,argv);
|
---|
| 32 |
|
---|
| 33 | FrameworkManager *manager;
|
---|
| 34 | manager = new FrameworkManager("vrpnforwarder");
|
---|
[446] | 35 | if(!headless) manager->SetupConnection("127.0.0.1", gcsPort);
|
---|
[308] | 36 | manager->SetupUserInterface(xml_file);
|
---|
| 37 |
|
---|
[330] | 38 | VrpnLite* vrpnlite=new VrpnLite(vrpnLitePort,vrpnServerAddress);
|
---|
[308] | 39 |
|
---|
| 40 | vrpnlite->Start();
|
---|
| 41 | vrpnlite->Join();
|
---|
| 42 |
|
---|
| 43 | delete manager;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | void parseOptions(int argc, char **argv) {
|
---|
| 47 | try {
|
---|
[446] | 48 | CmdLine cmd("Command description message", ' ', "0.1",false);
|
---|
[308] | 49 |
|
---|
[446] | 50 | ValueArg<int> vrpnLitePortArg("v", "vport","vrpn lite port", true,3884, "int");
|
---|
[330] | 51 | cmd.add(vrpnLitePortArg);
|
---|
[308] | 52 |
|
---|
[446] | 53 | ValueArg<string> serveraddressArg("s", "saddress","server address", true,"127.0.0.1:3883", "string");
|
---|
[308] | 54 | cmd.add(serveraddressArg);
|
---|
| 55 |
|
---|
[446] | 56 | ValueArg<int> gcsPortArg("p", "port","local port used to connect to the ground station",false, 9000, "int");
|
---|
[330] | 57 | cmd.add(gcsPortArg);
|
---|
[308] | 58 |
|
---|
[446] | 59 | ValueArg<string> xmlArg("x", "xml", "xml file", true, "./settings.xml","string");
|
---|
[308] | 60 | cmd.add(xmlArg);
|
---|
[446] | 61 |
|
---|
| 62 | ValueArg<bool> headlessArg("h", "headless", "headless mode", false, false,"bool");
|
---|
| 63 | cmd.add(headlessArg);
|
---|
[308] | 64 |
|
---|
| 65 | cmd.parse(argc, argv);
|
---|
| 66 |
|
---|
[330] | 67 | vrpnLitePort = vrpnLitePortArg.getValue();
|
---|
| 68 | vrpnServerAddress = serveraddressArg.getValue();
|
---|
| 69 | gcsPort = gcsPortArg.getValue();
|
---|
[308] | 70 | xml_file = xmlArg.getValue();
|
---|
[446] | 71 | headless = headlessArg.getValue();
|
---|
[308] | 72 |
|
---|
| 73 | } catch (ArgException &e) { // catch any exceptions
|
---|
| 74 | cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
|
---|
| 75 | }
|
---|
| 76 | }
|
---|