Changeset 158 in flair-src for trunk/demos/CircleFollower/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/CircleFollower/simulator/src/main.cpp

    r123 r158  
    2323#endif
    2424
    25 
    2625using namespace TCLAP;
    2726using namespace std;
     
    3837string address;
    3938
    40 void parseOptions(int argc, char** argv) {
    41         try {
    42         CmdLine cmd("Command description message", ' ', "0.1");
     39void parseOptions(int argc, char** argv)
     40{
     41  try {
     42    CmdLine cmd("Command description message", ' ', "0.1");
    4343
    44         ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
    45         cmd.add( nameArg );
     44    ValueArg<string> nameArg("n", "name", "uav name, also used for vrpn", true, "x4", "string");
     45    cmd.add(nameArg);
    4646
    47         ValueArg<string> xmlArg("x","xml","xml file",true,"./reglages.xml","string");
    48         cmd.add( xmlArg );
     47    ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string");
     48    cmd.add(xmlArg);
    4949
    50         ValueArg<int> portArg("p","port","ground station port",true,9002,"int");
    51         cmd.add( portArg );
     50    ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int");
     51    cmd.add(portArg);
    5252
    53         ValueArg<string> addressArg("a","address","ground station address",true,"127.0.0.1","string");
    54         cmd.add( addressArg );
     53    ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string");
     54    cmd.add(addressArg);
    5555
    56         ValueArg<string> typeArg("t","type","uav type, x4 or x8",true,"x4","string");
    57         cmd.add( typeArg );
     56    ValueArg<string> typeArg("t", "type", "uav type, x4 or x8", true, "x4", "string");
     57    cmd.add(typeArg);
    5858
    59         ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int");
    60         cmd.add( optiArg );
     59    ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int");
     60    cmd.add(optiArg);
    6161
    6262#ifdef GL
    63         ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");
    64         cmd.add( mediaArg );
     63    ValueArg<string> mediaArg("m", "media", "path to media files", true, "./", "string");
     64    cmd.add(mediaArg);
    6565
    66         ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");
    67         cmd.add( sceneArg );
     66    ValueArg<string> sceneArg("s", "scene", "path to scene file", true, "./voliere.xml", "string");
     67    cmd.add(sceneArg);
    6868#endif
    6969
    70         cmd.parse( argc, argv );
     70    cmd.parse(argc, argv);
    7171
    72         // Get the value parsed by each arg.
    73         port=portArg.getValue();
    74         xml_file = xmlArg.getValue();
    75         opti_time = optiArg.getValue();
    76         type = typeArg.getValue();
    77         name=nameArg.getValue();
    78         address=addressArg.getValue();
     72    // Get the value parsed by each arg.
     73    port = portArg.getValue();
     74    xml_file = xmlArg.getValue();
     75    opti_time = optiArg.getValue();
     76    type = typeArg.getValue();
     77    name = nameArg.getValue();
     78    address = addressArg.getValue();
    7979#ifdef GL
    80         media_path=mediaArg.getValue();
    81         scene_file=sceneArg.getValue();
     80    media_path = mediaArg.getValue();
     81    scene_file = sceneArg.getValue();
    8282#endif
    8383
    84         } catch (ArgException &e) {
    85             cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
    86     }
     84  } catch(ArgException& e) {
     85    cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
     86  }
    8787}
    8888
    89 int main(int argc, char* argv[]) {
    90     Simulator *simu;
    91     Model *drone;
    92     SimuImu* imu;
     89int main(int argc, char* argv[])
     90{
     91  Simulator* simu;
     92  Model* drone;
     93  SimuImu* imu;
    9394#ifdef GL
    94     SimuUsGL* us_gl;
    95     Parser *gui;
    96     Man *man;
     95  SimuUsGL* us_gl;
     96  Parser* gui;
     97  Man* man;
    9798#endif
    98     parseOptions(argc,argv);
     99  parseOptions(argc, argv);
    99100
    100     simu= new Simulator("simulator",opti_time,90);
    101     simu->SetupConnection(address,port);
    102     simu->SetupUserInterface(xml_file);
     101  simu = new Simulator("simulator", opti_time, 90);
     102  simu->SetupConnection(address, port);
     103  simu->SetupUserInterface(xml_file);
    103104
    104105#ifdef GL
    105     gui=new Parser(simu,1024,768,1024,768,media_path,scene_file);
     106  gui = new Parser(1024, 768, 1024, 768, media_path, scene_file);
    106107#endif
    107108
    108     if(type=="x4") {
    109         drone=new X4(simu,name,0);
    110     } else {
    111         drone=new X8(simu,name,0);
    112     }
     109  if(type == "x4") {
     110    drone = new X4(name, 0);
     111  } else {
     112    drone = new X8(name, 0);
     113  }
    113114
    114     imu=new SimuImu(drone,"imu",0);
     115  imu = new SimuImu(drone, "imu", 0,0);
    115116
    116117#ifdef GL
    117     us_gl=new SimuUsGL(drone,"us",0);
    118    
     118  us_gl = new SimuUsGL(drone, "us", 0,0);
    119119
    120     man=new Man(simu,"target");
     120  man = new Man("target",1);
    121121#endif
    122122
    123     simu->RunSimu();
     123  simu->RunSimu();
    124124
    125     delete simu;
     125  delete simu;
    126126
    127         return 0;
     127  return 0;
    128128}
    129 
Note: See TracChangeset for help on using the changeset viewer.