Changeset 158 in flair-src for trunk/demos/Gps/simulator


Ignore:
Timestamp:
Mar 5, 2017, 10:50:56 AM (8 years ago)
Author:
Sanahuja Guillaume
Message:

corrected simu/device id for sensors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/Gps/simulator/src/main.cpp

    r123 r158  
    2424#endif
    2525
    26 
    2726using namespace TCLAP;
    2827using namespace std;
     
    3938string address;
    4039
    41 void parseOptions(int argc, char** argv) {
    42         try {
    43         CmdLine cmd("Command description message", ' ', "0.1");
     40void parseOptions(int argc, char** argv)
     41{
     42  try {
     43    CmdLine cmd("Command description message", ' ', "0.1");
    4444
    45         ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
    46         cmd.add( nameArg );
     45    ValueArg<string> nameArg("n", "name", "uav name, also used for vrpn", true, "x4", "string");
     46    cmd.add(nameArg);
    4747
    48         ValueArg<string> xmlArg("x","xml","xml file",true,"./reglages.xml","string");
    49         cmd.add( xmlArg );
     48    ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string");
     49    cmd.add(xmlArg);
    5050
    51         ValueArg<int> portArg("p","port","ground station port",true,9002,"int");
    52         cmd.add( portArg );
     51    ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int");
     52    cmd.add(portArg);
    5353
    54         ValueArg<string> addressArg("a","address","ground station address",true,"127.0.0.1","string");
    55         cmd.add( addressArg );
     54    ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string");
     55    cmd.add(addressArg);
    5656
    57         ValueArg<string> typeArg("t","type","uav type, x4 or x8",true,"x4","string");
    58         cmd.add( typeArg );
     57    ValueArg<string> typeArg("t", "type", "uav type, x4 or x8", true, "x4", "string");
     58    cmd.add(typeArg);
    5959
    60         ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int");
    61         cmd.add( optiArg );
     60    ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int");
     61    cmd.add(optiArg);
    6262
    6363#ifdef GL
    64         ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");
    65         cmd.add( mediaArg );
     64    ValueArg<string> mediaArg("m", "media", "path to media files", true, "./", "string");
     65    cmd.add(mediaArg);
    6666
    67         ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");
    68         cmd.add( sceneArg );
     67    ValueArg<string> sceneArg("s", "scene", "path to scene file", true, "./voliere.xml", "string");
     68    cmd.add(sceneArg);
    6969#endif
    7070
    71         cmd.parse( argc, argv );
     71    cmd.parse(argc, argv);
    7272
    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();
     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();
    8080#ifdef GL
    81         media_path=mediaArg.getValue();
    82         scene_file=sceneArg.getValue();
     81    media_path = mediaArg.getValue();
     82    scene_file = sceneArg.getValue();
    8383#endif
    8484
    85         } catch (ArgException &e) {
    86             cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
    87     }
     85  } catch(ArgException& e) {
     86    cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
     87  }
    8888}
    8989
    90 int main(int argc, char* argv[]) {
    91     Simulator *simu;
    92     Model *drone;
    93     SimuImu *imu;
    94     SimuGps *gps;
     90int main(int argc, char* argv[])
     91{
     92  Simulator* simu;
     93  Model* drone;
     94  SimuImu* imu;
     95  SimuGps* gps;
    9596#ifdef GL
    96     SimuUsGL *us_gl;
    97     Parser *gui;
    98     Man *man;
     97  SimuUsGL* us_gl;
     98  Parser* gui;
    9999#endif
    100     parseOptions(argc,argv);
     100  parseOptions(argc, argv);
    101101
    102     simu= new Simulator("simulator",opti_time,0);
    103     simu->SetupConnection(address,port);
    104     simu->SetupUserInterface(xml_file);
     102  simu = new Simulator("simulator", opti_time, 0);
     103  simu->SetupConnection(address, port);
     104  simu->SetupUserInterface(xml_file);
    105105
    106106#ifdef GL
    107     gui=new Parser(simu,1024,768,1024,768,media_path,scene_file);
     107  gui = new Parser(1024, 768, 1024, 768, media_path, scene_file);
    108108#endif
    109109
    110     if(type=="x4") {
    111         drone=new X4(simu,name,0);
    112     } else {
    113         drone=new X8(simu,name,0);
    114     }
     110  if(type == "x4") {
     111    drone = new X4(name, 0);
     112  } else {
     113    drone = new X8(name, 0);
     114  }
    115115
    116     imu=new SimuImu(drone,"imu",90);
     116  imu = new SimuImu(drone, "imu", 0,0);
    117117
    118118#ifdef GL
    119     us_gl=new SimuUsGL(drone,"us",0);
    120     man=new Man(simu,"target");
     119  us_gl = new SimuUsGL(drone, "us", 0,0);
    121120#endif
    122     gps=new SimuGps(drone,"gps",0);
     121  gps = new SimuGps(drone, "gps", 0,0);
    123122
    124     simu->RunSimu();
     123  simu->RunSimu();
    125124
    126     delete simu;
     125  delete simu;
    127126
    128         return 0;
     127  return 0;
    129128}
    130 
Note: See TracChangeset for help on using the changeset viewer.