Changeset 458 in flair-src
- Timestamp:
- Jan 4, 2022, 3:58:45 PM (3 years ago)
- Location:
- trunk/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/Servos.h
r340 r458 124 124 * values size must be the same as ServosCount() 125 125 * 126 * \param position set servos position 126 * \param position set servos position in radians 127 127 */ 128 128 virtual void SetServos(float *position) = 0; -
trunk/lib/FlairSensorActuator/src/SimulatedServos.h
r340 r458 60 60 * Values size must be the same as ServosCount() 61 61 * 62 * \param positions positions values 62 * \param positions positions values in radians 63 63 */ 64 64 void SetServos(float *positions); -
trunk/lib/FlairSimulator/src/Plane.cpp
r457 r458 17 17 #include "Plane.h" 18 18 #include <SimuBldc.h> 19 #include <SimuServos.h> 19 20 #include <TabWidget.h> 20 21 #include <Tab.h> … … 55 56 56 57 motor = new SimuBldc(this, name, 1, modelId,0); 58 servos = new SimuServos(this, name, 2, modelId,0); 57 59 58 60 SetIsReady(true); … … 87 89 IMesh *wing= geo->createCubeMesh (vector3df(35, 100, 2)); 88 90 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 89 93 //origine de l'aile en son centre 90 MeshSceneNode *l_wing = new MeshSceneNode(this, wing, vector3df(75, -20-50, 20), 91 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_a ileron = 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); 100 104 101 motor_speed_mutex = new Mutex(this);105 actuators_mutex = new Mutex(this); 102 106 motor_speed = 0; 107 for (int i = 0; i < 2; i++) servos_pos[i] = 0; 103 108 ExtraDraw(); 104 109 } 105 110 106 111 void Plane::AnimateModel(void) { 107 motor_speed_mutex->GetMutex();112 actuators_mutex->GetMutex(); 108 113 motor_speed=10; 114 servos_pos[0]=-0; 115 servos_pos[1]=0; 109 116 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(); 112 121 113 122 // adapt UAV size … … 122 131 } 123 132 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();*/ 133 void Plane::WritedbtBuf(char *dbtbuf) { 134 } 135 136 void Plane::ReaddbtBuf(char *dbtbuf) { 164 137 } 165 138 #endif // GL … … 170 143 // z down 171 144 void Plane::CalcModel(void) { 172 173 145 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(); 177 150 #endif // GL 178 151 motor->GetSpeeds(&motor_speed,&motorTime); 179 152 if((GetTime()-motorTime)/1000000>motorTimeout->Value()) { 180 153 if(motor_speed!=0) { 181 //Printf("timout\n");182 154 motor_speed=0; 183 155 } 184 156 } 185 #ifdef GL 186 motor_speed_mutex->ReleaseMutex(); 157 servos->GetPositions(servos_pos,&servoTime); 158 159 #ifdef GL 160 actuators_mutex->ReleaseMutex(); 187 161 #endif // GL 188 162 … … 302 276 state[0].Vel.z = (state[0].Pos.z - state[-1].Pos.z) / dT(); 303 277 */ 278 304 279 #ifndef GL 305 280 if (state[0].Pos.z < 0) -
trunk/lib/FlairSimulator/src/Plane.h
r457 r458 30 30 namespace actuator { 31 31 class SimuBldc; 32 class SimuServos; 32 33 } 33 34 } … … 62 63 void WritedbtBuf(char *dbtbuf); 63 64 void ReaddbtBuf(char *dbtbuf); 64 core::Mutex * motor_speed_mutex;65 core::Mutex *actuators_mutex; 65 66 Blade *f_blade; 66 MeshSceneNode *l_a ileron,*r_aileron;67 MeshSceneNode *l_axe_aileron,*r_axe_aileron; 67 68 #endif 68 69 69 70 actuator::SimuBldc *motor; 70 float motor_speed; 71 actuator::SimuServos *servos; 72 float motor_speed,servos_pos[2];//servo pos in radians 71 73 gui::DoubleSpinBox *m; 72 74 gui::SpinBox *motorTimeout; -
trunk/lib/FlairSimulator/src/SimuServos.h
r341 r458 55 55 * 56 56 * 57 * \param value array to store servos positions 57 * \param value array to store servos positions in radians 58 58 * \param time time when shared memory was written 59 59 */
Note:
See TracChangeset
for help on using the changeset viewer.