Changeset 105 in flair-src for trunk/demos/PidStandalone/uav/src/main.cpp


Ignore:
Timestamp:
Oct 18, 2016, 9:13:08 AM (5 years ago)
Author:
Bayard Gildas
Message:

Passage du "framework" à flair

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/PidStandalone/uav/src/main.cpp

    r44 r105  
    2222using namespace TCLAP;
    2323using namespace std;
    24 using namespace framework::core;
    25 using namespace framework::meta;
    26 using namespace framework::sensor;
     24using namespace flair::core;
     25using namespace flair::meta;
     26using namespace flair::sensor;
    2727
    2828string uav_type;
     
    3535string address;
    3636
    37 void parseOptions(int argc, char** argv);
     37void parseOptions(int argc, char **argv);
    3838
     39int main(int argc, char *argv[]) {
     40  parseOptions(argc, argv);
    3941
    40 int main(int argc, char* argv[]) {
    41     parseOptions(argc,argv);
     42  FrameworkManager *manager;
     43  manager = new FrameworkManager(name);
     44  if (!headless) {
     45    manager->SetupConnection(address, port);
     46  }
     47  manager->SetupUserInterface(xml_file);
     48  manager->SetupLogger(log_path);
    4249
    43     FrameworkManager *manager;
    44     manager= new FrameworkManager(name);
    45     if (!headless) {
    46         manager->SetupConnection(address,port);
    47     }
    48     manager->SetupUserInterface(xml_file);
    49     manager->SetupLogger(log_path);
     50  Uav *drone = CreateUav(manager, name, uav_type);
     51  TargetEthController *controller =
     52      new TargetEthController(manager, "Dualshock3", 20000);
     53  // EmulatedController *controller=new EmulatedController(manager,"Emulated
     54  // Controller");
     55  //    controller->AddStep(10000,"Waiting for AHRS
     56  //    stabilization",0,0.,0.,0.,0.);
     57  //    controller->AddStep(500,"Takeoff",(uint16_t)EmulatedController::ButtonType::start,0.,0.,0.,0.);
     58  //    controller->AddStep(3000,"Waiting for flight
     59  //    stabilization",0,0.,0.,0.,0.);
     60  /*    controller->AddStep(2000,"fly left",0,-0.3,0.,0.,0.);
     61      controller->AddStep(1000,"fly right",0,0.3,0.,0.,0.);*/
     62  //    controller->AddStep(500,"Land",(uint16_t)EmulatedController::ButtonType::start,0.,0.,0.,0.);
     63  //    controller->AddStep(3000,"Waiting for landing",0,0.,0.,0.,0.);
     64  //    controller->AddStep(500,"Stop",(uint16_t)EmulatedController::ButtonType::select,0.,0.,0.,0.);
     65  PidUav *app = new PidUav(drone, controller);
    5066
    51     Uav* drone=CreateUav(manager,name,uav_type);
    52     TargetEthController *controller=new TargetEthController(manager,"Dualshock3",20000);
    53     //EmulatedController *controller=new EmulatedController(manager,"Emulated Controller");
    54 //    controller->AddStep(10000,"Waiting for AHRS stabilization",0,0.,0.,0.,0.);
    55 //    controller->AddStep(500,"Takeoff",(uint16_t)EmulatedController::ButtonType::start,0.,0.,0.,0.);
    56 //    controller->AddStep(3000,"Waiting for flight stabilization",0,0.,0.,0.,0.);
    57 /*    controller->AddStep(2000,"fly left",0,-0.3,0.,0.,0.);
    58     controller->AddStep(1000,"fly right",0,0.3,0.,0.,0.);*/
    59 //    controller->AddStep(500,"Land",(uint16_t)EmulatedController::ButtonType::start,0.,0.,0.,0.);
    60 //    controller->AddStep(3000,"Waiting for landing",0,0.,0.,0.,0.);
    61 //    controller->AddStep(500,"Stop",(uint16_t)EmulatedController::ButtonType::select,0.,0.,0.,0.);
    62     PidUav* app=new PidUav(drone,controller);
     67  app->Start();
     68  app->Join();
    6369
    64     app->Start();
    65     app->Join();
    66 
    67     delete manager;
     70  delete manager;
    6871}
    6972
    70 void parseOptions(int argc, char** argv) {
    71         try {
     73void parseOptions(int argc, char **argv) {
     74  try {
    7275
    73         CmdLine cmd("Command description message", ' ', "0.1");
     76    CmdLine cmd("Command description message", ' ', "0.1");
    7477
    75         ValueArg<string> nameArg("n","name","uav name",true,"x4","string");
    76         cmd.add( nameArg );
     78    ValueArg<string> nameArg("n", "name", "uav name", true, "x4", "string");
     79    cmd.add(nameArg);
    7780
    78         ValueArg<string> typeArg("t","type","uav type: ardrone2, hds_x4, hds_x8, hds_xufo, hds_simu or hds_simux (with x the number of the simulated uav)",true,"hds_x4","string");
    79         cmd.add( typeArg );
     81    ValueArg<string> typeArg(
     82        "t", "type", "uav type: ardrone2, hds_x4, hds_x8, hds_xufo, hds_simu "
     83                     "or hds_simux (with x the number of the simulated uav)",
     84        true, "hds_x4", "string");
     85    cmd.add(typeArg);
    8086
    81         ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
    82         cmd.add( xmlArg );
     87    ValueArg<string> xmlArg("x", "xml", "fichier xml", true, "./reglages.xml",
     88                            "string");
     89    cmd.add(xmlArg);
    8390
    84         ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
    85         cmd.add( logsArg );
     91    ValueArg<string> logsArg("l", "logs", "repertoire des logs", true,
     92                             "/media/ram", "string");
     93    cmd.add(logsArg);
    8694
    87         ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
    88         cmd.add( portArg );
     95    ValueArg<int> portArg("p", "port", "port pour station sol", true, 9000,
     96                          "int");
     97    cmd.add(portArg);
    8998
    90         ValueArg<string> addressArg("a","address","addresse station sol",true,"127.0.0.1","string");
    91         cmd.add( addressArg );
     99    ValueArg<string> addressArg("a", "address", "addresse station sol", true,
     100                                "127.0.0.1", "string");
     101    cmd.add(addressArg);
    92102
    93         SwitchArg headlessArg("e","headless","headless mode", false);
    94         cmd.add( headlessArg );
     103    SwitchArg headlessArg("e", "headless", "headless mode", false);
     104    cmd.add(headlessArg);
    95105
    96         cmd.parse( argc, argv );
     106    cmd.parse(argc, argv);
    97107
    98         // Get the value parsed by each arg.
    99         uav_type=typeArg.getValue();
    100         log_path = logsArg.getValue();
    101         port=portArg.getValue();
    102         xml_file = xmlArg.getValue();
    103         name=nameArg.getValue();
    104         address=addressArg.getValue();
    105         headless=headlessArg.getValue();
     108    // Get the value parsed by each arg.
     109    uav_type = typeArg.getValue();
     110    log_path = logsArg.getValue();
     111    port = portArg.getValue();
     112    xml_file = xmlArg.getValue();
     113    name = nameArg.getValue();
     114    address = addressArg.getValue();
     115    headless = headlessArg.getValue();
    106116
    107         } catch (ArgException &e)  // catch any exceptions
    108         { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; }
     117  } catch (ArgException &e) // catch any exceptions
     118  {
     119    cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
     120  }
    109121}
Note: See TracChangeset for help on using the changeset viewer.