1
0
Fork 0

JSBSim bug fixes

- Fixed the scripts end time computation
- Fixed nested tests in switches
- Simplifications to the computation of the aerodynamics angles alpha & beta
- Account for the contact transition in the gear compression speed
- Fixed docs in FGTank
This commit is contained in:
Bertrand Coconnier 2019-04-06 23:09:36 +02:00
parent 2720d9fd9f
commit f011d5f567
7 changed files with 74 additions and 72 deletions

View file

@ -138,9 +138,6 @@ bool FGScript::LoadScript(const SGPath& script, double default_dT,
return false;
}
// Make sure that the desired time is reached and executed.
EndTime += 0.99*FDMExec->GetDeltaT();
if (default_dT == 0.0)
dt = run_element->GetAttributeValueAsNumber("dt");
else {
@ -150,6 +147,9 @@ bool FGScript::LoadScript(const SGPath& script, double default_dT,
}
FDMExec->Setdt(dt);
// Make sure that the desired time is reached and executed.
EndTime += 0.99*FDMExec->GetDeltaT();
// read aircraft and initialization files

View file

@ -9,21 +9,21 @@
------------- Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
the terms of the GNU Lesser General Public License as published by the Free
Software 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
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
@ -50,8 +50,7 @@ using namespace std;
FGXMLParse::FGXMLParse(void)
{
first_element_read = false;
current_element = document = 0L;
current_element = document = nullptr;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -64,8 +63,7 @@ void FGXMLParse::startXML(void)
void FGXMLParse::reset(void)
{
first_element_read = false;
current_element = document = 0L;
current_element = document = nullptr;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -77,18 +75,28 @@ void FGXMLParse::endXML(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::dumpDataLines(void)
{
if (!working_string.empty()) {
for (auto s: split(working_string, '\n'))
current_element->AddData(s);
}
working_string.erase();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
{
string Name(name);
Element *temp_element;
working_string.erase();
if (!first_element_read) {
if (!document) {
document = new Element(Name);
current_element = document;
first_element_read = true;
} else {
dumpDataLines();
temp_element = new Element(Name);
temp_element->SetParent(current_element);
current_element->AddChildElement(temp_element);
@ -113,11 +121,7 @@ void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
void FGXMLParse::endElement (const char * name)
{
if (!working_string.empty()) {
vector <string> work_strings = split(working_string, '\n');
for (unsigned int i=0; i<work_strings.size(); i++) current_element->AddData(work_strings[i]);
}
dumpDataLines();
current_element = current_element->GetParent();
}

View file

@ -7,21 +7,21 @@
------------- Copyright (C) 2004 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
the terms of the GNU Lesser General Public License as published by the Free
Software 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
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
@ -41,7 +41,6 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_XMLPARSE "$Id: FGXMLParse.h,v 1.9 2014/06/09 11:52:06 bcoconni Exp $"
#define VALID_CHARS """`!@#$%^&*()_+`1234567890-={}[];':,.<>/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -58,7 +57,6 @@ CLASS DOCUMENTATION
/** Encapsulates an XML parser based on the EasyXML parser from the SimGear library.
@author Jon S. Berndt
@version $Id: FGXMLParse.h,v 1.9 2014/06/09 11:52:06 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -82,7 +80,8 @@ public:
void reset(void);
private:
bool first_element_read;
void dumpDataLines(void);
mutable std::string working_string;
Element_ptr document;
Element *current_element;

View file

@ -71,17 +71,16 @@ FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager)
}
Element* condition_element = element->GetElement();
if (condition_element) {
while (condition_element) {
conditions.push_back(new FGCondition(condition_element, PropertyManager));
condition_element = element->GetNextElement();
}
} else {
for (unsigned int i=0; i<element->GetNumDataLines(); i++) {
string data = element->GetDataLine(i);
conditions.push_back(new FGCondition(data, PropertyManager,
condition_element));
}
for (unsigned int i=0; i<element->GetNumDataLines(); i++) {
string data = element->GetDataLine(i);
conditions.push_back(new FGCondition(data, PropertyManager,
condition_element));
}
while (condition_element) {
conditions.push_back(new FGCondition(condition_element, PropertyManager));
condition_element = element->GetNextElement();
}
Debug(0);

View file

@ -9,21 +9,21 @@
------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
the terms of the GNU Lesser General Public License as published by the Free
Software 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
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU Lesser General Public License can also be found on
the world wide web at http://www.gnu.org.
Further information about the GNU Lesser General Public License can also be
found on the world wide web at http://www.gnu.org.
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
@ -157,19 +157,12 @@ bool FGAuxiliary::Run(bool Holding)
Vt = sqrt(Vt2);
if ( Vt > 0.001 ) {
if (vAeroUVW(eW) != 0.0)
alpha = AeroU2 > 0.0 ? atan2(vAeroUVW(eW), vAeroUVW(eU)) : 0.0;
if (vAeroUVW(eV) != 0.0)
beta = mUW > 0.0 ? atan2(vAeroUVW(eV), sqrt(mUW)) : 0.0;
beta = atan2(vAeroUVW(eV), sqrt(mUW));
//double signU=1;
//if (vAeroUVW(eU) < 0.0) signU=-1;
if ( mUW >= 0.001 ) {
if ( mUW >= 1E-6 ) {
alpha = atan2(vAeroUVW(eW), vAeroUVW(eU));
double Vtdot = (vAeroUVW(eU)*in.vUVWdot(eU) + vAeroUVW(eV)*in.vUVWdot(eV) + vAeroUVW(eW)*in.vUVWdot(eW))/Vt;
adot = (vAeroUVW(eU)*in.vUVWdot(eW) - vAeroUVW(eW)*in.vUVWdot(eU))/mUW;
// bdot = (signU*mUW*in.vUVWdot(eV)
// - vAeroUVW(eV)*(vAeroUVW(eU)*in.vUVWdot(eU) + vAeroUVW(eW)*in.vUVWdot(eW)))/(Vt2*sqrt(mUW));
bdot = (in.vUVWdot(eV)*Vt - vAeroUVW(eV)*Vtdot)/(Vt*sqrt(mUW));
}
}

View file

@ -58,8 +58,8 @@ DEFINITIONS
GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
// Body To Structural (body frame is rotated 180 deg about Y and lengths are given in
// ft instead of inches)
// Body To Structural (body frame is rotated 180 deg about Y and lengths are
// given in ft instead of inches)
const FGMatrix33 FGLGear::Tb2s(-1./inchtoft, 0., 0., 0., 1./inchtoft, 0., 0., 0., -1./inchtoft);
const FGMatrix33 FGLGear::Ts2b(-inchtoft, 0., 0., 0., inchtoft, 0., 0., 0., -inchtoft);
@ -308,9 +308,9 @@ const FGColumnVector3& FGLGear::GetBodyForces(FGSurface *surface)
vGroundNormal = in.Tec2b * normal;
// The height returned by GetGroundCallback() is the AGL and is expressed
// in the Z direction of the local coordinate frame. We now need to transform
// this height in actual compression of the strut (BOGEY) or in the normal
// direction to the ground (STRUCTURE)
// in the Z direction of the local coordinate frame. We now need to
// transform this height in actual compression of the strut (BOGEY) or in
// the normal direction to the ground (STRUCTURE)
double normalZ = (in.Tec2l*normal)(eZ);
LGearProj = -(mTGear.Transposed() * vGroundNormal)(eZ);
@ -348,12 +348,19 @@ const FGColumnVector3& FGLGear::GetBodyForces(FGSurface *surface)
vGroundWhlVel = mT.Transposed() * vBodyWhlVel;
if (fdmex->GetTrimStatus())
if (fdmex->GetTrimStatus() || in.TotalDeltaT == 0.0)
compressSpeed = 0.0; // Steady state is sought during trimming
else {
compressSpeed = -vGroundWhlVel(eZ);
if (eContactType == ctBOGEY)
compressSpeed /= LGearProj;
// If the gear is entering in contact with the ground during the current
// time step, the compression speed might actually be lower than the
// aircraft velocity projected along the gear leg (compressSpeed).
double maxCompressSpeed = compressLength/in.TotalDeltaT;
if (fabs(compressSpeed) > maxCompressSpeed)
compressSpeed = sign(compressSpeed)*maxCompressSpeed;
}
ComputeVerticalStrutForce();

View file

@ -135,7 +135,7 @@ CLASS DOCUMENTATION
<contents unit="{LBS | KG}"> {number} </contents>
<temperature> {number} </temperature> <!-- must be degrees fahrenheit -->
<standpipe unit="{LBS | KG"}> {number} </standpipe>
<unusable unit="{LBS | KG}"> {number} </unusable>
<unusable unit="{GAL | LTR | M3 | IN3 | FT3 | CC}"> {number} </unusable>
<priority> {integer} </priority>
<density unit="{KG/L | LBS/GAL}"> {number} </density>
<type> {string} </type> <!-- will override previous density setting -->
@ -154,7 +154,7 @@ CLASS DOCUMENTATION
- \b temperature - Initial temperature, defaults to degrees Fahrenheit.
- \b standpipe - Minimum contents to which tank can dump, defaults to pounds.
- \b unusable - Contents that cannot be used for combustion in the engine,
defaults to pounds.
defaults to gallons.
- \b priority - Establishes feed sequence of tank. "1" is the highest priority.
- \b density - Density of liquid tank contents.
- \b type - Named fuel type. One of AVGAS, JET-A, JET-A1, JET-B, JP-1, JP-2,