From a7976b835dd85b0dca2a205f3a747fa2fe5bced4 Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 29 Jul 2009 13:50:39 +0000 Subject: [PATCH] Sync. with JSBSim --- src/FDM/JSBSim/FGState.cpp | 3 +- .../JSBSim/input_output/FGPropertyManager.h | 7 +--- src/FDM/JSBSim/models/FGLGear.cpp | 36 +++++++++++-------- .../JSBSim/models/propulsion/FGElectric.cpp | 14 ++++++-- .../JSBSim/models/propulsion/FGPropeller.cpp | 6 +++- .../JSBSim/models/propulsion/FGTurboProp.cpp | 2 +- 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp index 5e659fc1e..a3f51e25b 100644 --- a/src/FDM/JSBSim/FGState.cpp +++ b/src/FDM/JSBSim/FGState.cpp @@ -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(); diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.h b/src/FDM/JSBSim/input_output/FGPropertyManager.h index 8f191fe87..fdd5c4077 100644 --- a/src/FDM/JSBSim/input_output/FGPropertyManager.h +++ b/src/FDM/JSBSim/input_output/FGPropertyManager.h @@ -35,14 +35,9 @@ SENTRY INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include -#include -#include +#include "simgear/props/props.hxx" #include "FGJSBBase.h" diff --git a/src/FDM/JSBSim/models/FGLGear.cpp b/src/FDM/JSBSim/models/FGLGear.cpp index 3031af700..dcb140b8a 100644 --- a/src/FDM/JSBSim/models/FGLGear.cpp +++ b/src/FDM/JSBSim/models/FGLGear.cpp @@ -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; diff --git a/src/FDM/JSBSim/models/propulsion/FGElectric.cpp b/src/FDM/JSBSim/models/propulsion/FGElectric.cpp index 0835c857e..32b05ea19 100644 --- a/src/FDM/JSBSim/models/propulsion/FGElectric.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGElectric.cpp @@ -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(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp b/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp index 28ded4012..3a54175fc 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGPropeller.cpp @@ -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 } diff --git a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp index 3030a16a6..dce831412 100755 --- a/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp @@ -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")) -- 2.39.5