Synced with latest JSBSim cvs.
reinit fix from Norman.
This commit is contained in:
parent
d422a7bb7f
commit
4b6e8102a7
7 changed files with 114 additions and 44 deletions
|
@ -53,8 +53,9 @@ FGControls::~FGControls() {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.23 2001/04/02 01:12:38 curt
|
||||
// Latest jsbsim updates.
|
||||
// Revision 1.24 2001/04/05 19:14:37 curt
|
||||
// Synced with latest JSBSim cvs.
|
||||
// reinit fix from Norman.
|
||||
//
|
||||
// Revision 1.7 2001/03/22 14:10:24 jberndt
|
||||
// Fixed ID comment
|
||||
|
|
|
@ -178,8 +178,9 @@ extern FGControls controls;
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.22 2001/04/02 01:12:38 curt
|
||||
// Latest jsbsim updates.
|
||||
// Revision 1.23 2001/04/05 19:14:37 curt
|
||||
// Synced with latest JSBSim cvs.
|
||||
// reinit fix from Norman.
|
||||
//
|
||||
// Revision 1.10 2001/03/22 14:10:24 jberndt
|
||||
// Fixed ID comment
|
||||
|
|
|
@ -94,7 +94,10 @@ enum eParam {
|
|||
FG_THROTTLE_POS,
|
||||
FG_ACTIVE_ENGINE,
|
||||
FG_HOVERB,
|
||||
FG_PITCH_TRIM_CMD
|
||||
FG_PITCH_TRIM_CMD,
|
||||
FG_LEFT_BRAKE_CMD,
|
||||
FG_CENTER_BRAKE_CMD,
|
||||
FG_RIGHT_BRAKE_CMD
|
||||
};
|
||||
|
||||
enum eAction {
|
||||
|
|
|
@ -172,50 +172,63 @@ public:
|
|||
/** Gets the aileron command.
|
||||
@return aileron command in radians */
|
||||
inline float GetDaCmd(void) { return DaCmd; }
|
||||
|
||||
/** Gets the elevator command.
|
||||
@return elevator command in radians */
|
||||
inline float GetDeCmd(void) { return DeCmd; }
|
||||
|
||||
/** Gets the rudder command.
|
||||
@return rudder command in radians */
|
||||
inline float GetDrCmd(void) { return DrCmd; }
|
||||
|
||||
/** Gets the flaps command.
|
||||
@return flaps command in radians */
|
||||
inline float GetDfCmd(void) { return DfCmd; }
|
||||
|
||||
/** Gets the speedbrake command.
|
||||
@return speedbrake command in radians */
|
||||
inline float GetDsbCmd(void) { return DsbCmd; }
|
||||
|
||||
/** Gets the spoiler command.
|
||||
@return spoiler command in radians */
|
||||
inline float GetDspCmd(void) { return DspCmd; }
|
||||
|
||||
/** Gets the throttle command.
|
||||
@param engine engine ID number
|
||||
@return throttle command in percent ( 0 - 100) for the given engine */
|
||||
inline float GetThrottleCmd(int engine) { return ThrottleCmd[engine]; }
|
||||
|
||||
/** Gets the pitch trim command.
|
||||
@return pitch trim command in radians */
|
||||
inline float GetPitchTrimCmd(void) { return PTrimCmd; }
|
||||
//@}
|
||||
|
||||
|
||||
/// @name Aerosurface position retrieval
|
||||
//@{
|
||||
/** Gets the aileron position.
|
||||
@return aileron position in radians */
|
||||
inline float GetDaPos(void) { return DaPos; }
|
||||
|
||||
/** Gets the elevator position.
|
||||
@return elevator position in radians */
|
||||
inline float GetDePos(void) { return DePos; }
|
||||
|
||||
/** Gets the rudder position.
|
||||
@return rudder position in radians */
|
||||
inline float GetDrPos(void) { return DrPos; }
|
||||
|
||||
/** Gets the flaps position.
|
||||
@return flaps position in radians */
|
||||
inline float GetDfPos(void) { return DfPos; }
|
||||
|
||||
/** Gets the speedbrake position.
|
||||
@return speedbrake position in radians */
|
||||
inline float GetDsbPos(void) { return DsbPos; }
|
||||
|
||||
/** Gets the spoiler position.
|
||||
@return spoiler position in radians */
|
||||
inline float GetDspPos(void) { return DspPos; }
|
||||
|
||||
/** Gets the throttle position.
|
||||
@param engine engine ID number
|
||||
@return throttle position for the given engine in percent ( 0 - 100)*/
|
||||
|
@ -226,16 +239,20 @@ public:
|
|||
This is used by the FGFCS-owned components.
|
||||
@return pointer to the State object */
|
||||
inline FGState* GetState(void) { return State; }
|
||||
|
||||
/** Retrieves a components output value
|
||||
@param idx the index of the component (the component ID)
|
||||
@return output value from the component */
|
||||
float GetComponentOutput(eParam idx);
|
||||
|
||||
/** Retrieves the component name
|
||||
@param idx the index of the component (the component ID)
|
||||
@return name of the component */
|
||||
string GetComponentName(int idx);
|
||||
|
||||
/** Retrieves all component names for inclusion in output stream */
|
||||
string GetComponentStrings(void);
|
||||
|
||||
/** Retrieves all component outputs for inclusion in output stream */
|
||||
string GetComponentValues(void);
|
||||
|
||||
|
@ -244,26 +261,33 @@ public:
|
|||
/** Sets the aileron command
|
||||
@param cmd aileron command in radians*/
|
||||
inline void SetDaCmd(float cmd) { DaCmd = cmd; }
|
||||
|
||||
/** Sets the elevator command
|
||||
@param cmd elevator command in radians*/
|
||||
inline void SetDeCmd(float cmd) { DeCmd = cmd; }
|
||||
|
||||
/** Sets the rudder command
|
||||
@param cmd rudder command in radians*/
|
||||
inline void SetDrCmd(float cmd) { DrCmd = cmd; }
|
||||
|
||||
/** Sets the flaps command
|
||||
@param cmd flaps command in radians*/
|
||||
inline void SetDfCmd(float cmd) { DfCmd = cmd; }
|
||||
|
||||
/** Sets the speedbrake command
|
||||
@param cmd speedbrake command in radians*/
|
||||
inline void SetDsbCmd(float cmd) { DsbCmd = cmd; }
|
||||
|
||||
/** Sets the spoilers command
|
||||
@param cmd spoilers command in radians*/
|
||||
inline void SetDspCmd(float cmd) { DspCmd = cmd; }
|
||||
|
||||
/** Sets the pitch trim command
|
||||
@param cmd pitch trim command in radians*/
|
||||
inline void SetPitchTrimCmd(float cmd) { PTrimCmd = cmd; }
|
||||
|
||||
/** Sets the throttle command for the specified engine
|
||||
@param engine engine ID number
|
||||
@param engine engine ID number
|
||||
@param cmd throttle command in percent (0 - 100)*/
|
||||
inline void SetThrottleCmd(int engine, float cmd);
|
||||
//@}
|
||||
|
@ -273,23 +297,29 @@ public:
|
|||
/** Sets the aileron position
|
||||
@param cmd aileron position in radians*/
|
||||
inline void SetDaPos(float cmd) { DaPos = cmd; }
|
||||
|
||||
/** Sets the elevator position
|
||||
@param cmd elevator position in radians*/
|
||||
inline void SetDePos(float cmd) { DePos = cmd; }
|
||||
|
||||
/** Sets the rudder position
|
||||
@param cmd rudder position in radians*/
|
||||
inline void SetDrPos(float cmd) { DrPos = cmd; }
|
||||
|
||||
/** Sets the flaps position
|
||||
@param cmd flaps position in radians*/
|
||||
inline void SetDfPos(float cmd) { DfPos = cmd; }
|
||||
|
||||
/** Sets the speedbrake position
|
||||
@param cmd speedbrake position in radians*/
|
||||
inline void SetDsbPos(float cmd) { DsbPos = cmd; }
|
||||
|
||||
/** Sets the spoiler position
|
||||
@param cmd spoiler position in radians*/
|
||||
inline void SetDspPos(float cmd) { DspPos = cmd; }
|
||||
|
||||
/** Sets the actual throttle setting for the specified engine
|
||||
@param engine engine ID number
|
||||
@param engine engine ID number
|
||||
@param cmd throttle setting in percent (0 - 100)*/
|
||||
inline void SetThrottlePos(int engine, float cmd);
|
||||
//@}
|
||||
|
@ -299,12 +329,15 @@ public:
|
|||
/** Sets the left brake group
|
||||
@param cmd brake setting in percent (0.0 - 1.0) */
|
||||
void SetLBrake(float cmd) {LeftBrake = cmd;}
|
||||
|
||||
/** Sets the right brake group
|
||||
@param cmd brake setting in percent (0.0 - 1.0) */
|
||||
void SetRBrake(float cmd) {RightBrake = cmd;}
|
||||
|
||||
/** Sets the center brake group
|
||||
@param cmd brake setting in percent (0.0 - 1.0) */
|
||||
void SetCBrake(float cmd) {CenterBrake = cmd;}
|
||||
|
||||
/** Gets the brake for a specified group.
|
||||
@param bg which brakegroup to retrieve the command for
|
||||
@return the brake setting for the supplied brake group argument */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
Module: FGLGear.cpp
|
||||
Author: Jon S. Berndt
|
||||
Norman H. Princen
|
||||
Date started: 11/18/99
|
||||
Purpose: Encapsulates the landing gear elements
|
||||
Called by: FGAircraft
|
||||
|
@ -64,10 +65,10 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
|
|||
Exec(fdmex)
|
||||
{
|
||||
string tmp;
|
||||
*AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3)
|
||||
*AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3)
|
||||
>> kSpring >> bDamp>> dynamicFCoeff >> staticFCoeff
|
||||
>> rollingFCoeff >> sSteerType >> sBrakeGroup >> maxSteerAngle;
|
||||
|
||||
|
||||
cout << " Name: " << name << endl;
|
||||
cout << " Location: " << vXYZ << endl;
|
||||
cout << " Spring Constant: " << kSpring << endl;
|
||||
|
@ -106,14 +107,14 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
|
|||
Position = Exec->GetPosition();
|
||||
Rotation = Exec->GetRotation();
|
||||
FCS = Exec->GetFCS();
|
||||
|
||||
|
||||
WOW = false;
|
||||
ReportEnable = true;
|
||||
FirstContact = false;
|
||||
Reported = false;
|
||||
DistanceTraveled = 0.0;
|
||||
MaximumStrutForce = MaximumStrutTravel = 0.0;
|
||||
|
||||
|
||||
vWhlBodyVec = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
|
||||
vWhlBodyVec(eX) = -vWhlBodyVec(eX);
|
||||
vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
|
||||
|
@ -184,32 +185,48 @@ FGColumnVector FGLGear::Force(void)
|
|||
|
||||
FGColumnVector vForce(3);
|
||||
FGColumnVector vLocalForce(3);
|
||||
//FGColumnVector vLocalGear(3); // Vector: CG to this wheel (Local)
|
||||
FGColumnVector vWhlVelVec(3); // Velocity of this wheel (Local)
|
||||
|
||||
vWhlBodyVec = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
|
||||
vWhlBodyVec(eX) = -vWhlBodyVec(eX);
|
||||
vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
|
||||
|
||||
// vWhlBodyVec now stores the vector from the cg to this wheel
|
||||
|
||||
vLocalGear = State->GetTb2l() * vWhlBodyVec;
|
||||
|
||||
// For now, gear compression is assumed to happen in the Local Z axis,
|
||||
// not the strut axis as it should be. Will fix this later.
|
||||
|
||||
// vLocalGear now stores the vector from the cg to the wheel in local coords.
|
||||
|
||||
compressLength = vLocalGear(eZ) - Position->GetDistanceAGL();
|
||||
|
||||
// The compression length is currently measured in the Z-axis, only, at this time.
|
||||
// It should be measured along the strut axis. If the local-frame gear position
|
||||
// "hangs down" below the CG greater than the altitude, then the compressLength
|
||||
// will be positive - i.e. the gear will have made contact.
|
||||
|
||||
if (compressLength > 0.00) {
|
||||
|
||||
WOW = true;
|
||||
|
||||
WOW = true; // Weight-On-Wheels is true
|
||||
|
||||
// The next equation should really use the vector to the contact patch of the tire
|
||||
// including the strut compression and not vWhlBodyVec. Will fix this later.
|
||||
// As it stands, now, the following equation takes the aircraft body-frame
|
||||
// rotational rate and calculates the cross-product with the vector from the CG
|
||||
// to the wheel, thus producing the instantaneous velocity vector of the tire
|
||||
// in Body coords. The frame is also converted to local coordinates. When the
|
||||
// aircraft local-frame velocity is added to this quantity, the total velocity of
|
||||
// the wheel in local frame is then known. Subsequently, the compression speed
|
||||
// (used for calculating damping force) is found by taking the Z-component of the
|
||||
// wheel velocity.
|
||||
|
||||
vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
|
||||
vWhlVelVec += Position->GetVel();
|
||||
|
||||
compressSpeed = vWhlVelVec(eZ);
|
||||
|
||||
// If this is the first time the wheel has made contact, remember some values
|
||||
// for later printout.
|
||||
|
||||
if (!FirstContact) {
|
||||
FirstContact = true;
|
||||
SinkRate = compressSpeed;
|
||||
|
@ -220,43 +237,42 @@ FGColumnVector FGLGear::Force(void)
|
|||
// 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.
|
||||
|
||||
switch (eBrakeGrp) {
|
||||
case bgLeft:
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
|
||||
staticFCoeff*FCS->GetBrake(bgLeft);
|
||||
break;
|
||||
case bgRight:
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
|
||||
staticFCoeff*FCS->GetBrake(bgRight);
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
|
||||
staticFCoeff*FCS->GetBrake(bgRight);
|
||||
break;
|
||||
case bgCenter:
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
|
||||
staticFCoeff*FCS->GetBrake(bgCenter);
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
|
||||
staticFCoeff*FCS->GetBrake(bgCenter);
|
||||
break;
|
||||
case bgNose:
|
||||
SteerGain = maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff;
|
||||
SteerGain = maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff;
|
||||
break;
|
||||
case bgTail:
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff;
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff;
|
||||
break;
|
||||
case bgNone:
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff;
|
||||
SteerGain = -maxSteerAngle;
|
||||
BrakeFCoeff = rollingFCoeff;
|
||||
break;
|
||||
default:
|
||||
cerr << "Improper brake group membership detected for this gear." << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
// Note to Jon: Need to substitute the correct variable for RudderPedal.
|
||||
// It is assumed that rudder pedal has a range of -1.0 to 1.0.
|
||||
|
||||
switch (eSteerType) {
|
||||
case stSteer:
|
||||
SteerAngle = SteerGain*FCS->GetDrCmd();
|
||||
|
@ -265,7 +281,6 @@ FGColumnVector FGLGear::Force(void)
|
|||
SteerAngle = 0.0;
|
||||
break;
|
||||
case stCaster:
|
||||
|
||||
// Note to Jon: This is not correct for castering gear. I'll fix it later.
|
||||
SteerAngle = 0.0;
|
||||
break;
|
||||
|
@ -277,7 +292,6 @@ FGColumnVector FGLGear::Force(void)
|
|||
// Transform the wheel velocities from the local axis system to the wheel axis system.
|
||||
// For now, steering angle is assumed to happen in the Local Z axis,
|
||||
// not the strut axis as it should be. Will fix this later.
|
||||
// Note to Jon: Please substitute the correct variable for Deg2Rad conversion.
|
||||
|
||||
SinWheel = sin(Rotation->Getpsi() + SteerAngle*DEGTORAD);
|
||||
CosWheel = cos(Rotation->Getpsi() + SteerAngle*DEGTORAD);
|
||||
|
@ -292,11 +306,11 @@ FGColumnVector FGLGear::Force(void)
|
|||
WheelSlip = RADTODEG*atan2(SideWhlVel, RollingWhlVel);
|
||||
}
|
||||
|
||||
// The following code normalizes the wheel velocity vector, reverses it, and zeroes out
|
||||
// the z component of the velocity. The question is, should the Z axis velocity be zeroed
|
||||
// out first before the normalization takes place or not? Subsequent to that, the Wheel
|
||||
// Velocity vector now points as a unit vector backwards and parallel to the wheel
|
||||
// velocity vector. It acts AT the wheel.
|
||||
// The following code normalizes the wheel velocity vector, reverses it, and zeroes out
|
||||
// the z component of the velocity. The question is, should the Z axis velocity be zeroed
|
||||
// out first before the normalization takes place or not? Subsequent to that, the Wheel
|
||||
// Velocity vector now points as a unit vector backwards and parallel to the wheel
|
||||
// velocity vector. It acts AT the wheel.
|
||||
|
||||
// Note to Jon: I commented out this line because I wasn't sure we want to do this.
|
||||
// vWhlVelVec = -1.0 * vWhlVelVec.Normalize();
|
||||
|
@ -323,7 +337,7 @@ FGColumnVector FGLGear::Force(void)
|
|||
// Compute the forces in the wheel ground plane.
|
||||
|
||||
RollingForce = 0;
|
||||
if(fabs(RollingWhlVel) > 1E-3) {
|
||||
if (fabs(RollingWhlVel) > 1E-3) {
|
||||
RollingForce = vLocalForce(eZ) * BrakeFCoeff * fabs(RollingWhlVel)/RollingWhlVel;
|
||||
}
|
||||
SideForce = vLocalForce(eZ) * FCoeff;
|
||||
|
@ -369,7 +383,7 @@ FGColumnVector FGLGear::Force(void)
|
|||
if (ReportEnable && Position->GetVel().Magnitude() <= 0.05 && !Reported) {
|
||||
Report();
|
||||
}
|
||||
|
||||
|
||||
return vForce;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,9 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
|
|||
RegisterVariable(FG_ACTIVE_ENGINE, " active_engine " );
|
||||
RegisterVariable(FG_HOVERB, " height/span " );
|
||||
RegisterVariable(FG_PITCH_TRIM_CMD, " pitch_trim_cmd " );
|
||||
RegisterVariable(FG_LEFT_BRAKE_CMD, " left_brake_cmd " );
|
||||
RegisterVariable(FG_RIGHT_BRAKE_CMD," right_brake_cmd ");
|
||||
RegisterVariable(FG_CENTER_BRAKE_CMD," center_brake_cmd ");
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGState" << endl;
|
||||
}
|
||||
|
@ -287,6 +290,16 @@ void FGState::SetParameter(eParam val_idx, float val) {
|
|||
ActiveEngine = (int)val;
|
||||
break;
|
||||
|
||||
case FG_LEFT_BRAKE_CMD:
|
||||
FDMExec->GetFCS()->SetLBrake(val);
|
||||
break;
|
||||
case FG_CENTER_BRAKE_CMD:
|
||||
FDMExec->GetFCS()->SetCBrake(val);
|
||||
break;
|
||||
case FG_RIGHT_BRAKE_CMD:
|
||||
FDMExec->GetFCS()->SetRBrake(val);
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "Parameter '" << val_idx << "' (" << paramdef[val_idx] << ") not handled" << endl;
|
||||
}
|
||||
|
|
|
@ -817,6 +817,11 @@ void fgReInitSubsystems( void )
|
|||
controls.reset_all();
|
||||
current_autopilot->reset();
|
||||
|
||||
fgUpdateSunPos();
|
||||
fgUpdateMoonPos();
|
||||
cur_light_params.Update();
|
||||
fgUpdateLocalTime();
|
||||
|
||||
if( !freeze )
|
||||
globals->set_freeze( false );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue