]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/Rotor.cpp
Fixed a bug where a structural to Body frame conversion was being doen twice for...
[flightgear.git] / src / FDM / YASim / Rotor.cpp
index 5e2bf4b4cf451fb0a80957a6bf30697a264ca036..79e5fd128ebc975304296913534d06d4b348eb17 100644 (file)
@@ -1,3 +1,8 @@
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <simgear/debug/logstream.hxx>
 
 #include "Math.hpp"
@@ -8,10 +13,8 @@
 #include "Ground.hpp"
 #include "Rotor.hpp"
 
-#include STL_IOSTREAM
-#include STL_IOMANIP
-
-SG_USING_STD(setprecision);
+#include <iostream>
+#include <iomanip>
 
 #ifdef TEST_DEBUG
 #include <stdio.h>
@@ -20,7 +23,8 @@ SG_USING_STD(setprecision);
 #include <iostream>
 #include <sstream>
 
-
+using std::setprecision;
+using std::endl;
 
 namespace yasim {
 
@@ -699,7 +703,7 @@ void Rotor::setGlobalGround(double *global_ground, float* global_vel)
     for(i=0; i<4; i++) _global_ground[i] = global_ground[i];
 }
 
-void Rotor::setParameter(char *parametername, float value)
+void Rotor::setParameter(const char *parametername, float value)
 {
 #define p(a,b) if (strcmp(parametername,#a)==0) _##a = (value * (b)); else
     p(translift_ve,1)
@@ -732,7 +736,7 @@ void Rotor::setParameter(char *parametername, float value)
         p(rotor_correction_factor,1)
         SG_LOG(SG_INPUT, SG_ALERT,
             "internal error in parameter set up for rotor: '" << 
-            parametername <<"'" << endl);
+               parametername <<"'" << std::endl);
 #undef p
 }
 
@@ -794,7 +798,6 @@ void Rotor::setCyclicail(float lval,float rval)
 void Rotor::setRotorBalance(float lval)
 {
     lval = Math::clamp(lval, -1, 1);
-    int i;
     _balance2 = lval;
 }
 
@@ -819,7 +822,7 @@ void Rotor::calcLiftFactor(float* v, float rho, State *s)
     _f_ge=1+_diameter/_ground_effect_altitude*_ground_effect_constant;
 
     // Now calculate translational lift
-    float v_vert = Math::dot3(v,_normal);
+    // float v_vert = Math::dot3(v,_normal);
     float help[3];
     Math::cross3(v,_normal,help);
     float v_horiz = Math::mag3(help);
@@ -830,6 +833,7 @@ void Rotor::calcLiftFactor(float* v, float rho, State *s)
 
     //store the gravity direction
     Glue::geodUp(s->pos, _grav_direction);
+    s->velGlobalToLocal(_grav_direction, _grav_direction);
 }
 
 void Rotor::findGroundEffectAltitude(Ground * ground_cb,State *s)
@@ -1181,7 +1185,7 @@ void Rotor::compile()
         * _diameter * _rel_blade_center * _rel_blade_center /(0.5*0.5);
     float speed=_rotor_rpm/60*_diameter*_rel_blade_center*pi;
     float lentocenter=_diameter*_rel_blade_center*0.5;
-    float lentoforceattac=_diameter*_rel_len_hinge*0.5;
+    // float lentoforceattac=_diameter*_rel_len_hinge*0.5;
     float zentforce=rotorpartmass*speed*speed/lentocenter;
     float pitchaforce=_force_at_pitch_a/_number_of_parts*.453*9.81;
     // was pounds of force, now N, devided by _number_of_parts
@@ -1196,8 +1200,8 @@ void Rotor::compile()
 
     float relamp=(omega*omega/(2*_delta*Math::sqrt(sqr(omega0*omega0-omega*omega)
         +4*_delta*_delta*omega*omega)))*_cyclic_factor;
-    float relamp_theoretical=(omega*omega/(2*delta_theoretical*Math::sqrt(sqr(omega0*omega0-omega*omega)
-        +4*delta_theoretical*delta_theoretical*omega*omega)))*_cyclic_factor;
+    //float relamp_theoretical=(omega*omega/(2*delta_theoretical*Math::sqrt(sqr(omega0*omega0-omega*omega)
+    //    +4*delta_theoretical*delta_theoretical*omega*omega)))*_cyclic_factor;
     _phi=Math::acos(_rel_len_hinge);
     _phi-=Math::atan(_delta3);
     if (!_no_torque)
@@ -1303,7 +1307,7 @@ void Rotor::compile()
         &(torque[1]),&(lift[1])); //pitch b
     rps[0]->calculateAlpha(v_wind,rho_null,0,0,0,
         &(torque[3]),&(lift[3])); //pitch 0
-    SG_LOG(SG_GENERAL, SG_INFO,
+    SG_LOG(SG_FLIGHT, SG_INFO,
         "Rotor: coefficients for airfoil:" << endl << setprecision(6)
         << " drag0: " << _dragcoef0*_number_of_parts/_number_of_blades/_c2
         << " drag1: " << _dragcoef1*_number_of_parts/_number_of_blades/_c2
@@ -1528,7 +1532,7 @@ void Rotorgear::calcForces(float* torqueOut)
             total_torque+=r->getTorque()*omegan;
         }
         float max_torque_of_engine=0;
-        SGPropertyNode * node=fgGetNode("/rotors/gear", true);
+        // SGPropertyNode * node=fgGetNode("/rotors/gear", true);
         if (_engineon)
         {
             max_torque_of_engine=_max_power_engine*_max_rel_torque;
@@ -1539,6 +1543,8 @@ void Rotorgear::calcForces(float* torqueOut)
         }
         total_torque*=-1;
         _ddt_omegarel=0;
+
+#if 0
         float rel_torque_engine=1;
         if (total_torque<=0)
             rel_torque_engine=0;
@@ -1547,6 +1553,7 @@ void Rotorgear::calcForces(float* torqueOut)
                 rel_torque_engine=1/max_torque_of_engine*total_torque;
             else
                 rel_torque_engine=0;
+#endif
 
         //add the rotor brake and the gear fritcion
         float dt=0.1f;
@@ -1599,7 +1606,7 @@ void Rotorgear::calcForces(float* torqueOut)
             for(j=0; j<_rotors.size(); j++) {
                 Rotor* r = (Rotor*)_rotors.get(j);
                 for(i=0; i<r->_rotorparts.size(); i++) {
-                    float torque_scalar=0;
+                    // float torque_scalar=0;
                     Rotorpart* rp = (Rotorpart*)r->_rotorparts.get(i);
                     float torque[3];
                     rp->getAccelTorque(_ddt_omegarel,torque);
@@ -1619,7 +1626,7 @@ void Rotorgear::addRotor(Rotor* rotor)
 
 void Rotorgear::compile()
 {
-    float wgt = 0;
+    // float wgt = 0;
     for(int j=0; j<_rotors.size(); j++) {
         Rotor* r = (Rotor*)_rotors.get(j);
         r->compile();