Changeset 157 in flair-src for trunk/lib/FlairMeta/src/UavFactory.cpp


Ignore:
Timestamp:
03/04/17 15:29:18 (7 years ago)
Author:
Sanahuja Guillaume
Message:

iadded isready to iodevice:
avoid problem of imu not ready in ardrone2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairMeta/src/UavFactory.cpp

    r122 r157  
    3030
    3131namespace { // anonymous
    32      vector<flair::meta::Uav* (*)(string,string,UavMultiplex*)> *vectoroffunctions=NULL;
     32     vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)> *vectoroffunctions=NULL;
    3333}
    3434
     
    4141
    4242
    43 Uav *CreateUav(string name, string uav_type,
     43Uav *CreateUav(string name, string type,string options,
    4444               UavMultiplex *multiplex) {
    4545
     
    4848  if(vectoroffunctions!=NULL) {
    4949    for(int i=0;i<vectoroffunctions->size();i++) {
    50       uav=vectoroffunctions->at(i)(name,uav_type,multiplex);
     50      uav=vectoroffunctions->at(i)(name,type,options,multiplex);
    5151      if(uav!=NULL) {
    5252        free(vectoroffunctions);
     
    5757  }
    5858
    59   if (uav_type == "hds_x4") {
    60     getFrameworkManager()->Err("UAV type %s not yet implemented\n", uav_type.c_str());
     59  if (type == "hds_x4") {
     60    getFrameworkManager()->Err("UAV type %s not yet implemented\n", type.c_str());
    6161    return NULL;
    62   } else if (uav_type == "hds_x8") {
    63     return new HdsX8(name, multiplex);
    64   } else if (uav_type == "xair") {
    65     return new XAir(name, multiplex);
    66   } else if (uav_type == "hds_xufo") {
    67     getFrameworkManager()->Err("UAV type %s not yet implemented\n", uav_type.c_str());
     62  } else if (type == "hds_x8") {
     63    return new HdsX8(name,options, multiplex);
     64  } else if (type == "xair") {
     65    return new XAir(name,options, multiplex);
     66  } else if (type == "hds_xufo") {
     67    getFrameworkManager()->Err("UAV type %s not yet implemented\n", type.c_str());
    6868    return NULL;
    69   } else if (uav_type.compare(0, 7, "x4_simu") == 0) {
     69  } else if (type.compare(0, 7, "x4_simu") == 0) {
    7070    int simu_id = 0;
    71     if (uav_type.size() > 7) {
    72       simu_id = atoi(uav_type.substr(7, uav_type.size() - 7).c_str());
     71    if (type.size() > 7) {
     72      simu_id = atoi(type.substr(7, type.size() - 7).c_str());
    7373    }
    74     return new SimuX4(name, simu_id, multiplex);
    75   } else if (uav_type.compare(0, 7, "x8_simu") == 0) {
     74    return new SimuX4(name, simu_id,options, multiplex);
     75  } else if (type.compare(0, 7, "x8_simu") == 0) {
    7676    int simu_id = 0;
    77     if (uav_type.size() > 7) {
    78       simu_id = atoi(uav_type.substr(7, uav_type.size() - 7).c_str());
     77    if (type.size() > 7) {
     78      simu_id = atoi(type.substr(7, type.size() - 7).c_str());
    7979    }
    80     return new SimuX8(name, simu_id, multiplex);
     80    return new SimuX8(name, simu_id,options, multiplex);
    8181  } else {
    82     getFrameworkManager()->Err("UAV type %s unknown\n", uav_type.c_str());
     82    getFrameworkManager()->Err("UAV type %s unknown\n", type.c_str());
    8383    return NULL;
    8484  }
    8585}
    8686
    87 void RegisterUavCreator(flair::meta::Uav*(*func)(string name, string type,
    88                UavMultiplex *multiplex)) {
    89   if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Uav* (*)(string,string,UavMultiplex*)>*)malloc(sizeof(vector<flair::meta::Uav* (*)(string,string,UavMultiplex*)>));
     87void RegisterUavCreator(flair::meta::Uav*(*func)(string,string,string,UavMultiplex*)) {
     88  if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)>*)malloc(sizeof(vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)>));
    9089
    9190  vectoroffunctions->push_back(func);
Note: See TracChangeset for help on using the changeset viewer.