source: flair-src/trunk/demos/CircleFollower/simulator/src/main.cpp

Last change on this file was 334, checked in by Sanahuja Guillaume, 2 years ago

misc

File size: 3.0 KB
RevLine 
[21]1//  created:    2012/04/18
2//  filename:   main.cpp
3//
4//  author:     Guillaume Sanahuja
5//              Copyright Heudiasyc UMR UTC/CNRS 6599
6//
7//  version:    $Id: $
8//
9//  purpose:    main simulateur
10//
11//
12/*********************************************************************/
13
14#include <tclap/CmdLine.h>
15#include <Simulator.h>
16#include <X4.h>
17#include <X8.h>
18#include <SimuImu.h>
19#ifdef GL
20#include <Parser.h>
21#include <Man.h>
22#include <SimuUsGL.h>
[240]23#include <SimuCameraGL.h>
[21]24#endif
25
26using namespace TCLAP;
27using namespace std;
[23]28using namespace flair::simulator;
29using namespace flair::sensor;
[21]30
31int port;
32int opti_time;
33string xml_file;
34string media_path;
35string scene_file;
36string type;
37string name;
38string address;
39
[158]40void parseOptions(int argc, char** argv)
41{
42  try {
43    CmdLine cmd("Command description message", ' ', "0.1");
[21]44
[158]45    ValueArg<string> nameArg("n", "name", "uav name, also used for vrpn", true, "x4", "string");
46    cmd.add(nameArg);
[21]47
[158]48    ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string");
49    cmd.add(xmlArg);
[21]50
[158]51    ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int");
52    cmd.add(portArg);
[21]53
[158]54    ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string");
55    cmd.add(addressArg);
[21]56
[158]57    ValueArg<string> typeArg("t", "type", "uav type, x4 or x8", true, "x4", "string");
58    cmd.add(typeArg);
[21]59
[158]60    ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int");
61    cmd.add(optiArg);
[21]62
63#ifdef GL
[158]64    ValueArg<string> mediaArg("m", "media", "path to media files", true, "./", "string");
65    cmd.add(mediaArg);
[21]66
[158]67    ValueArg<string> sceneArg("s", "scene", "path to scene file", true, "./voliere.xml", "string");
68    cmd.add(sceneArg);
[21]69#endif
70
[158]71    cmd.parse(argc, argv);
[21]72
[158]73    // Get the value parsed by each arg.
74    port = portArg.getValue();
75    xml_file = xmlArg.getValue();
76    opti_time = optiArg.getValue();
77    type = typeArg.getValue();
78    name = nameArg.getValue();
79    address = addressArg.getValue();
[21]80#ifdef GL
[158]81    media_path = mediaArg.getValue();
82    scene_file = sceneArg.getValue();
[21]83#endif
84
[158]85  } catch(ArgException& e) {
86    cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
[291]87    exit(EXIT_FAILURE);
[158]88  }
[21]89}
90
[334]91int main(int argc, char* argv[]) {
[158]92  Simulator* simu;
93  Model* drone;
94  SimuImu* imu;
[21]95#ifdef GL
[158]96  SimuUsGL* us_gl;
[240]97  SimuCameraGL* cam_bas;
[158]98  Parser* gui;
99  Man* man;
[21]100#endif
[158]101  parseOptions(argc, argv);
[21]102
[158]103  simu = new Simulator("simulator", opti_time, 90);
104  simu->SetupConnection(address, port);
105  simu->SetupUserInterface(xml_file);
[21]106
107#ifdef GL
[240]108  gui = new Parser(960, 480, 640, 480, media_path, scene_file);
[21]109#endif
110
[158]111  if(type == "x4") {
112    drone = new X4(name, 0);
113  } else {
114    drone = new X8(name, 0);
115  }
[21]116
[158]117  imu = new SimuImu(drone, "imu", 0,0);
[21]118
119#ifdef GL
[158]120  us_gl = new SimuUsGL(drone, "us", 0,0);
[240]121  cam_bas = new SimuCameraGL(drone, "bottom camera", 320, 240, 640, 0, 0,0);
[21]122
[158]123  man = new Man("target",1);
[21]124#endif
125
[158]126  simu->RunSimu();
[21]127
[158]128  delete simu;
[21]129
[158]130  return 0;
[21]131}
[228]132
Note: See TracBrowser for help on using the repository browser.