]> git.mxchange.org Git - flightgear.git/commitdiff
Sync. with JSBSim
authorehofman <ehofman>
Wed, 29 Jul 2009 13:50:39 +0000 (13:50 +0000)
committerTim Moore <timoore@redhat.com>
Sat, 8 Aug 2009 06:37:14 +0000 (08:37 +0200)
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/input_output/FGPropertyManager.h
src/FDM/JSBSim/models/FGLGear.cpp
src/FDM/JSBSim/models/propulsion/FGElectric.cpp
src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp

index 5e659fc1e1e8d597b25e2e18c5fdaddc0cd4cd1f..a3f51e25b0e6e88ef511fc1397c11ec8834a8aa3 100644 (file)
@@ -58,7 +58,8 @@ FGState::FGState(FGFDMExec* fdex)
   FDMExec = fdex;
 
   sim_time = 0.0;
-  //dt = 1.0/120.0;
+  dt = 1.0/120.0; // a default timestep size. This is needed for when JSBSim is
+                  // run in standalone mode with no initialization file.
 
   Aircraft     = FDMExec->GetAircraft();
   Propagate    = FDMExec->GetPropagate();
index 8f191fe87fa3cb2b3d174d63c0bb97aacf731b65..fdd5c40776c51a37cbad7f376c1e0d14d7f2281d 100644 (file)
@@ -35,14 +35,9 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
 #include <string>
 #include <iostream>
-#include <simgear/props/props.hxx>
-#include <simgear/math/SGMath.hxx>
+#include "simgear/props/props.hxx"
 
 #include "FGJSBBase.h"
 
index 3031af700ac1ebede657857a2f16b1e1d7b6f12e..dcb140b8aacffc928a539decf7ba33834e173cd3 100644 (file)
@@ -310,15 +310,6 @@ FGColumnVector3& FGLGear::Force(void)
       RollingForce = ((1.0 - TirePressureNorm) * 30 + vLocalForce(eZ) * BrakeFCoeff) * sign;
       SideForce    = vLocalForce(eZ) * FCoeff;
 
-      // Transform these forces back to the local reference frame.
-
-      vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
-      vLocalForce(eY) = SideForce*CosWheel    + RollingForce*SinWheel;
-
-      // Transform the forces back to the body frame and compute the moment.
-
-      vForce  = Propagate->GetTl2b() * vLocalForce;
-
       // Lag and attenuate the XY-plane forces dependent on velocity. This code
       // uses a lag filter, C/(s + C) where "C" is the filter coefficient. When
       // "C" is chosen at the frame rate (in Hz), the jittering is significantly
@@ -326,11 +317,20 @@ FGColumnVector3& FGLGear::Force(void)
       // If a coefficient is set to something equal to or less than zero, the
       // filter is bypassed.
 
-      if (LongForceLagFilterCoeff > 0) vForce(eX) = LongForceFilter.execute(vForce(eX));
-      if (LatForceLagFilterCoeff > 0)  vForce(eY) = LatForceFilter.execute(vForce(eY));
+      if (LongForceLagFilterCoeff > 0) RollingForce = LongForceFilter.execute(RollingForce);
+      if (LatForceLagFilterCoeff > 0)  SideForce = LatForceFilter.execute(SideForce);
 
-      if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
-      if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
+      if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) RollingForce *= fabs(RollingWhlVel)/RFRV;
+      if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) SideForce *= fabs(SideWhlVel)/SFRV;
+
+      // Transform these forces back to the local reference frame.
+
+      vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
+      vLocalForce(eY) = SideForce*CosWheel    + RollingForce*SinWheel;
+
+      // Transform the forces back to the body frame and compute the moment.
+
+      vForce  = Propagate->GetTl2b() * vLocalForce;
 
       // End section for attentuating gear jitter
 
@@ -340,9 +340,14 @@ FGColumnVector3& FGLGear::Force(void)
 
       WOW = false;
       compressLength = 0.0;
+      compressSpeed = 0.0;
+
+      // No wheel conditions
+      SideWhlVel = WheelSlip = 0.0;
 
-      // No wheel conditons
-      RollingWhlVel = SideWhlVel = WheelSlip = 0.0;
+      // Let wheel spin down slowly
+      RollingWhlVel -= 13.0*dT;
+      if (RollingWhlVel < 0.0) RollingWhlVel = 0.0;
 
       // Return to neutral position between 1.0 and 0.8 gear pos.
       SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
@@ -371,6 +376,7 @@ void FGLGear::ComputeRetractionState(void)
     GearUp   = true;
     WOW      = false;
     GearDown = false;
+    RollingWhlVel = 0.0;
   } else if (gearPos > 0.99) {
     GearDown = true;
     GearUp   = false;
index 0835c857eafb4d0549fdd32c70efa26d75e23973..32b05ea19254b273b7fd1f40b69a1acb2cd35fed 100644 (file)
@@ -94,14 +94,24 @@ double FGElectric::Calculate(void)
 
 string FGElectric::GetEngineLabels(string delimeter)
 {
-  return ""; // currently no labels are returned for this engine
+  std::ostringstream buf;
+
+  buf << Name << " HP (engine " << EngineNumber << ")" << delimeter
+      << Thruster->GetThrusterLabels(EngineNumber, delimeter);
+
+  return buf.str();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 string FGElectric::GetEngineValues(string delimeter)
 {
-  return ""; // currently no values are returned for this engine
+  std::ostringstream buf;
+
+  buf << HP << delimeter
+     << Thruster->GetThrusterValues(EngineNumber, delimeter);
+
+  return buf.str();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 28ded401250c0611241ac950156c77b3cf9aa95c..3a54175fc9e887c6c7d8d3989b8154e20d441f36 100644 (file)
@@ -199,6 +199,8 @@ double FGPropeller::Calculate(double PowerAvailable)
   vH(eY) = 0.0;
   vH(eZ) = 0.0;
 
+  vH = Transform()*vH; // Transform rotational momentum to rotated frame (if any)
+
   if (omega > 0.0) ExcessTorque = GearRatio * PowerAvailable / omega;
   else             ExcessTorque = GearRatio * PowerAvailable / 1.0;
 
@@ -206,7 +208,9 @@ double FGPropeller::Calculate(double PowerAvailable)
 
   if (RPM < 1.0) RPM = 0; // Engine friction stops rotation arbitrarily at 1 RPM.
 
-  vMn = fdmex->GetPropagate()->GetPQR()*vH + vTorque;
+  // Transform Torque and momentum prior to this equation, as PQR is used in this
+  // equation and cannot be transformed itself.
+  vMn = fdmex->GetPropagate()->GetPQR()*vH + Transform()*vTorque;
 
   return Thrust; // return thrust in pounds
 }
index 3030a16a68ebdfcfcc9bcbb8b01b51f049e750ef..dce83141299f64d0a81d451f96368096bea93311 100755 (executable)
@@ -91,7 +91,7 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
   if (el->FindElement("idlen1"))
     IdleN1 = el->FindElementValueAsNumber("idlen1");
   if (el->FindElement("idlen2"))
-    IdleN2 = el->FindElementValueAsNumber("idlen1");
+    IdleN2 = el->FindElementValueAsNumber("idlen2");
   if (el->FindElement("maxn1"))
     MaxN1 = el->FindElementValueAsNumber("maxn1");
   if (el->FindElement("maxn2"))