Changeset 45 in flair-src for trunk/lib/FlairMeta/src
- Timestamp:
- Jul 18, 2016, 4:13:56 PM (8 years ago)
- Location:
- trunk/lib/FlairMeta/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairMeta/src/UavFactory.cpp
r41 r45 18 18 #include "UavFactory.h" 19 19 #include "FrameworkManager.h" 20 //#include "ArDrone2.h"21 20 #include "SimuX4.h" 22 21 #include "SimuX8.h" 23 22 #include "HdsX8.h" 24 23 #include "XAir.h" 24 #include "compile_info.h" 25 25 26 26 using namespace std; … … 30 30 31 31 namespace { // anonymous 32 vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> vectoroffunctions;32 vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> *vectoroffunctions=NULL; 33 33 } 34 35 36 static void constructor() __attribute__((constructor)); 37 38 void constructor() { 39 compile_info("FlairMeta"); 40 } 41 34 42 35 43 Uav *CreateUav(FrameworkManager *parent, string uav_name, string uav_type, … … 37 45 38 46 Uav *uav; 39 for(int i=0;i<vectoroffunctions.size();i++) { 40 uav=vectoroffunctions.at(i)(parent, uav_name, uav_type,multiplex); 41 if(uav!=NULL) return uav; 47 48 if(vectoroffunctions!=NULL) { 49 for(int i=0;i<vectoroffunctions->size();i++) { 50 uav=vectoroffunctions->at(i)(parent, uav_name, uav_type,multiplex); 51 if(uav!=NULL) { 52 free(vectoroffunctions); 53 vectoroffunctions=NULL; 54 return uav; 55 } 56 } 42 57 } 43 58 … … 72 87 void RegisterUavCreator(flair::meta::Uav*(*func)(FrameworkManager *parent, string uav_name, string uav_type, 73 88 UavMultiplex *multiplex)) { 74 vectoroffunctions.push_back(func);89 if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)>*)malloc(sizeof(vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)>)); 75 90 91 vectoroffunctions->push_back(func); 76 92 } -
trunk/lib/FlairMeta/src/UavStateMachine.cpp
r42 r45 181 181 ComputeThrust(); // logs are added to uz, so it must be updated at last 182 182 183 //check nan problems184 if( CheckIsNan(currentTorques.roll,"roll torque")185 || CheckIsNan(currentTorques.pitch,"pitch torque")186 || CheckIsNan(currentTorques.yaw,"yaw torque")187 || CheckIsNan(currentThrust,"thrust")) {183 //check nan/inf problems 184 if(IsValuePossible(currentTorques.roll,"roll torque") 185 || IsValuePossible(currentTorques.pitch,"pitch torque") 186 || IsValuePossible(currentTorques.yaw,"yaw torque") 187 || IsValuePossible(currentThrust,"thrust")) { 188 188 189 189 if(failSafeMode) { … … 218 218 } 219 219 220 bool UavStateMachine:: CheckIsNan(float value,std::string desc) {220 bool UavStateMachine::IsValuePossible(float value,std::string desc) { 221 221 if(isnan(value)) { 222 222 Warn("%s is not an number\n",desc.c_str()); 223 return true; 224 } else if(isinf(value)) { 225 Warn("%s is infinite\n",desc.c_str()); 223 226 return true; 224 227 } else { -
trunk/lib/FlairMeta/src/UavStateMachine.h
r42 r45 261 261 void Run(void); 262 262 void StopMotors(void); 263 bool CheckIsNan(float value,std::string desc);263 bool IsValuePossible(float value,std::string desc); 264 264 265 265 meta::Uav *uav;
Note:
See TracChangeset
for help on using the changeset viewer.