namespace JSBSim {
-IDENT(IdSrc,"$Id: FGTrim.cpp,v 1.30 2015/12/29 13:44:39 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGTrim.cpp,v 1.34 2016/06/12 09:09:02 bcoconni Exp $");
IDENT(IdHdr,ID_TRIM);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double rudder0 = FCS->GetDrCmd();
double PitchTrim0 = FCS->GetPitchTrimCmd();
- for(int i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
+ for(int i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++)
fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false);
- }
fdmex->SetTrimStatus(true);
fdmex->SuspendIntegration();
cout << endl << " Trim failed" << endl;
}
+ fdmex->GetPropagate()->InitializeDerivatives();
fdmex->ResumeIntegration();
fdmex->SetTrimStatus(false);
- for(int i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
+ for(int i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++)
fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true);
- }
return !trim_failed;
}
vector<ContactPoints> contacts;
FGLocation CGLocation = Propagate->GetLocation();
FGMatrix33 Tec2b = Propagate->GetTec2b();
- FGMatrix33 Tl2b = Propagate->GetTl2b();
+ FGMatrix33 Tb2l = Propagate->GetTb2l();
double hmin = 1E+10;
int contactRef = -1;
// Build the list of the aircraft contact points and take opportunity of the
// loop to find which one is closer to (or deeper into) the ground.
- for (int i = 0; i < GroundReactions->GetNumGearUnits(); i++) {
+ for (int i = 0; i < GroundReactions->GetNumGearUnits(); ++i) {
ContactPoints c;
FGLGear* gear = GroundReactions->GetGearUnit(i);
- c.location = gear->GetLocalGear();
- FGLocation gearLoc = CGLocation.LocalToLocation(c.location);
- c.location = Tl2b * c.location;
+
+ // Skip the retracted landing gears
+ if (!gear->GetGearUnitDown())
+ continue;
+
+ c.location = gear->GetBodyLocation();
+ FGLocation gearLoc = CGLocation.LocalToLocation(Tb2l * c.location);
FGColumnVector3 normal, vDummy;
FGLocation lDummy;
if (height < hmin) {
hmin = height;
- contactRef = i;
+ contactRef = contacts.size() - 1;
}
}
// Apply the computed rotation to all the contact points
FGMatrix33 rot = q0.GetTInv();
vector<ContactPoints>::iterator iter;
- for (iter = contacts.begin(); iter != contacts.end(); iter++)
+ for (iter = contacts.begin(); iter != contacts.end(); ++iter)
iter->location = contact0 + rot * (iter->location - contact0);
// Remove the second point to come in contact with the ground from the list.
FGQuaternion q1(rParam.angleMin, rotationAxis);
// Update the aircraft orientation
- FGColumnVector3 euler = (q0 * q1 * fgic.GetOrientation()).GetEuler();
+ FGColumnVector3 euler = (fgic.GetOrientation() * q0 * q1).GetEuler();
fgic.SetPhiRadIC(euler(1));
fgic.SetThetaRadIC(euler(2));
rParam.angleMin = 3.0 * M_PI;
- for (iter = contacts.begin(); iter != contacts.end(); iter++) {
+ for (iter = contacts.begin(); iter != contacts.end(); ++iter) {
// Below the processed contact point is named 'M'
// Construct an orthonormal basis (u, v, t). The ground normal is obtained
// from iter->normal.
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGAerodynamics.cpp,v 1.59 2016/05/23 17:23:36 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGAerodynamics.cpp,v 1.60 2016/05/30 19:05:58 bcoconni Exp $");
IDENT(IdHdr,ID_AERODYNAMICS);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
unsigned int axis_ctr;
const double twovel=2*in.Vt;
- // Calculate lift coefficient squared
- // Make sure that aero/cl-squared is computed with the current qbar
+ // The lift coefficient squared (property aero/cl-squared) is computed before
+ // the aero functions are called to make sure that they use the same value for
+ // qbar.
if ( in.Qbar > 1.0) {
+ // Skip the computation if qbar is close to zero to avoid huge values for
+ // aero/cl-squared when a non-null lift coincides with a very small aero
+ // velocity (i.e. when qbar is close to zero).
clsq = (vFw(eLift) + vFwAtCG(eLift))/ (in.Wingarea*in.Qbar);
clsq *= clsq;
}
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGPropeller.cpp,v 1.57 2016/01/02 17:42:53 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGPropeller.cpp,v 1.58 2016/06/04 11:06:51 bcoconni Exp $");
IDENT(IdHdr,ID_PROPELLER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Vinduced = 0.5 * (-Vel + sqrt(Vel2sum));
else
Vinduced = 0.5 * (-Vel - sqrt(-Vel2sum));
-
- // We need to drop the case where the downstream velocity is opposite in
- // direction to the aircraft velocity. For example, in such a case, the
- // direction of the airflow on the tail would be opposite to the airflow on
- // the wing tips. When such complicated airflows occur, the momentum theory
- // breaks down and the formulas above are no longer applicable
- // (see H. Glauert, "The Elements of Airfoil and Airscrew Theory",
- // 2nd edition, ยง16.3, pp. 219-221)
-
- if ((Vel+2.0*Vinduced)*Vel < 0.0) {
- // The momentum theory is no longer applicable so let's assume the induced
- // saturates to -0.5*Vel so that the total velocity Vel+2*Vinduced equals 0.
- Vinduced = -0.5*Vel;
- }
// P-factor is simulated by a shift of the acting location of the thrust.
// The shift is a multiple of the angle between the propeller shaft axis