Changeset 214 in flair-src for trunk/lib/FlairSimulator/src/X4.cpp


Ignore:
Timestamp:
Feb 7, 2018, 5:49:27 PM (4 years ago)
Author:
Sanahuja Guillaume
Message:

matrix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSimulator/src/X4.cpp

    r167 r214  
    2020#include <Tab.h>
    2121#include <DoubleSpinBox.h>
     22#include <SpinBox.h>
    2223#include <GroupBox.h>
    2324#include <math.h>
     
    7374  j_yaw = new DoubleSpinBox(setup_tab->LastRowLastCol(), "j_yaw:", 0, 1, 0.001,
    7475                            5); // moment d'inertie d'un axe (N.m.s²/rad)
     76                           
     77  motorTimeout = new SpinBox(setup_tab->NewRow(), "motor timeout:","ms", 0, 1000, 100,100);
    7578
    7679  motors = new SimuBldc(this, name, 4, modelId,0);
     
    199202  float fl_speed, fr_speed, rl_speed, rr_speed;
    200203  float u_roll, u_pitch, u_yaw, u_thrust;
     204  Time motorTime;
    201205#ifdef GL
    202206  motor_speed_mutex->GetMutex();
    203207#endif // GL
    204   motors->GetSpeeds(motor_speed);
     208  motors->GetSpeeds(motor_speed,&motorTime);
     209  if((GetTime()-motorTime)/1000000>motorTimeout->Value()) {
     210    for(int i=0;i<4;i++) {
     211      if(motor_speed[i]!=0) {
     212         //Printf("timout\n");
     213        for(int i=0;i<4;i++) motor_speed[i]=0;
     214        break;
     215      }
     216    }
     217  }
    205218#ifdef GL
    206219  motor_speed_mutex->ReleaseMutex();
    207220#endif // GL
     221 
    208222  fl_speed = motor_speed[0];
    209223  fr_speed = motor_speed[1];
     
    212226
    213227  /*
    214       ** ===================================================================
    215       **    u roll: roll torque
    216       **
    217       ** ===================================================================
    218       */
     228  ** ===================================================================
     229  **    u roll: roll torque
     230  **
     231  ** ===================================================================
     232  */
    219233  u_roll = arm_length->Value() * k_mot->Value() *
    220234           (fl_speed * fl_speed + rl_speed * rl_speed - fr_speed * fr_speed -
Note: See TracChangeset for help on using the changeset viewer.