Changeset 458 in flair-src for trunk


Ignore:
Timestamp:
01/04/22 15:58:45 (2 years ago)
Author:
Sanahuja Guillaume
Message:

update plane

Location:
trunk/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/Servos.h

    r340 r458  
    124124  * values size must be the same as ServosCount()
    125125  *
    126   * \param position set servos position
     126  * \param position set servos position in radians
    127127  */
    128128  virtual void SetServos(float *position) = 0;
  • trunk/lib/FlairSensorActuator/src/SimulatedServos.h

    r340 r458  
    6060  * Values size must be the same as ServosCount()
    6161  *
    62   * \param positions positions values
     62  * \param positions positions values in radians
    6363  */
    6464  void SetServos(float *positions);
  • trunk/lib/FlairSimulator/src/Plane.cpp

    r457 r458  
    1717#include "Plane.h"
    1818#include <SimuBldc.h>
     19#include <SimuServos.h>
    1920#include <TabWidget.h>
    2021#include <Tab.h>
     
    5556 
    5657  motor = new SimuBldc(this, name, 1, modelId,0);
     58  servos = new SimuServos(this, name, 2, modelId,0);
    5759 
    5860  SetIsReady(true);
     
    8789  IMesh *wing= geo->createCubeMesh (vector3df(35, 100, 2));
    8890  IMesh *aileron= geo->createCubeMesh (vector3df(10, 90, 2));
     91  IMesh *axe = geo->createCylinderMesh(.5, 100, 16);//axe pour definir l'axe de rotation en bout d'aileron (sinon l'axe est au milieu d'aileron)
     92 
    8993  //origine de l'aile en son centre
    90   MeshSceneNode *l_wing = new MeshSceneNode(this, wing, vector3df(75, -20-50, 20),
    91                              vector3df(0, 0, 0));
    92   MeshSceneNode *r_wing = new MeshSceneNode(this, wing, vector3df(75, 20+50, 20),
    93                              vector3df(0, 0, 0));
    94                              
    95   l_aileron = new MeshSceneNode(this, aileron, vector3df(55, -20-50, 20),
    96                              vector3df(0, 0, 0));
    97                              
    98   r_aileron = new MeshSceneNode(this, aileron, vector3df(55, 20+50, 20),
    99                              vector3df(0, 0, 0));
     94  MeshSceneNode *l_wing = new MeshSceneNode(this, wing, vector3df(75, -20-50, 20),vector3df(0, 0, 0));
     95  MeshSceneNode *r_wing = new MeshSceneNode(this, wing, vector3df(75, 20+50, 20),vector3df(0, 0, 0));
     96                     
     97       
     98  l_axe_aileron = new MeshSceneNode(this, axe, vector3df(75-35/2, -20-100, 20),vector3df(0, 0, 0));
     99  MeshSceneNode *l_aileron = new MeshSceneNode(l_axe_aileron, aileron, vector3df(-5, 50, 0),vector3df(0, 0, 0),texture);
     100 
     101                       
     102  r_axe_aileron = new MeshSceneNode(this, axe, vector3df(75-35/2, 20, 20),vector3df(0, 0, 0));
     103  MeshSceneNode *r_aileron = new MeshSceneNode(r_axe_aileron, aileron, vector3df(-5, 50,0),vector3df(0, 0, 0),texture);
    100104                               
    101   motor_speed_mutex = new Mutex(this);
     105  actuators_mutex = new Mutex(this);
    102106  motor_speed = 0;
     107  for (int i = 0; i < 2; i++) servos_pos[i] = 0;
    103108  ExtraDraw();
    104109}
    105110
    106111void Plane::AnimateModel(void) {
    107   motor_speed_mutex->GetMutex();
     112  actuators_mutex->GetMutex();
    108113  motor_speed=10;
     114  servos_pos[0]=-0;
     115  servos_pos[1]=0;
    109116  f_blade->SetRotationSpeed(K_MOT *vector3df( 0,motor_speed,0));
    110 
    111   motor_speed_mutex->ReleaseMutex();
     117  l_axe_aileron->setRotation(vector3df(0,servos_pos[1]*180./3.14,0));
     118  r_axe_aileron->setRotation(vector3df(0,servos_pos[0]*180./3.14,0));
     119
     120  actuators_mutex->ReleaseMutex();
    112121
    113122  // adapt UAV size
     
    122131}
    123132
    124 void Plane::WritedbtBuf(
    125     char *dbtbuf) { /*
    126                        float *buf=(float*)dbtbuf;
    127                        vector3df vect=getPosition();
    128                        memcpy(buf,&vect.X,sizeof(float));
    129                        buf++;
    130                        memcpy(buf,&vect.Y,sizeof(float));
    131                        buf++;
    132                        memcpy(buf,&vect.Z,sizeof(float));
    133                        buf++;
    134                        vect=getRotation();
    135                        memcpy(buf,&vect.X,sizeof(float));
    136                        buf++;
    137                        memcpy(buf,&vect.Y,sizeof(float));
    138                        buf++;
    139                        memcpy(buf,&vect.Z,sizeof(float));
    140                        buf++;
    141                        memcpy(buf,&motors,sizeof(rtsimu_motors));*/
    142 }
    143 
    144 void Plane::ReaddbtBuf(
    145     char *dbtbuf) { /*
    146                        float *buf=(float*)dbtbuf;
    147                        vector3df vect;
    148                        memcpy(&vect.X,buf,sizeof(float));
    149                        buf++;
    150                        memcpy(&vect.Y,buf,sizeof(float));
    151                        buf++;
    152                        memcpy(&vect.Z,buf,sizeof(float));
    153                        buf++;
    154                        setPosition(vect);
    155                        memcpy(&vect.X,buf,sizeof(float));
    156                        buf++;
    157                        memcpy(&vect.Y,buf,sizeof(float));
    158                        buf++;
    159                        memcpy(&vect.Z,buf,sizeof(float));
    160                        buf++;
    161                        ((ISceneNode*)(this))->setRotation(vect);
    162                        memcpy(&motors,buf,sizeof(rtsimu_motors));
    163                        AnimateModele();*/
     133void Plane::WritedbtBuf(char *dbtbuf) {
     134}
     135
     136void Plane::ReaddbtBuf(char *dbtbuf) {
    164137}
    165138#endif // GL
     
    170143// z down
    171144void Plane::CalcModel(void) {
    172  
    173145  float u_roll, u_pitch, u_yaw, u_thrust;
    174   Time motorTime;
    175 #ifdef GL
    176   motor_speed_mutex->GetMutex();
     146  Time motorTime,servoTime;
     147 
     148#ifdef GL
     149  actuators_mutex->GetMutex();
    177150#endif // GL
    178151  motor->GetSpeeds(&motor_speed,&motorTime);
    179152  if((GetTime()-motorTime)/1000000>motorTimeout->Value()) {
    180153      if(motor_speed!=0) {
    181          //Printf("timout\n");
    182154        motor_speed=0;
    183155      }
    184156  }
    185 #ifdef GL
    186   motor_speed_mutex->ReleaseMutex();
     157  servos->GetPositions(servos_pos,&servoTime);
     158 
     159#ifdef GL
     160  actuators_mutex->ReleaseMutex();
    187161#endif // GL
    188162 
     
    302276  state[0].Vel.z = (state[0].Pos.z - state[-1].Pos.z) / dT();
    303277*/
     278
    304279#ifndef GL
    305280  if (state[0].Pos.z < 0)
  • trunk/lib/FlairSimulator/src/Plane.h

    r457 r458  
    3030namespace actuator {
    3131class SimuBldc;
     32class SimuServos;
    3233}
    3334}
     
    6263  void WritedbtBuf(char *dbtbuf);
    6364  void ReaddbtBuf(char *dbtbuf);
    64   core::Mutex *motor_speed_mutex;
     65  core::Mutex *actuators_mutex;
    6566  Blade *f_blade;
    66   MeshSceneNode *l_aileron,*r_aileron;
     67  MeshSceneNode *l_axe_aileron,*r_axe_aileron;
    6768#endif
    6869
    6970  actuator::SimuBldc *motor;
    70   float motor_speed;
     71  actuator::SimuServos *servos;
     72  float motor_speed,servos_pos[2];//servo pos in radians
    7173  gui::DoubleSpinBox *m;
    7274  gui::SpinBox *motorTimeout;
  • trunk/lib/FlairSimulator/src/SimuServos.h

    r341 r458  
    5555  *
    5656  *
    57   * \param value array to store servos positions
     57  * \param value array to store servos positions in radians
    5858  * \param time time when shared memory was written
    5959  */
Note: See TracChangeset for help on using the changeset viewer.