Changeset 157 in flair-src for trunk/lib/FlairMeta
- Timestamp:
- Mar 4, 2017, 3:29:18 PM (8 years ago)
- Location:
- trunk/lib/FlairMeta/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairMeta/src/HdsX8.cpp
r137 r157 35 35 namespace meta { 36 36 37 HdsX8::HdsX8(string name, 37 HdsX8::HdsX8(string name,string options, 38 38 filter::UavMultiplex *multiplex) 39 39 : Uav(name, multiplex) { … … 56 56 57 57 void HdsX8::StartSensors(void) { 58 ((Gx3_25_ ahrs *)GetAhrs())->Start();58 ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start(); 59 59 ((Srf08 *)GetUsRangeFinder())->Start(); 60 60 ((Ps3Eye *)GetVerticalCamera())->Start(); 61 61 } 62 62 63 bool HdsX8::isReadyToFly(void) const { 64 return GetAhrs()->GetImu()->IsReady(); 65 } 66 63 67 } // end namespace meta 64 68 } // end namespace flair -
trunk/lib/FlairMeta/src/HdsX8.h
r122 r157 24 24 class HdsX8 : public Uav { 25 25 public: 26 HdsX8(std::string name, 26 HdsX8(std::string name,std::string options="", 27 27 filter::UavMultiplex *multiplex = NULL); 28 28 ~HdsX8(); 29 29 void StartSensors(void); 30 30 std::string GetDefaultVrpnAddress(void) const{return "192.168.147.197:3883";} 31 bool isReadyToFly(void) const; 31 32 32 33 private: -
trunk/lib/FlairMeta/src/MetaDualShock3.cpp
r137 r157 42 42 getFrameworkManager()->AddDeviceToLog(pimpl_->joy_ref); 43 43 controller->Start(); 44 45 SetIsReady(true); 44 46 } 45 47 -
trunk/lib/FlairMeta/src/SimuX4.cpp
r137 r157 26 26 #include <BatteryMonitor.h> 27 27 #include <Tab.h> 28 #include <FindArgument.h> 28 29 29 30 using std::string; … … 37 38 namespace meta { 38 39 39 SimuX4::SimuX4(string name, int simu_id, 40 SimuX4::SimuX4(string name, int simu_id,string options, 40 41 filter::UavMultiplex *multiplex) 41 42 : Uav(name, multiplex) { … … 51 52 SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery")); 52 53 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 53 61 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)); 55 63 } 56 64 … … 58 66 59 67 void SimuX4::StartSensors(void) { 60 ((Simu Ahrs *)GetAhrs())->Start();68 ((SimuImu *)(GetAhrs()->GetImu()))->Start(); 61 69 ((SimuUs *)GetUsRangeFinder())->Start(); 62 70 ((SimuCamera *)GetVerticalCamera())->Start(); 63 71 } 64 72 73 65 74 } // end namespace meta 66 75 } // end namespace flair -
trunk/lib/FlairMeta/src/SimuX4.h
r122 r157 26 26 // simu_id: 0 if simulating only one UAV 27 27 //>0 otherwise 28 SimuX4(std::string name, int simu_id = 0, 28 SimuX4(std::string name, int simu_id = 0,std::string options="", 29 29 filter::UavMultiplex *multiplex = NULL); 30 30 ~SimuX4(); -
trunk/lib/FlairMeta/src/SimuX8.cpp
r137 r157 37 37 namespace meta { 38 38 39 SimuX8::SimuX8(string name, int simu_id, 39 SimuX8::SimuX8(string name, int simu_id,string options, 40 40 filter::UavMultiplex *multiplex) 41 41 : Uav(name, multiplex) { … … 58 58 59 59 void SimuX8::StartSensors(void) { 60 ((Simu Ahrs *)GetAhrs())->Start();60 ((SimuImu *)(GetAhrs()->GetImu()))->Start(); 61 61 ((SimuUs *)GetUsRangeFinder())->Start(); 62 62 ((SimuCamera *)GetVerticalCamera())->Start(); -
trunk/lib/FlairMeta/src/SimuX8.h
r122 r157 26 26 // simu_id: 0 if simulating only one UAV 27 27 //>0 otherwise 28 SimuX8(std::string name, int simu_id = 0, 28 SimuX8(std::string name, int simu_id = 0,std::string options="", 29 29 filter::UavMultiplex *multiplex = NULL); 30 30 ~SimuX8(); -
trunk/lib/FlairMeta/src/Uav.h
r122 r157 15 15 16 16 #include <Object.h> 17 #include <UsRangeFinder.h> 17 18 18 19 namespace flair { … … 62 63 sensor::Camera *GetHorizontalCamera(void) const; 63 64 virtual std::string GetDefaultVrpnAddress(void) const{return "127.0.0.1:3883";} 65 virtual bool isReadyToFly(void) const { return true;} 64 66 65 67 protected: -
trunk/lib/FlairMeta/src/UavFactory.cpp
r122 r157 30 30 31 31 namespace { // anonymous 32 vector<flair::meta::Uav* (*)(string,string, UavMultiplex*)> *vectoroffunctions=NULL;32 vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)> *vectoroffunctions=NULL; 33 33 } 34 34 … … 41 41 42 42 43 Uav *CreateUav(string name, string uav_type,43 Uav *CreateUav(string name, string type,string options, 44 44 UavMultiplex *multiplex) { 45 45 … … 48 48 if(vectoroffunctions!=NULL) { 49 49 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); 51 51 if(uav!=NULL) { 52 52 free(vectoroffunctions); … … 57 57 } 58 58 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()); 61 61 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()); 68 68 return NULL; 69 } else if ( uav_type.compare(0, 7, "x4_simu") == 0) {69 } else if (type.compare(0, 7, "x4_simu") == 0) { 70 70 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()); 73 73 } 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) { 76 76 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()); 79 79 } 80 return new SimuX8(name, simu_id, multiplex);80 return new SimuX8(name, simu_id,options, multiplex); 81 81 } else { 82 getFrameworkManager()->Err("UAV type %s unknown\n", uav_type.c_str());82 getFrameworkManager()->Err("UAV type %s unknown\n", type.c_str()); 83 83 return NULL; 84 84 } 85 85 } 86 86 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*)>)); 87 void 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*)>)); 90 89 91 90 vectoroffunctions->push_back(func); -
trunk/lib/FlairMeta/src/UavFactory.h
r122 r157 21 21 #include <Uav.h> 22 22 23 flair::meta::Uav *CreateUav(std::string name, std::string type, 23 flair::meta::Uav *CreateUav(std::string name, std::string type,std::string options="", 24 24 flair::filter::UavMultiplex *multiplex = NULL); 25 25 26 void RegisterUavCreator(flair::meta::Uav*(*func)(std::string name, std::string type,27 flair::filter::UavMultiplex *multiplex));26 void RegisterUavCreator(flair::meta::Uav*(*func)(std::string,std::string,std::string, 27 flair::filter::UavMultiplex*)); 28 28 #endif // UAVFACTORY -
trunk/lib/FlairMeta/src/UavStateMachine.cpp
r153 r157 460 460 flagZTrajectoryFinished = false; 461 461 462 if((altitudeState==AltitudeState_t::Stopped) && safeToFly) {// && GetBatteryMonitor()->IsBatteryLow()==false)463 464 465 466 467 468 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); 469 469 470 470 uZ->SetOffset(); // positionne l'offset de compensation de la gravité à sa … … 481 481 SignalEvent(Event_t::TakingOff); 482 482 } else { 483 Warn("cannot takeoff\n"); 483 484 joy->ErrorNotify(); 484 485 } -
trunk/lib/FlairMeta/src/XAir.cpp
r137 r157 38 38 namespace meta { 39 39 40 XAir::XAir(string name, 40 XAir::XAir(string name, string options, 41 41 filter::UavMultiplex *multiplex) 42 42 : Uav(name, multiplex) { … … 61 61 62 62 void XAir::StartSensors(void) { 63 ((Gx3_25_ ahrs *)GetAhrs())->Start();63 ((Gx3_25_imu *)(GetAhrs()->GetImu()))->Start(); 64 64 ((Srf08 *)GetUsRangeFinder())->Start(); 65 65 ((Ps3Eye *)GetVerticalCamera())->Start(); 66 66 } 67 67 68 bool XAir::isReadyToFly(void) const { 69 return GetAhrs()->GetImu()->IsReady(); 70 } 71 68 72 } // end namespace meta 69 73 } // end namespace flair -
trunk/lib/FlairMeta/src/XAir.h
r122 r157 24 24 class XAir : public Uav { 25 25 public: 26 XAir(std::string name, 26 XAir(std::string name,std::string options="", 27 27 filter::UavMultiplex *multiplex = NULL); 28 28 ~XAir(); 29 29 void StartSensors(void); 30 30 std::string GetDefaultVrpnAddress(void) const{return "192.168.147.197:3883";} 31 bool isReadyToFly(void) const; 31 32 32 33 private:
Note:
See TracChangeset
for help on using the changeset viewer.