From 63b3f802ec9412b47c089d7c82f740a6c41f3e3e Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Sat, 14 Aug 2010 14:09:58 +0200 Subject: [PATCH] sync again --- .../JSBSim/input_output/FGPropertyManager.cpp | 22 +++++------ src/FDM/JSBSim/math/FGColumnVector3.cpp | 7 +--- src/FDM/JSBSim/models/FGAtmosphere.cpp | 6 ++- src/FDM/JSBSim/models/FGFCS.cpp | 14 +++---- src/FDM/JSBSim/models/FGMassBalance.cpp | 6 ++- src/FDM/JSBSim/models/FGMassBalance.h | 39 +++++++++++++------ src/FDM/JSBSim/models/FGPropagate.cpp | 18 +++------ 7 files changed, 63 insertions(+), 49 deletions(-) diff --git a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp index 6e62fef03..11e566965 100755 --- a/src/FDM/JSBSim/input_output/FGPropertyManager.cpp +++ b/src/FDM/JSBSim/input_output/FGPropertyManager.cpp @@ -74,7 +74,7 @@ FGPropertyManager::GetNode (const string &path, bool create) { SGPropertyNode* node=this->getNode(path.c_str(), create); if (node == 0 && !suppress_warning) { - cout << "FGPropertyManager::GetNode() No node found for " << path << endl; + cerr << "FGPropertyManager::GetNode() No node found for " << path << endl; } return (FGPropertyManager*)node; } @@ -256,8 +256,8 @@ void FGPropertyManager::SetArchivable (const string &name, bool state ) { SGPropertyNode * node = getNode(name.c_str()); if (node == 0) - cout << - "Attempt to set archive flag for non-existant property " + cerr << + "Attempt to set archive flag for non-existent property " << name << endl; else node->setAttribute(SGPropertyNode::ARCHIVE, state); @@ -269,7 +269,7 @@ void FGPropertyManager::SetReadable (const string &name, bool state ) { SGPropertyNode * node = getNode(name.c_str()); if (node == 0) - cout << + cerr << "Attempt to set read flag for non-existant property " << name << endl; else @@ -282,7 +282,7 @@ void FGPropertyManager::SetWritable (const string &name, bool state ) { SGPropertyNode * node = getNode(name.c_str()); if (node == 0) - cout << + cerr << "Attempt to set write flag for non-existant property " << name << endl; else @@ -294,7 +294,7 @@ void FGPropertyManager::SetWritable (const string &name, bool state ) void FGPropertyManager::Untie (const string &name) { if (!untie(name.c_str())) - cout << "Failed to untie property " << name << endl; + cerr << "Failed to untie property " << name << endl; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -302,7 +302,7 @@ void FGPropertyManager::Untie (const string &name) void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault) { if (!tie(name.c_str(), SGRawValuePointer(pointer), useDefault)) - cout << "Failed to tie property " << name << " to a pointer" << endl; + cerr << "Failed to tie property " << name << " to a pointer" << endl; else if (debug_lvl & 0x20) cout << name << endl; } @@ -313,7 +313,7 @@ void FGPropertyManager::Tie (const string &name, int *pointer, bool useDefault ) { if (!tie(name.c_str(), SGRawValuePointer(pointer), useDefault)) - cout << "Failed to tie property " << name << " to a pointer" << endl; + cerr << "Failed to tie property " << name << " to a pointer" << endl; else if (debug_lvl & 0x20) cout << name << endl; } @@ -324,7 +324,7 @@ void FGPropertyManager::Tie (const string &name, long *pointer, bool useDefault ) { if (!tie(name.c_str(), SGRawValuePointer(pointer), useDefault)) - cout << "Failed to tie property " << name << " to a pointer" << endl; + cerr << "Failed to tie property " << name << " to a pointer" << endl; else if (debug_lvl & 0x20) cout << name << endl; } @@ -335,7 +335,7 @@ void FGPropertyManager::Tie (const string &name, float *pointer, bool useDefault ) { if (!tie(name.c_str(), SGRawValuePointer(pointer), useDefault)) - cout << "Failed to tie property " << name << " to a pointer" << endl; + cerr << "Failed to tie property " << name << " to a pointer" << endl; else if (debug_lvl & 0x20) cout << name << endl; } @@ -345,7 +345,7 @@ void FGPropertyManager::Tie (const string &name, float *pointer, void FGPropertyManager::Tie (const string &name, double *pointer, bool useDefault) { if (!tie(name.c_str(), SGRawValuePointer(pointer), useDefault)) - cout << "Failed to tie property " << name << " to a pointer" << endl; + cerr << "Failed to tie property " << name << " to a pointer" << endl; else if (debug_lvl & 0x20) cout << name << endl; } diff --git a/src/FDM/JSBSim/math/FGColumnVector3.cpp b/src/FDM/JSBSim/math/FGColumnVector3.cpp index 1e41cd193..5b91dcdb6 100644 --- a/src/FDM/JSBSim/math/FGColumnVector3.cpp +++ b/src/FDM/JSBSim/math/FGColumnVector3.cpp @@ -47,7 +47,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGColumnVector3.cpp,v 1.12 2010/06/30 03:13:40 jberndt Exp $"; +static const char *IdSrc = "$Id: FGColumnVector3.cpp,v 1.13 2010/08/08 00:19:21 jberndt Exp $"; static const char *IdHdr = ID_COLUMNVECTOR3; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -110,10 +110,7 @@ FGColumnVector3& FGColumnVector3::operator/=(const double scalar) double FGColumnVector3::Magnitude(void) const { - if (data[0] == 0.0 && data[1] == 0.0 && data[2] == 0.0) - return 0.0; - else - return sqrt( data[0]*data[0] + data[1]*data[1] + data[2]*data[2] ); + return sqrt( data[0]*data[0] + data[1]*data[1] + data[2]*data[2] ); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/models/FGAtmosphere.cpp b/src/FDM/JSBSim/models/FGAtmosphere.cpp index 601658922..2db1c65d9 100644 --- a/src/FDM/JSBSim/models/FGAtmosphere.cpp +++ b/src/FDM/JSBSim/models/FGAtmosphere.cpp @@ -61,7 +61,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.33 2010/02/25 05:21:36 jberndt Exp $"; +static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.35 2010/08/11 11:51:33 jberndt Exp $"; static const char *IdHdr = ID_ATMOSPHERE; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -277,7 +277,9 @@ void FGAtmosphere::Calculate(double altitude) void FGAtmosphere::CalculateDerived(void) { T_dev = (*temperature) - GetTemperature(h); - density_altitude = h + T_dev * 66.7; + + if (T_dev == 0.0) density_altitude = h; + else density_altitude = 518.4/0.00357 * (1.0 - pow(GetDensityRatio(),0.235)); if (turbType != ttNone) Turbulence(); diff --git a/src/FDM/JSBSim/models/FGFCS.cpp b/src/FDM/JSBSim/models/FGFCS.cpp index f5bbba07d..4d71ca97d 100644 --- a/src/FDM/JSBSim/models/FGFCS.cpp +++ b/src/FDM/JSBSim/models/FGFCS.cpp @@ -63,7 +63,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGFCS.cpp,v 1.68 2010/03/18 13:21:24 jberndt Exp $"; +static const char *IdSrc = "$Id: FGFCS.cpp,v 1.69 2010/08/10 12:39:07 jberndt Exp $"; static const char *IdHdr = ID_FCS; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -705,18 +705,18 @@ string FGFCS::FindSystemFullPathname(const string& sysfilename) system_filename.append(".xml"); } - system_file.open(string(fullpath + system_filename).c_str()); + system_file.open(string(localpath + system_filename).c_str()); if ( !system_file.is_open()) { - system_file.open(string(localpath + system_filename).c_str()); + system_file.open(string(fullpath + system_filename).c_str()); if ( !system_file.is_open()) { cerr << " Could not open system file: " << system_filename << " in path " << fullpath << " or " << localpath << endl; return string(""); } else { - return string(localpath + system_filename); + return string(fullpath + system_filename); } } - return string(fullpath + system_filename); + return string(localpath + system_filename); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -736,9 +736,9 @@ ifstream* FGFCS::FindSystemFile(const string& sysfilename) system_filename.append(".xml"); } - system_file->open(string(fullpath + system_filename).c_str()); + system_file->open(string(localpath + system_filename).c_str()); if ( !system_file->is_open()) { - system_file->open(string(localpath + system_filename).c_str()); + system_file->open(string(fullpath + system_filename).c_str()); if ( !system_file->is_open()) { cerr << " Could not open system file: " << system_filename << " in path " << fullpath << " or " << localpath << endl; diff --git a/src/FDM/JSBSim/models/FGMassBalance.cpp b/src/FDM/JSBSim/models/FGMassBalance.cpp index 24727547c..9e485c1a6 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.cpp +++ b/src/FDM/JSBSim/models/FGMassBalance.cpp @@ -51,7 +51,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.31 2010/02/19 00:30:00 jberndt Exp $"; +static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.32 2010/08/12 04:07:11 jberndt Exp $"; static const char *IdHdr = ID_MASSBALANCE; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -280,6 +280,10 @@ void FGMassBalance::AddPointMass(Element* el) pm->SetPointMassShapeType(PointMass::esSphere); pm->SetRadius(radius); pm->CalculateShapeInertia(); + } else if (shape == "ball") { + pm->SetPointMassShapeType(PointMass::esBall); + pm->SetRadius(radius); + pm->CalculateShapeInertia(); } else { } } diff --git a/src/FDM/JSBSim/models/FGMassBalance.h b/src/FDM/JSBSim/models/FGMassBalance.h index c49fe2904..be461a1e8 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.h +++ b/src/FDM/JSBSim/models/FGMassBalance.h @@ -49,7 +49,7 @@ INCLUDES DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.20 2010/02/04 13:09:26 jberndt Exp $" +#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.21 2010/08/12 04:07:11 jberndt Exp $" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONSS @@ -65,7 +65,11 @@ CLASS DOCUMENTATION /** Models weight, balance and moment of inertia information. Maintains a vector of point masses. Sums the contribution of all, and provides this to FGPropagate. - Loads the \ section of the aircraft configuration file. + Loads the \ section of the aircraft configuration file. There + can be any number of . Each can also have a shape which - if + present - causes an associated moment of inertia to be calculated based on + the shape. Note that a cylinder is solid, a tube is hollow, a ball is solid + and a sphere is hollow.

Configuration File Format:

@code @@ -77,20 +81,24 @@ CLASS DOCUMENTATION {number} {number} {number} - + {number} {number} {number} - + [ +
+ {number} + {number} +
{number} - + {number} {number} {number}
- ... other point masses ... + ... other point masses ...]
@endcode */ @@ -197,21 +205,30 @@ private: void CalculateShapeInertia(void) { switch(eShapeType) { case esTube: - mPMInertia(1,1) = (Weight/(32.16))*Radius*Radius; // mr^2 - mPMInertia(2,2) = (Weight/(32.16*12))*(6*Radius*Radius + Length*Length); + mPMInertia(1,1) = (Weight/(slugtolb))*Radius*Radius; // mr^2 + mPMInertia(2,2) = (Weight/(slugtolb*12))*(6*Radius*Radius + Length*Length); mPMInertia(3,3) = mPMInertia(2,2); break; case esCylinder: - mPMInertia(1,1) = (Weight/(32.16*2))*Radius*Radius; // 0.5*mr^2 - mPMInertia(2,2) = (Weight/(32.16*12))*(3*Radius*Radius + Length*Length); + mPMInertia(1,1) = (Weight/(slugtolb*2))*Radius*Radius; // 0.5*mr^2 + mPMInertia(2,2) = (Weight/(slugtolb*12))*(3*Radius*Radius + Length*Length); mPMInertia(3,3) = mPMInertia(2,2); break; + case esSphere: + mPMInertia(1,1) = (Weight/(slugtolb*3))*Radius*Radius*2; // (2mr^2)/3 + mPMInertia(2,2) = mPMInertia(1,1); + mPMInertia(3,3) = mPMInertia(1,1); + case esBall: + mPMInertia(1,1) = (Weight/(slugtolb*5))*Radius*Radius*2; // (2mr^2)/5 + mPMInertia(2,2) = mPMInertia(1,1); + mPMInertia(3,3) = mPMInertia(1,1); + break; default: break; } } - enum esShape {esUnspecified, esTube, esCylinder, esSphere} eShapeType; + enum esShape {esUnspecified, esTube, esCylinder, esSphere, esBall} eShapeType; FGColumnVector3 Location; double Weight; /// Weight in pounds. double Radius; /// Radius in feet. diff --git a/src/FDM/JSBSim/models/FGPropagate.cpp b/src/FDM/JSBSim/models/FGPropagate.cpp index 9c7543c48..ebb83211b 100644 --- a/src/FDM/JSBSim/models/FGPropagate.cpp +++ b/src/FDM/JSBSim/models/FGPropagate.cpp @@ -71,7 +71,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.59 2010/07/30 11:50:01 jberndt Exp $"; +static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.60 2010/08/12 19:11:22 andgi Exp $"; static const char *IdHdr = ID_PROPAGATE; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -259,8 +259,6 @@ Inertial. bool FGPropagate::Run(void) { -static int ctr; - if (FGModel::Run()) return true; // Fast return if we have nothing to do ... if (FDMExec->Holding()) return false; @@ -498,11 +496,11 @@ void FGPropagate::ResolveFrictionForces(double dt) // If no gears are in contact with the ground then return if (!n) return; - double *a = new double[n*n]; // Will contain J*M^-1*J^T - double *eta = new double[n]; - double *lambda = new double[n]; - double *lambdaMin = new double[n]; - double *lambdaMax = new double[n]; + vector a(n*n); // Will contain J*M^-1*J^T + vector eta(n); + vector lambda(n); + vector lambdaMin(n); + vector lambdaMax(n); // Initializes the Lagrange multipliers i = 0; @@ -519,8 +517,6 @@ void FGPropagate::ResolveFrictionForces(double dt) // First compute the ground velocity below the aircraft center of gravity FGLocation contact; FGColumnVector3 normal, cvel; - double t = FDMExec->GetSimTime(); - double height = FDMExec->GetGroundCallback()->GetAGLevel(t, VState.vLocation, contact, normal, cvel); // Instruct the algorithm to zero out the relative movement between the // aircraft and the ground. @@ -587,8 +583,6 @@ void FGPropagate::ResolveFrictionForces(double dt) (*it)->value = lambda[i++]; GroundReactions->UpdateForcesAndMoments(); - - delete a, eta, lambda, lambdaMin, lambdaMax; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%