2006-01-12 15:04:22 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
Module: FGLGear.cpp
|
|
|
|
Author: Jon S. Berndt
|
|
|
|
Norman H. Princen
|
2009-08-20 05:33:20 +00:00
|
|
|
Bertrand Coconnier
|
2006-01-12 15:04:22 +00:00
|
|
|
Date started: 11/18/99
|
|
|
|
Purpose: Encapsulates the landing gear elements
|
|
|
|
Called by: FGAircraft
|
|
|
|
|
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
2007-01-15 12:48:54 +00:00
|
|
|
the terms of the GNU Lesser General Public License as published by the Free Software
|
2006-01-12 15:04:22 +00:00
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
2007-01-15 12:48:54 +00:00
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
2006-01-12 15:04:22 +00:00
|
|
|
details.
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License along with
|
2006-01-12 15:04:22 +00:00
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
Further information about the GNU Lesser General Public License can also be found on
|
2006-01-12 15:04:22 +00:00
|
|
|
the world wide web at http://www.gnu.org.
|
|
|
|
|
|
|
|
FUNCTIONAL DESCRIPTION
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
11/18/99 JSB Created
|
|
|
|
01/30/01 NHP Extended gear model to properly simulate steering and braking
|
2009-08-20 05:33:20 +00:00
|
|
|
07/08/09 BC Modified gear model to support large angles between aircraft and ground
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
INCLUDES
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
#include "FGLGear.h"
|
|
|
|
|
|
|
|
namespace JSBSim {
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
DEFINITIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
GLOBAL DATA
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
static const char *IdSrc = "$Id$";
|
|
|
|
static const char *IdHdr = ID_LGEAR;
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS IMPLEMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) :
|
|
|
|
GearNumber(number),
|
|
|
|
Exec(fdmex)
|
2006-01-12 15:04:22 +00:00
|
|
|
{
|
|
|
|
Element *force_table=0;
|
2008-08-03 13:52:45 +00:00
|
|
|
Element *dampCoeff=0;
|
|
|
|
Element *dampCoeffRebound=0;
|
2006-01-12 15:04:22 +00:00
|
|
|
string force_type="";
|
|
|
|
|
|
|
|
kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0;
|
|
|
|
sSteerType = sBrakeGroup = sSteerType = "";
|
|
|
|
isRetractable = 0;
|
2008-08-03 13:52:45 +00:00
|
|
|
eDampType = dtLinear;
|
|
|
|
eDampTypeRebound = dtLinear;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
name = el->GetAttributeValue("name");
|
|
|
|
sContactType = el->GetAttributeValue("type");
|
2008-07-10 17:23:02 +00:00
|
|
|
if (sContactType == "BOGEY") {
|
|
|
|
eContactType = ctBOGEY;
|
|
|
|
} else if (sContactType == "STRUCTURE") {
|
|
|
|
eContactType = ctSTRUCTURE;
|
|
|
|
} else {
|
|
|
|
eContactType = ctUNKNOWN;
|
|
|
|
}
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
if (el->FindElement("spring_coeff"))
|
|
|
|
kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
|
2008-08-03 13:52:45 +00:00
|
|
|
if (el->FindElement("damping_coeff")) {
|
|
|
|
dampCoeff = el->FindElement("damping_coeff");
|
|
|
|
if (dampCoeff->GetAttributeValue("type") == "SQUARE") {
|
2008-08-14 14:16:50 +00:00
|
|
|
eDampType = dtSquare;
|
|
|
|
bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT2/SEC2");
|
2008-08-03 13:52:45 +00:00
|
|
|
} else {
|
|
|
|
bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
|
|
|
|
}
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2008-08-03 13:52:45 +00:00
|
|
|
if (el->FindElement("damping_coeff_rebound")) {
|
|
|
|
dampCoeffRebound = el->FindElement("damping_coeff_rebound");
|
|
|
|
if (dampCoeffRebound->GetAttributeValue("type") == "SQUARE") {
|
2008-08-14 14:16:50 +00:00
|
|
|
eDampTypeRebound = dtSquare;
|
|
|
|
bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT2/SEC2");
|
2008-08-03 13:52:45 +00:00
|
|
|
} else {
|
|
|
|
bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
|
|
|
|
}
|
|
|
|
} else {
|
2006-01-12 15:04:22 +00:00
|
|
|
bDampRebound = bDamp;
|
2008-08-03 13:52:45 +00:00
|
|
|
eDampTypeRebound = eDampType;
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
if (el->FindElement("dynamic_friction"))
|
|
|
|
dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
|
|
|
|
if (el->FindElement("static_friction"))
|
|
|
|
staticFCoeff = el->FindElementValueAsNumber("static_friction");
|
|
|
|
if (el->FindElement("rolling_friction"))
|
|
|
|
rollingFCoeff = el->FindElementValueAsNumber("rolling_friction");
|
|
|
|
if (el->FindElement("max_steer"))
|
|
|
|
maxSteerAngle = el->FindElementValueAsNumberConvertTo("max_steer", "DEG");
|
|
|
|
if (el->FindElement("retractable"))
|
2007-06-03 09:37:02 +00:00
|
|
|
isRetractable = ((unsigned int)el->FindElementValueAsNumber("retractable"))>0.0?true:false;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
ForceY_Table = 0;
|
|
|
|
force_table = el->FindElement("table");
|
|
|
|
while (force_table) {
|
|
|
|
force_type = force_table->GetAttributeValue("type");
|
|
|
|
if (force_type == "CORNERING_COEFF") {
|
|
|
|
ForceY_Table = new FGTable(Exec->GetPropertyManager(), force_table);
|
|
|
|
} else {
|
|
|
|
cerr << "Undefined force table for " << name << " contact point" << endl;
|
|
|
|
}
|
|
|
|
force_table = el->FindNextElement("table");
|
|
|
|
}
|
|
|
|
|
|
|
|
sBrakeGroup = el->FindElementValue("brake_group");
|
|
|
|
|
|
|
|
if (maxSteerAngle == 360) sSteerType = "CASTERED";
|
|
|
|
else if (maxSteerAngle == 0.0) sSteerType = "FIXED";
|
|
|
|
else sSteerType = "STEERABLE";
|
|
|
|
|
|
|
|
Element* element = el->FindElement("location");
|
|
|
|
if (element) vXYZ = element->FindElementTripletConvertTo("IN");
|
|
|
|
else {cerr << "No location given for contact " << name << endl; exit(-1);}
|
|
|
|
|
|
|
|
if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
|
|
|
|
else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
|
|
|
|
else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
|
|
|
|
else if (sBrakeGroup == "NOSE" ) eBrakeGrp = bgNose;
|
|
|
|
else if (sBrakeGroup == "TAIL" ) eBrakeGrp = bgTail;
|
|
|
|
else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone;
|
|
|
|
else if (sBrakeGroup.empty() ) {eBrakeGrp = bgNone;
|
|
|
|
sBrakeGroup = "NONE (defaulted)";}
|
|
|
|
else {
|
|
|
|
cerr << "Improper braking group specification in config file: "
|
|
|
|
<< sBrakeGroup << " is undefined." << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sSteerType == "STEERABLE") eSteerType = stSteer;
|
|
|
|
else if (sSteerType == "FIXED" ) eSteerType = stFixed;
|
|
|
|
else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
|
|
|
|
else if (sSteerType.empty() ) {eSteerType = stFixed;
|
|
|
|
sSteerType = "FIXED (defaulted)";}
|
|
|
|
else {
|
|
|
|
cerr << "Improper steering type specification in config file: "
|
|
|
|
<< sSteerType << " is undefined." << endl;
|
|
|
|
}
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
RFRV = 0.7; // Rolling force relaxation velocity, default value
|
|
|
|
SFRV = 0.7; // Side force relaxation velocity, default value
|
|
|
|
|
|
|
|
Element* relax_vel = el->FindElement("relaxation_velocity");
|
|
|
|
if (relax_vel) {
|
|
|
|
if (relax_vel->FindElement("rolling")) {
|
|
|
|
RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
|
|
|
|
}
|
|
|
|
if (relax_vel->FindElement("side")) {
|
|
|
|
SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
State = Exec->GetState();
|
|
|
|
LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
|
|
|
|
LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
|
|
|
|
|
|
|
|
Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
|
|
|
|
if (force_lag_filter_elem) {
|
|
|
|
if (force_lag_filter_elem->FindElement("rolling")) {
|
|
|
|
LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
|
|
|
|
}
|
|
|
|
if (force_lag_filter_elem->FindElement("side")) {
|
|
|
|
LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-06 19:53:51 +00:00
|
|
|
LongForceFilter = Filter(LongForceLagFilterCoeff, State->Getdt());
|
|
|
|
LatForceFilter = Filter(LatForceLagFilterCoeff, State->Getdt());
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
WheelSlipLagFilterCoeff = 1/State->Getdt();
|
|
|
|
|
|
|
|
Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
|
|
|
|
if (wheel_slip_angle_lag_elem) {
|
|
|
|
WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
|
|
|
|
}
|
|
|
|
|
2009-02-06 19:53:51 +00:00
|
|
|
WheelSlipFilter = Filter(WheelSlipLagFilterCoeff, State->Getdt());
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
GearUp = false;
|
|
|
|
GearDown = true;
|
2008-07-10 17:23:02 +00:00
|
|
|
GearPos = 1.0;
|
|
|
|
useFCSGearPos = false;
|
2006-01-12 15:04:22 +00:00
|
|
|
Servicable = true;
|
|
|
|
|
|
|
|
// Add some AI here to determine if gear is located properly according to its
|
|
|
|
// brake group type ??
|
|
|
|
|
|
|
|
State = Exec->GetState();
|
|
|
|
Aircraft = Exec->GetAircraft();
|
|
|
|
Propagate = Exec->GetPropagate();
|
|
|
|
Auxiliary = Exec->GetAuxiliary();
|
|
|
|
FCS = Exec->GetFCS();
|
|
|
|
MassBalance = Exec->GetMassBalance();
|
|
|
|
|
2007-01-20 09:28:53 +00:00
|
|
|
WOW = lastWOW = false;
|
2006-01-12 15:04:22 +00:00
|
|
|
ReportEnable = true;
|
|
|
|
FirstContact = false;
|
|
|
|
StartedGroundRun = false;
|
|
|
|
TakeoffReported = LandingReported = false;
|
|
|
|
LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
|
|
|
|
MaximumStrutForce = MaximumStrutTravel = 0.0;
|
|
|
|
SinkRate = GroundSpeed = 0.0;
|
|
|
|
|
|
|
|
vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
|
|
|
|
|
|
|
|
vLocalGear = Propagate->GetTb2l() * vWhlBodyVec;
|
|
|
|
|
2009-08-20 05:33:20 +00:00
|
|
|
vLocalWhlVel.InitMatrix();
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
compressLength = 0.0;
|
|
|
|
compressSpeed = 0.0;
|
|
|
|
brakePct = 0.0;
|
|
|
|
maxCompLen = 0.0;
|
|
|
|
|
2007-01-15 12:48:54 +00:00
|
|
|
WheelSlip = 0.0;
|
2006-01-12 15:04:22 +00:00
|
|
|
TirePressureNorm = 1.0;
|
|
|
|
|
2009-03-25 10:00:46 +00:00
|
|
|
// Set Pacejka terms
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-03-25 10:00:46 +00:00
|
|
|
Stiffness = 0.06;
|
|
|
|
Shape = 2.8;
|
|
|
|
Peak = staticFCoeff;
|
|
|
|
Curvature = 1.03;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-03-25 10:00:46 +00:00
|
|
|
Debug(0);
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
FGLGear::~FGLGear()
|
|
|
|
{
|
2009-05-10 12:23:35 +00:00
|
|
|
delete ForceY_Table;
|
2006-01-12 15:04:22 +00:00
|
|
|
Debug(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
FGColumnVector3& FGLGear::Force(void)
|
|
|
|
{
|
|
|
|
double t = Exec->GetState()->Getsim_time();
|
2007-01-15 12:48:54 +00:00
|
|
|
dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
vForce.InitMatrix();
|
2009-08-20 05:33:20 +00:00
|
|
|
vLocalForce.InitMatrix();
|
2006-01-12 15:04:22 +00:00
|
|
|
vMoment.InitMatrix();
|
|
|
|
|
|
|
|
if (isRetractable) ComputeRetractionState();
|
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
if (GearDown) {
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
vWhlBodyVec = MassBalance->StructuralToBody(vXYZ); // Get wheel in body frame
|
|
|
|
vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
|
2009-08-20 05:33:20 +00:00
|
|
|
// Compute the height of the theoritical location of the wheel (if struct was not compressed) with
|
|
|
|
// respect to the ground level
|
|
|
|
double height = Exec->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
|
|
|
|
vGroundNormal = -1. * Propagate->GetTec2b() * normal;
|
|
|
|
|
|
|
|
switch (eContactType) {
|
|
|
|
case ctBOGEY:
|
|
|
|
// Project the height in the local coordinate frame of the strut to compute the actual compression
|
|
|
|
// length. The strut is assumed to be parallel to Z in the body frame.
|
|
|
|
compressLength = vGroundNormal(eZ) < 0.0 ? height / vGroundNormal(eZ) : 0.0;
|
|
|
|
break;
|
|
|
|
case ctSTRUCTURE:
|
|
|
|
compressLength = -height;
|
|
|
|
break;
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
if (compressLength > 0.00) {
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
WOW = true;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
// [The next equation should really use the vector to the contact patch of
|
|
|
|
// the tire including the strut compression and not the original vWhlBodyVec.]
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-08-20 05:33:20 +00:00
|
|
|
FGColumnVector3 vWhlContactVec = vWhlBodyVec - FGColumnVector3(0., 0., compressLength);
|
|
|
|
vWhlVelVec = Propagate->GetPQR() * vWhlContactVec;
|
|
|
|
vWhlVelVec += Propagate->GetUVW() - Propagate->GetTec2b() * cvel;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
InitializeReporting();
|
|
|
|
ComputeSteeringAngle();
|
2009-08-20 05:33:20 +00:00
|
|
|
ComputeGroundCoordSys();
|
|
|
|
|
|
|
|
vLocalWhlVel = Tb2g * vWhlVelVec;
|
|
|
|
|
|
|
|
compressSpeed = -vLocalWhlVel(eZ);
|
|
|
|
if (eContactType == ctBOGEY)
|
|
|
|
// Project the compression speed in the local coordinate frame of the strut
|
|
|
|
compressSpeed /= -vGroundNormal(eZ);
|
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
ComputeVerticalStrutForce();
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
// Compute the forces in the wheel ground plane.
|
2009-08-20 05:33:20 +00:00
|
|
|
if (eContactType == ctBOGEY) {
|
|
|
|
ComputeSlipAngle();
|
|
|
|
ComputeBrakeForceCoefficient();
|
|
|
|
ComputeSideForceCoefficient();
|
|
|
|
double sign = vLocalWhlVel(eX)>0?1.0:(vLocalWhlVel(eX)<0?-1.0:0.0);
|
|
|
|
vLocalForce(eX) = - ((1.0 - TirePressureNorm) * 30 + vLocalForce(eZ) * BrakeFCoeff) * sign;
|
|
|
|
vLocalForce(eY) = vLocalForce(eZ) * FCoeff;
|
|
|
|
}
|
|
|
|
else if (eContactType == ctSTRUCTURE) {
|
|
|
|
FGColumnVector3 vSlipVec = vLocalWhlVel;
|
|
|
|
vSlipVec(eZ) = 0.;
|
|
|
|
vSlipVec.Normalize();
|
|
|
|
vLocalForce -= staticFCoeff * vLocalForce(eZ) * vSlipVec;
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-02-06 19:53:51 +00:00
|
|
|
// 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
|
|
|
|
// reduced. This is because the jitter is present *at* the execution rate.
|
|
|
|
// If a coefficient is set to something equal to or less than zero, the
|
|
|
|
// filter is bypassed.
|
|
|
|
|
2009-08-20 05:33:20 +00:00
|
|
|
if (LongForceLagFilterCoeff > 0) vLocalForce(eX) = LongForceFilter.execute(vLocalForce(eX));
|
|
|
|
if (LatForceLagFilterCoeff > 0) vLocalForce(eY) = LatForceFilter.execute(vLocalForce(eY));
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-08-20 05:33:20 +00:00
|
|
|
if ((fabs(vLocalWhlVel(eX)) <= RFRV) && RFRV > 0) vLocalForce(eX) *= fabs(vLocalWhlVel(eX))/RFRV;
|
|
|
|
if ((fabs(vLocalWhlVel(eY)) <= SFRV) && SFRV > 0) vLocalForce(eY) *= fabs(vLocalWhlVel(eY))/SFRV;
|
2009-07-29 13:50:39 +00:00
|
|
|
|
2009-08-20 05:33:20 +00:00
|
|
|
// End section for attenuating gear jitter
|
2009-07-29 13:50:39 +00:00
|
|
|
|
|
|
|
// Transform the forces back to the body frame and compute the moment.
|
|
|
|
|
2009-08-20 05:33:20 +00:00
|
|
|
vForce = Tg2b * vLocalForce;
|
|
|
|
vMoment = vWhlContactVec * vForce;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
} else { // Gear is NOT compressed
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
WOW = false;
|
|
|
|
compressLength = 0.0;
|
2009-07-29 13:50:39 +00:00
|
|
|
compressSpeed = 0.0;
|
|
|
|
|
|
|
|
// Let wheel spin down slowly
|
2009-08-20 05:33:20 +00:00
|
|
|
vLocalWhlVel(eX) -= 13.0*dT;
|
|
|
|
if (vLocalWhlVel(eX) < 0.0) vLocalWhlVel(eX) = 0.0;
|
2009-04-13 11:47:57 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
// Return to neutral position between 1.0 and 0.8 gear pos.
|
|
|
|
SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
2009-01-26 20:36:17 +00:00
|
|
|
ResetReporting();
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ReportTakeoffOrLanding();
|
2008-07-10 17:23:02 +00:00
|
|
|
|
|
|
|
// Require both WOW and LastWOW to be true before checking crash conditions
|
|
|
|
// to allow the WOW flag to be used in terminating a scripted run.
|
|
|
|
if (WOW && lastWOW) CrashDetect();
|
|
|
|
|
|
|
|
lastWOW = WOW;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
return vForce;
|
|
|
|
}
|
|
|
|
|
2009-08-20 05:33:20 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// Build a local "ground" coordinate system defined by
|
|
|
|
// eX : projection of the rolling direction on the ground
|
|
|
|
// eY : projection of the sliping direction on the ground
|
|
|
|
// eZ : normal to the ground
|
|
|
|
|
|
|
|
void FGLGear::ComputeGroundCoordSys(void)
|
|
|
|
{
|
|
|
|
// Compute the rolling direction projected on the ground
|
|
|
|
// It consists in finding a vector 'r' such that 'r' lies in the plane (w,z) and r.n = 0 (scalar
|
|
|
|
// product) where:
|
|
|
|
// 'n' is the normal to the ground,
|
|
|
|
// (x,y,z) are the directions defined in the body coord system
|
|
|
|
// and 'w' is 'x' rotated by the steering angle (SteerAngle) in the plane (x,y).
|
|
|
|
// r = u * w + v * z and r.n = 0 => v/u = -w.n/z.n = a
|
|
|
|
// We also want u**2+v**2=1 and u > 0 (i.e. r orientated in the same 'direction' than w)
|
|
|
|
// after some arithmetic, one finds that :
|
|
|
|
double a = -(vGroundNormal(eX)*cos(SteerAngle)+vGroundNormal(eY)*sin(SteerAngle)) / vGroundNormal(eZ);
|
|
|
|
double u = 1. / sqrt(1. + a*a);
|
|
|
|
double v = a * u;
|
|
|
|
FGColumnVector3 vRollingGroundVec = FGColumnVector3(u * cos(SteerAngle), u * sin(SteerAngle), v);
|
|
|
|
|
|
|
|
// The sliping direction is the cross product multiplication of the ground normal and rolling
|
|
|
|
// directions
|
|
|
|
FGColumnVector3 vSlipGroundVec = vGroundNormal * vRollingGroundVec;
|
|
|
|
|
|
|
|
Tg2b(1,1) = vRollingGroundVec(eX);
|
|
|
|
Tg2b(2,1) = vRollingGroundVec(eY);
|
|
|
|
Tg2b(3,1) = vRollingGroundVec(eZ);
|
|
|
|
Tg2b(1,2) = vSlipGroundVec(eX);
|
|
|
|
Tg2b(2,2) = vSlipGroundVec(eY);
|
|
|
|
Tg2b(3,2) = vSlipGroundVec(eZ);
|
|
|
|
Tg2b(1,3) = vGroundNormal(eX);
|
|
|
|
Tg2b(2,3) = vGroundNormal(eY);
|
|
|
|
Tg2b(3,3) = vGroundNormal(eZ);
|
|
|
|
|
|
|
|
Tb2g = Tg2b.Transposed();
|
|
|
|
}
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGLGear::ComputeRetractionState(void)
|
|
|
|
{
|
2008-07-10 17:23:02 +00:00
|
|
|
double gearPos = GetGearUnitPos();
|
|
|
|
if (gearPos < 0.01) {
|
2006-01-12 15:04:22 +00:00
|
|
|
GearUp = true;
|
2009-01-26 20:36:17 +00:00
|
|
|
WOW = false;
|
2006-01-12 15:04:22 +00:00
|
|
|
GearDown = false;
|
2009-08-20 05:33:20 +00:00
|
|
|
vLocalWhlVel.InitMatrix();
|
2008-07-10 17:23:02 +00:00
|
|
|
} else if (gearPos > 0.99) {
|
2006-01-12 15:04:22 +00:00
|
|
|
GearDown = true;
|
|
|
|
GearUp = false;
|
|
|
|
} else {
|
|
|
|
GearUp = false;
|
|
|
|
GearDown = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGLGear::ComputeSlipAngle(void)
|
|
|
|
{
|
|
|
|
// Calculate tire slip angle.
|
2009-08-20 05:33:20 +00:00
|
|
|
WheelSlip = -atan2(vLocalWhlVel(eY), fabs(vLocalWhlVel(eX)))*radtodeg;
|
2007-01-15 12:48:54 +00:00
|
|
|
|
2007-06-03 09:37:02 +00:00
|
|
|
// Filter the wheel slip angle
|
2009-02-06 19:53:51 +00:00
|
|
|
if (WheelSlipLagFilterCoeff > 0) WheelSlip = WheelSlipFilter.execute(WheelSlip);
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// Compute the steering angle in any case.
|
|
|
|
// This will also make sure that animations will look right.
|
|
|
|
|
|
|
|
void FGLGear::ComputeSteeringAngle(void)
|
|
|
|
{
|
|
|
|
switch (eSteerType) {
|
|
|
|
case stSteer:
|
|
|
|
SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
|
|
|
|
break;
|
|
|
|
case stFixed:
|
|
|
|
SteerAngle = 0.0;
|
|
|
|
break;
|
|
|
|
case stCaster:
|
2009-08-20 05:33:20 +00:00
|
|
|
SteerAngle = atan2(fabs(vWhlVelVec(eX)), vWhlVelVec(eY));
|
2006-01-12 15:04:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cerr << "Improper steering type membership detected for this gear." << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// Reset reporting functionality after takeoff
|
|
|
|
|
|
|
|
void FGLGear::ResetReporting(void)
|
|
|
|
{
|
|
|
|
if (Propagate->GetDistanceAGL() > 200.0) {
|
|
|
|
FirstContact = false;
|
|
|
|
StartedGroundRun = false;
|
|
|
|
LandingReported = false;
|
2008-07-10 17:23:02 +00:00
|
|
|
TakeoffReported = true;
|
2006-01-12 15:04:22 +00:00
|
|
|
LandingDistanceTraveled = 0.0;
|
|
|
|
MaximumStrutForce = MaximumStrutTravel = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGLGear::InitializeReporting(void)
|
|
|
|
{
|
|
|
|
// If this is the first time the wheel has made contact, remember some values
|
|
|
|
// for later printout.
|
|
|
|
|
|
|
|
if (!FirstContact) {
|
|
|
|
FirstContact = true;
|
|
|
|
SinkRate = compressSpeed;
|
|
|
|
GroundSpeed = Propagate->GetVel().Magnitude();
|
|
|
|
TakeoffReported = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the takeoff run is starting, initialize.
|
|
|
|
|
|
|
|
if ((Propagate->GetVel().Magnitude() > 0.1) &&
|
|
|
|
(FCS->GetBrake(bgLeft) == 0) &&
|
|
|
|
(FCS->GetBrake(bgRight) == 0) &&
|
2008-07-10 17:23:02 +00:00
|
|
|
(FCS->GetThrottlePos(0) > 0.90) && !StartedGroundRun)
|
2006-01-12 15:04:22 +00:00
|
|
|
{
|
|
|
|
TakeoffDistanceTraveled = 0;
|
|
|
|
TakeoffDistanceTraveled50ft = 0;
|
|
|
|
StartedGroundRun = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// Takeoff and landing reporting functionality
|
|
|
|
|
|
|
|
void FGLGear::ReportTakeoffOrLanding(void)
|
|
|
|
{
|
|
|
|
double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
|
|
|
|
|
2008-07-10 17:23:02 +00:00
|
|
|
if (FirstContact)
|
|
|
|
LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
if (StartedGroundRun) {
|
2009-01-26 20:36:17 +00:00
|
|
|
TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
|
2006-01-12 15:04:22 +00:00
|
|
|
if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
|
|
|
|
}
|
|
|
|
|
2008-07-10 17:23:02 +00:00
|
|
|
if ( ReportEnable
|
|
|
|
&& Auxiliary->GetVground() <= 0.05
|
|
|
|
&& !LandingReported
|
|
|
|
&& Exec->GetGroundReactions()->GetWOW())
|
|
|
|
{
|
2006-01-12 15:04:22 +00:00
|
|
|
if (debug_lvl > 0) Report(erLand);
|
|
|
|
}
|
|
|
|
|
2008-07-10 17:23:02 +00:00
|
|
|
if ( ReportEnable
|
|
|
|
&& !TakeoffReported
|
|
|
|
&& (Propagate->GetDistanceAGL() - vLocalGear(eZ)) > 50.0
|
|
|
|
&& !Exec->GetGroundReactions()->GetWOW())
|
2006-01-12 15:04:22 +00:00
|
|
|
{
|
|
|
|
if (debug_lvl > 0) Report(erTakeoff);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// Crash detection logic (really out-of-bounds detection)
|
|
|
|
|
|
|
|
void FGLGear::CrashDetect(void)
|
|
|
|
{
|
2007-01-15 12:48:54 +00:00
|
|
|
if ( (compressLength > 500.0 ||
|
2006-01-12 15:04:22 +00:00
|
|
|
vForce.Magnitude() > 100000000.0 ||
|
|
|
|
vMoment.Magnitude() > 5000000000.0 ||
|
2007-01-15 12:48:54 +00:00
|
|
|
SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
|
2006-01-12 15:04:22 +00:00
|
|
|
{
|
|
|
|
PutMessage("Crash Detected: Simulation FREEZE.");
|
|
|
|
State->SuspendIntegration();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// The following needs work regarding friction coefficients and braking and
|
|
|
|
// steering The BrakeFCoeff formula assumes that an anti-skid system is used.
|
|
|
|
// It also assumes that we won't be turning and braking at the same time.
|
|
|
|
// Will fix this later.
|
|
|
|
// [JSB] The braking force coefficients include normal rolling coefficient +
|
|
|
|
// a percentage of the static friction coefficient based on braking applied.
|
|
|
|
|
|
|
|
void FGLGear::ComputeBrakeForceCoefficient(void)
|
|
|
|
{
|
|
|
|
switch (eBrakeGrp) {
|
|
|
|
case bgLeft:
|
|
|
|
BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
|
|
|
|
staticFCoeff*FCS->GetBrake(bgLeft) );
|
|
|
|
break;
|
|
|
|
case bgRight:
|
|
|
|
BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
|
|
|
|
staticFCoeff*FCS->GetBrake(bgRight) );
|
|
|
|
break;
|
|
|
|
case bgCenter:
|
|
|
|
BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
|
|
|
|
staticFCoeff*FCS->GetBrake(bgCenter) );
|
|
|
|
break;
|
|
|
|
case bgNose:
|
|
|
|
BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
|
|
|
|
staticFCoeff*FCS->GetBrake(bgCenter) );
|
|
|
|
break;
|
|
|
|
case bgTail:
|
|
|
|
BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
|
|
|
|
staticFCoeff*FCS->GetBrake(bgCenter) );
|
|
|
|
break;
|
|
|
|
case bgNone:
|
|
|
|
BrakeFCoeff = rollingFCoeff;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cerr << "Improper brake group membership detected for this gear." << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2009-03-25 10:00:46 +00:00
|
|
|
// Compute the sideforce coefficients using Pacejka's Magic Formula.
|
|
|
|
//
|
|
|
|
// y(x) = D sin {C arctan [Bx - E(Bx - arctan Bx)]}
|
|
|
|
//
|
|
|
|
// Where: B = Stiffness Factor (0.06, here)
|
|
|
|
// C = Shape Factor (2.8, here)
|
|
|
|
// D = Peak Factor (0.8, here)
|
|
|
|
// E = Curvature Factor (1.03, here)
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
void FGLGear::ComputeSideForceCoefficient(void)
|
|
|
|
{
|
|
|
|
if (ForceY_Table) {
|
|
|
|
FCoeff = ForceY_Table->GetValue(WheelSlip);
|
|
|
|
} else {
|
2009-03-25 10:00:46 +00:00
|
|
|
double StiffSlip = Stiffness*WheelSlip;
|
|
|
|
FCoeff = Peak * sin(Shape*atan(StiffSlip - Curvature*(StiffSlip - atan(StiffSlip))));
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// Compute the vertical force on the wheel using square-law damping (per comment
|
|
|
|
// in paper AIAA-2000-4303 - see header prologue comments). We might consider
|
|
|
|
// allowing for both square and linear damping force calculation. Also need to
|
|
|
|
// possibly give a "rebound damping factor" that differs from the compression
|
|
|
|
// case.
|
|
|
|
|
|
|
|
void FGLGear::ComputeVerticalStrutForce(void)
|
|
|
|
{
|
|
|
|
double springForce = 0;
|
|
|
|
double dampForce = 0;
|
|
|
|
|
|
|
|
springForce = -compressLength * kSpring;
|
|
|
|
|
|
|
|
if (compressSpeed >= 0.0) {
|
2008-08-03 13:52:45 +00:00
|
|
|
|
|
|
|
if (eDampType == dtLinear) dampForce = -compressSpeed * bDamp;
|
|
|
|
else dampForce = -compressSpeed * compressSpeed * bDamp;
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
} else {
|
2008-08-03 13:52:45 +00:00
|
|
|
|
|
|
|
if (eDampTypeRebound == dtLinear)
|
|
|
|
dampForce = -compressSpeed * bDampRebound;
|
|
|
|
else
|
|
|
|
dampForce = compressSpeed * compressSpeed * bDampRebound;
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
2009-08-20 05:33:20 +00:00
|
|
|
|
|
|
|
StrutForce = min(springForce + dampForce, (double)0.0);
|
|
|
|
|
|
|
|
// The reaction force of the wheel is always normal to the ground
|
|
|
|
switch (eContactType) {
|
|
|
|
case ctBOGEY:
|
|
|
|
// Project back the strut force in the local coordinate frame of the ground
|
|
|
|
vLocalForce(eZ) = StrutForce / vGroundNormal(eZ);
|
|
|
|
break;
|
|
|
|
case ctSTRUCTURE:
|
|
|
|
vLocalForce(eZ) = -StrutForce;
|
|
|
|
break;
|
|
|
|
}
|
2006-01-12 15:04:22 +00:00
|
|
|
|
|
|
|
// Remember these values for reporting
|
2009-08-20 05:33:20 +00:00
|
|
|
MaximumStrutForce = max(MaximumStrutForce, fabs(StrutForce));
|
2008-06-06 21:21:57 +00:00
|
|
|
MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2008-07-10 17:23:02 +00:00
|
|
|
double FGLGear::GetGearUnitPos(void)
|
2006-01-12 15:04:22 +00:00
|
|
|
{
|
2008-07-10 17:23:02 +00:00
|
|
|
// hack to provide backward compatibility to gear/gear-pos-norm property
|
|
|
|
if( useFCSGearPos || FCS->GetGearPos() != 1.0 ) {
|
|
|
|
useFCSGearPos = true;
|
|
|
|
return FCS->GetGearPos();
|
|
|
|
}
|
|
|
|
return GearPos;
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2008-07-10 17:23:02 +00:00
|
|
|
void FGLGear::bind(void)
|
2006-01-12 15:04:22 +00:00
|
|
|
{
|
2009-02-06 19:53:51 +00:00
|
|
|
string property_name;
|
|
|
|
string base_property_name;
|
|
|
|
base_property_name = CreateIndexedPropertyName("gear/unit", GearNumber);
|
2008-07-10 17:23:02 +00:00
|
|
|
if (eContactType == ctBOGEY) {
|
2009-02-06 19:53:51 +00:00
|
|
|
property_name = base_property_name + "/slip-angle-deg";
|
|
|
|
Exec->GetPropertyManager()->Tie( property_name.c_str(), &WheelSlip );
|
|
|
|
property_name = base_property_name + "/WOW";
|
|
|
|
Exec->GetPropertyManager()->Tie( property_name.c_str(), &WOW );
|
|
|
|
property_name = base_property_name + "/wheel-speed-fps";
|
2009-08-20 05:33:20 +00:00
|
|
|
Exec->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
|
|
|
|
&FGLGear::GetWheelRollVel);
|
2009-02-06 19:53:51 +00:00
|
|
|
property_name = base_property_name + "/z-position";
|
|
|
|
Exec->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
|
2008-07-10 17:23:02 +00:00
|
|
|
&FGLGear::GetZPosition, &FGLGear::SetZPosition);
|
2009-02-06 19:53:51 +00:00
|
|
|
property_name = base_property_name + "/compression-ft";
|
|
|
|
Exec->GetPropertyManager()->Tie( property_name.c_str(), &compressLength );
|
2009-03-25 10:00:46 +00:00
|
|
|
property_name = base_property_name + "/side_friction_coeff";
|
|
|
|
Exec->GetPropertyManager()->Tie( property_name.c_str(), &FCoeff );
|
2009-08-16 19:36:55 +00:00
|
|
|
|
|
|
|
property_name = base_property_name + "/static_friction_coeff";
|
|
|
|
Exec->GetPropertyManager()->Tie( property_name.c_str(), &staticFCoeff );
|
|
|
|
|
2008-07-10 17:23:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( isRetractable ) {
|
2009-02-06 19:53:51 +00:00
|
|
|
property_name = base_property_name + "/pos-norm";
|
|
|
|
Exec->GetPropertyManager()->Tie( property_name.c_str(), &GearPos );
|
2008-07-10 17:23:02 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
void FGLGear::Report(ReportType repType)
|
|
|
|
{
|
2009-01-26 20:36:17 +00:00
|
|
|
if (fabs(TakeoffDistanceTraveled) < 0.001) return; // Don't print superfluous reports
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
switch(repType) {
|
|
|
|
case erLand:
|
2009-06-01 08:52:34 +00:00
|
|
|
cout << endl << "Touchdown report for " << name << " (WOW at time: "
|
|
|
|
<< Exec->GetState()->Getsim_time() << " seconds)" << endl;
|
2006-01-12 15:04:22 +00:00
|
|
|
cout << " Sink rate at contact: " << SinkRate << " fps, "
|
|
|
|
<< SinkRate*0.3048 << " mps" << endl;
|
|
|
|
cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
|
|
|
|
<< GroundSpeed*0.3048 << " mps" << endl;
|
|
|
|
cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
|
|
|
|
<< MaximumStrutForce*4.448 << " Newtons" << endl;
|
|
|
|
cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
|
|
|
|
<< MaximumStrutTravel*30.48 << " cm" << endl;
|
|
|
|
cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
|
|
|
|
<< LandingDistanceTraveled*0.3048 << " meters" << endl;
|
|
|
|
LandingReported = true;
|
|
|
|
break;
|
|
|
|
case erTakeoff:
|
2009-06-01 08:52:34 +00:00
|
|
|
cout << endl << "Takeoff report for " << name << " (Liftoff at time: "
|
|
|
|
<< Exec->GetState()->Getsim_time() << " seconds)" << endl;
|
2006-01-12 15:04:22 +00:00
|
|
|
cout << " Distance traveled: " << TakeoffDistanceTraveled
|
|
|
|
<< " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
|
|
|
|
cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
|
|
|
|
<< " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
|
2009-06-01 08:52:34 +00:00
|
|
|
cout << " [Altitude (ASL): " << Exec->GetPropagate()->GetAltitudeASL() << " ft. / "
|
|
|
|
<< Exec->GetPropagate()->GetAltitudeASLmeters() << " m | Temperature: "
|
|
|
|
<< Exec->GetAtmosphere()->GetTemperature() - 459.67 << " F / "
|
|
|
|
<< RankineToCelsius(Exec->GetAtmosphere()->GetTemperature()) << " C]" << endl;
|
|
|
|
cout << " [Velocity (KCAS): " << Exec->GetAuxiliary()->GetVcalibratedKTS() << "]" << endl;
|
2006-01-12 15:04:22 +00:00
|
|
|
TakeoffReported = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
// The bitmasked value choices are as follows:
|
|
|
|
// unset: In this case (the default) JSBSim would only print
|
|
|
|
// out the normally expected messages, essentially echoing
|
|
|
|
// the config files as they are read. If the environment
|
|
|
|
// variable is not set, debug_lvl is set to 1 internally
|
|
|
|
// 0: This requests JSBSim not to output any messages
|
|
|
|
// whatsoever.
|
|
|
|
// 1: This value explicity requests the normal JSBSim
|
|
|
|
// startup messages
|
|
|
|
// 2: This value asks for a message to be printed out when
|
|
|
|
// a class is instantiated
|
|
|
|
// 4: When this value is set, a message is displayed when a
|
|
|
|
// FGModel object executes its Run() method
|
|
|
|
// 8: When this value is set, various runtime state variables
|
|
|
|
// are printed out periodically
|
|
|
|
// 16: When set various parameters are sanity checked and
|
|
|
|
// a message is printed out when they go out of bounds
|
|
|
|
|
|
|
|
void FGLGear::Debug(int from)
|
|
|
|
{
|
|
|
|
if (debug_lvl <= 0) return;
|
|
|
|
|
|
|
|
if (debug_lvl & 1) { // Standard console startup message output
|
|
|
|
if (from == 0) { // Constructor - loading and initialization
|
|
|
|
cout << " " << sContactType << " " << name << endl;
|
|
|
|
cout << " Location: " << vXYZ << endl;
|
|
|
|
cout << " Spring Constant: " << kSpring << endl;
|
2008-08-03 13:52:45 +00:00
|
|
|
|
|
|
|
if (eDampType == dtLinear)
|
|
|
|
cout << " Damping Constant: " << bDamp << " (linear)" << endl;
|
|
|
|
else
|
|
|
|
cout << " Damping Constant: " << bDamp << " (square law)" << endl;
|
|
|
|
|
|
|
|
if (eDampTypeRebound == dtLinear)
|
|
|
|
cout << " Rebound Damping Constant: " << bDampRebound << " (linear)" << endl;
|
|
|
|
else
|
|
|
|
cout << " Rebound Damping Constant: " << bDampRebound << " (square law)" << endl;
|
|
|
|
|
2006-01-12 15:04:22 +00:00
|
|
|
cout << " Dynamic Friction: " << dynamicFCoeff << endl;
|
|
|
|
cout << " Static Friction: " << staticFCoeff << endl;
|
2008-07-10 17:23:02 +00:00
|
|
|
if (eContactType == ctBOGEY) {
|
2006-01-12 15:04:22 +00:00
|
|
|
cout << " Rolling Friction: " << rollingFCoeff << endl;
|
|
|
|
cout << " Steering Type: " << sSteerType << endl;
|
|
|
|
cout << " Grouping: " << sBrakeGroup << endl;
|
|
|
|
cout << " Max Steer Angle: " << maxSteerAngle << endl;
|
|
|
|
cout << " Retractable: " << isRetractable << endl;
|
2007-01-15 12:48:54 +00:00
|
|
|
cout << " Relaxation Velocities:" << endl;
|
|
|
|
cout << " Rolling: " << RFRV << endl;
|
|
|
|
cout << " Side: " << SFRV << endl;
|
2006-01-12 15:04:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
|
|
|
|
if (from == 0) cout << "Instantiated: FGLGear" << endl;
|
|
|
|
if (from == 1) cout << "Destroyed: FGLGear" << endl;
|
|
|
|
}
|
|
|
|
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
|
|
|
|
}
|
|
|
|
if (debug_lvl & 8 ) { // Runtime state variables
|
|
|
|
}
|
|
|
|
if (debug_lvl & 16) { // Sanity checking
|
|
|
|
}
|
|
|
|
if (debug_lvl & 64) {
|
|
|
|
if (from == 0) { // Constructor
|
|
|
|
cout << IdSrc << endl;
|
|
|
|
cout << IdHdr << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace JSBSim
|
|
|
|
|