Changeset 157 in flair-src for trunk/lib/FlairMeta


Ignore:
Timestamp:
Mar 4, 2017, 3:29:18 PM (8 years ago)
Author:
Sanahuja Guillaume
Message:

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

Location:
trunk/lib/FlairMeta/src
Files:
13 edited

Legend:

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

    r137 r157  
    3535namespace meta {
    3636
    37 HdsX8::HdsX8(string name,
     37HdsX8::HdsX8(string name,string options,
    3838             filter::UavMultiplex *multiplex)
    3939    : Uav(name, multiplex) {
     
    5656
    5757void HdsX8::StartSensors(void) {
    58   ((Gx3_25_ahrs *)GetAhrs())->Start();
     58  ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start();
    5959  ((Srf08 *)GetUsRangeFinder())->Start();
    6060  ((Ps3Eye *)GetVerticalCamera())->Start();
    6161}
    6262
     63bool HdsX8::isReadyToFly(void) const {
     64  return GetAhrs()->GetImu()->IsReady();
     65}
     66
    6367} // end namespace meta
    6468} // end namespace flair
  • trunk/lib/FlairMeta/src/HdsX8.h

    r122 r157  
    2424class HdsX8 : public Uav {
    2525public:
    26   HdsX8(std::string name,
     26  HdsX8(std::string name,std::string options="",
    2727        filter::UavMultiplex *multiplex = NULL);
    2828  ~HdsX8();
    2929  void StartSensors(void);
    3030        std::string GetDefaultVrpnAddress(void) const{return "192.168.147.197:3883";}
     31  bool isReadyToFly(void) const;
    3132
    3233private:
  • trunk/lib/FlairMeta/src/MetaDualShock3.cpp

    r137 r157  
    4242  getFrameworkManager()->AddDeviceToLog(pimpl_->joy_ref);
    4343  controller->Start();
     44 
     45  SetIsReady(true);
    4446}
    4547
  • trunk/lib/FlairMeta/src/SimuX4.cpp

    r137 r157  
    2626#include <BatteryMonitor.h>
    2727#include <Tab.h>
     28#include <FindArgument.h>
    2829
    2930using std::string;
     
    3738namespace meta {
    3839
    39 SimuX4::SimuX4(string name, int simu_id,
     40SimuX4::SimuX4(string name, int simu_id,string options,
    4041               filter::UavMultiplex *multiplex)
    4142    : Uav(name, multiplex) {
     
    5152  SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
    5253  GetBatteryMonitor()->SetBatteryValue(12);
     54 
     55  string camvOpts=FindArgument(options,"camv=",false);
     56  uint16_t camvWidth=320,camvHeight=240;
     57        if(camvOpts=="") {
     58    Info("using default vertical camera resolution: %ix%i\n",camvWidth, camvHeight);
     59        }
     60 
    5361  SetVerticalCamera(
    54       new SimuCamera("simu_cam_v", 320, 240, 3, simu_id, 10));
     62      new SimuCamera("simu_cam_v", camvWidth, camvHeight, 3, simu_id, 10));
    5563}
    5664
     
    5866
    5967void SimuX4::StartSensors(void) {
    60   ((SimuAhrs *)GetAhrs())->Start();
     68  ((SimuImu *)(GetAhrs()->GetImu()))->Start();
    6169  ((SimuUs *)GetUsRangeFinder())->Start();
    6270  ((SimuCamera *)GetVerticalCamera())->Start();
    6371}
    6472
     73
    6574} // end namespace meta
    6675} // end namespace flair
  • trunk/lib/FlairMeta/src/SimuX4.h

    r122 r157  
    2626  // simu_id: 0 if simulating only one UAV
    2727  //>0 otherwise
    28   SimuX4(std::string name, int simu_id = 0,
     28  SimuX4(std::string name, int simu_id = 0,std::string options="",
    2929         filter::UavMultiplex *multiplex = NULL);
    3030  ~SimuX4();
  • trunk/lib/FlairMeta/src/SimuX8.cpp

    r137 r157  
    3737namespace meta {
    3838
    39 SimuX8::SimuX8(string name, int simu_id,
     39SimuX8::SimuX8(string name, int simu_id,string options,
    4040               filter::UavMultiplex *multiplex)
    4141    : Uav(name, multiplex) {
     
    5858
    5959void SimuX8::StartSensors(void) {
    60   ((SimuAhrs *)GetAhrs())->Start();
     60  ((SimuImu *)(GetAhrs()->GetImu()))->Start();
    6161  ((SimuUs *)GetUsRangeFinder())->Start();
    6262  ((SimuCamera *)GetVerticalCamera())->Start();
  • trunk/lib/FlairMeta/src/SimuX8.h

    r122 r157  
    2626  // simu_id: 0 if simulating only one UAV
    2727  //>0 otherwise
    28   SimuX8(std::string name, int simu_id = 0,
     28  SimuX8(std::string name, int simu_id = 0,std::string options="",
    2929         filter::UavMultiplex *multiplex = NULL);
    3030  ~SimuX8();
  • trunk/lib/FlairMeta/src/Uav.h

    r122 r157  
    1515
    1616#include <Object.h>
     17#include <UsRangeFinder.h>
    1718
    1819namespace flair {
     
    6263  sensor::Camera *GetHorizontalCamera(void) const;
    6364        virtual std::string GetDefaultVrpnAddress(void) const{return "127.0.0.1:3883";}
     65  virtual bool isReadyToFly(void) const { return true;}
    6466
    6567protected:
  • 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);
  • trunk/lib/FlairMeta/src/UavFactory.h

    r122 r157  
    2121#include <Uav.h>
    2222
    23 flair::meta::Uav *CreateUav(std::string name, std::string type,
     23flair::meta::Uav *CreateUav(std::string name, std::string type,std::string options="",
    2424                            flair::filter::UavMultiplex *multiplex = NULL);
    2525
    26 void RegisterUavCreator(flair::meta::Uav*(*func)(std::string name, std::string type,
    27                                    flair::filter::UavMultiplex *multiplex));
     26void RegisterUavCreator(flair::meta::Uav*(*func)(std::string,std::string,std::string,
     27                                   flair::filter::UavMultiplex*));
    2828#endif // UAVFACTORY
  • trunk/lib/FlairMeta/src/UavStateMachine.cpp

    r153 r157  
    460460  flagZTrajectoryFinished = false;
    461461
    462     if((altitudeState==AltitudeState_t::Stopped) && safeToFly) {// && GetBatteryMonitor()->IsBatteryLow()==false)
    463         //The uav always takes off in fail safe mode
    464         EnterFailSafeMode();
    465         joy->SetLedOFF(4);//DualShock3::led4
    466         joy->SetLedOFF(1);//DualShock3::led1
    467         joy->Rumble(0x70);
    468         joy->SetZRef(0);
     462  if((altitudeState==AltitudeState_t::Stopped) && safeToFly && uav->isReadyToFly()) {// && GetBatteryMonitor()->IsBatteryLow()==false)
     463    //The uav always takes off in fail safe mode
     464    EnterFailSafeMode();
     465    joy->SetLedOFF(4);//DualShock3::led4
     466    joy->SetLedOFF(1);//DualShock3::led1
     467    joy->Rumble(0x70);
     468    joy->SetZRef(0);
    469469
    470470    uZ->SetOffset(); // positionne l'offset de compensation de la gravité à sa
     
    481481    SignalEvent(Event_t::TakingOff);
    482482  } else {
     483    Warn("cannot takeoff\n");
    483484    joy->ErrorNotify();
    484485  }
  • trunk/lib/FlairMeta/src/XAir.cpp

    r137 r157  
    3838namespace meta {
    3939
    40 XAir::XAir(string name,
     40XAir::XAir(string name, string options,
    4141           filter::UavMultiplex *multiplex)
    4242    : Uav(name, multiplex) {
     
    6161
    6262void XAir::StartSensors(void) {
    63   ((Gx3_25_ahrs *)GetAhrs())->Start();
     63  ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start();
    6464  ((Srf08 *)GetUsRangeFinder())->Start();
    6565  ((Ps3Eye *)GetVerticalCamera())->Start();
    6666}
    6767
     68bool XAir::isReadyToFly(void) const {
     69  return GetAhrs()->GetImu()->IsReady();
     70}
     71
    6872} // end namespace meta
    6973} // end namespace flair
  • trunk/lib/FlairMeta/src/XAir.h

    r122 r157  
    2424class XAir : public Uav {
    2525public:
    26   XAir(std::string name,
     26  XAir(std::string name,std::string options="",
    2727       filter::UavMultiplex *multiplex = NULL);
    2828  ~XAir();
    2929  void StartSensors(void);
    3030        std::string GetDefaultVrpnAddress(void) const{return "192.168.147.197:3883";}
     31  bool isReadyToFly(void) const;
    3132
    3233private:
Note: See TracChangeset for help on using the changeset viewer.