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


Ignore:
Timestamp:
Jul 18, 2016, 4:13:56 PM (8 years ago)
Author:
Sanahuja Guillaume
Message:

added compile info

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

Legend:

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

    r41 r45  
    1818#include "UavFactory.h"
    1919#include "FrameworkManager.h"
    20 //#include "ArDrone2.h"
    2120#include "SimuX4.h"
    2221#include "SimuX8.h"
    2322#include "HdsX8.h"
    2423#include "XAir.h"
     24#include "compile_info.h"
    2525
    2626using namespace std;
     
    3030
    3131namespace { // anonymous
    32      vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> vectoroffunctions;
     32     vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> *vectoroffunctions=NULL;
    3333}
     34
     35
     36static void constructor() __attribute__((constructor));
     37
     38void constructor() {
     39  compile_info("FlairMeta");
     40}
     41
    3442
    3543Uav *CreateUav(FrameworkManager *parent, string uav_name, string uav_type,
     
    3745
    3846  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    }
    4257  }
    4358
     
    7287void RegisterUavCreator(flair::meta::Uav*(*func)(FrameworkManager *parent, string uav_name, string uav_type,
    7388               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*)>));
    7590
     91  vectoroffunctions->push_back(func);
    7692}
  • trunk/lib/FlairMeta/src/UavStateMachine.cpp

    r42 r45  
    181181    ComputeThrust(); // logs are added to uz, so it must be updated at last
    182182
    183     //check nan problems
    184     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")) {
    188188
    189189      if(failSafeMode) {
     
    218218}
    219219
    220 bool UavStateMachine::CheckIsNan(float value,std::string desc) {
     220bool UavStateMachine::IsValuePossible(float value,std::string desc) {
    221221  if(isnan(value)) {
    222222    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());
    223226    return true;
    224227  } else {
  • trunk/lib/FlairMeta/src/UavStateMachine.h

    r42 r45  
    261261  void Run(void);
    262262  void StopMotors(void);
    263   bool CheckIsNan(float value,std::string desc);
     263  bool IsValuePossible(float value,std::string desc);
    264264
    265265  meta::Uav *uav;
Note: See TracChangeset for help on using the changeset viewer.