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


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

added compile info

Location:
trunk/lib/FlairMeta
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairMeta/CMakeLists.txt

    r7 r45  
    4444
    4545SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
     46
     47add_custom_target(
     48        compile_info
     49        COMMAND $ENV{FLAIR_ROOT}/flair-dev/scripts/compile_info.sh ${CMAKE_C_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src/unexported/compile_info.h
     50)
     51
     52add_dependencies(${PROJECT_NAME} compile_info)
  • 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.