1
0
Fork 0

Syncing with most recent JSBSim.

This commit is contained in:
curt 2001-12-07 17:10:17 +00:00
parent 53fdf0c25c
commit 6b2e17493e
28 changed files with 499 additions and 452 deletions

View file

@ -263,7 +263,7 @@ bool FGJSBsim::update( int multiloop ) {
fdmex->Run();
}
struct FGJSBBase::Message* msg;
FGJSBBase::Message* msg;
while (fdmex->ReadMessage()) {
msg = fdmex->ProcessMessage();
switch (msg->type) {

View file

@ -48,12 +48,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec),
vFs(3),
vForces(3),
vMoments(3),
vLastFs(3),
vDXYZcg(3)
FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec)
{
Name = "FGAerodynamics";

View file

@ -98,15 +98,7 @@ static const char *IdHdr = ID_AIRCRAFT;
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
vMoments(3),
vForces(3),
vXYZrp(3),
vXYZep(3),
vDXYZcg(3),
vBodyAccel(3),
vNcg(3),
vNwcg(3)
FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGAircraft";
alphaclmin = alphaclmax = 0;
@ -237,8 +229,9 @@ bool FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
{
string token = "";
string parameter;
double EW, bixx, biyy, bizz, bixz, biyz;
FGColumnVector3 vbaseXYZcg(3);
double EW, bixx, biyy, bizz, bixy, bixz;
double pmWt, pmX, pmY, pmZ;
FGColumnVector3 vbaseXYZcg;
AC_cfg->GetNextConfigLine();
@ -280,14 +273,14 @@ bool FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
*AC_cfg >> bizz;
if (debug_lvl > 0) cout << " baseIzz: " << bizz << endl;
MassBalance->SetBaseIzz(bizz);
} else if (parameter == "AC_IXY") {
*AC_cfg >> bixy;
if (debug_lvl > 0) cout << " baseIxy: " << bixy << endl;
MassBalance->SetBaseIxy(bixy);
} else if (parameter == "AC_IXZ") {
*AC_cfg >> bixz;
if (debug_lvl > 0) cout << " baseIxz: " << bixz << endl;
MassBalance->SetBaseIxz(bixz);
} else if (parameter == "AC_IYZ") {
*AC_cfg >> biyz;
if (debug_lvl > 0) cout << " baseIyz: " << biyz << endl;
MassBalance->SetBaseIyz(biyz);
} else if (parameter == "AC_EMPTYWT") {
*AC_cfg >> EW;
MassBalance->SetEmptyWeight(EW);
@ -307,6 +300,11 @@ bool FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
if (debug_lvl > 0) cout << " Maximum Alpha: " << alphaclmax
<< " Minimum Alpha: " << alphaclmin
<< endl;
} else if (parameter == "AC_POINTMASS") {
*AC_cfg >> pmWt >> pmX >> pmY >> pmZ;
if (debug_lvl > 0) cout << " Point Mass Object: " << pmWt << " lbs. at "
<< "X, Y, Z (in.): " << pmX << " " << pmY << " " << pmZ
<< endl;
}
}

View file

@ -68,15 +68,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex),
vDirectiondAccelDt(3),
vDirectionAccel(3),
vDirection(3),
vTurbulence(3),
vTurbulenceGrad(3),
vBodyTurbGrad(3),
vTurbPQR(3),
vWindNED(3)
FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGAtmosphere";
lastIndex=0;

View file

@ -63,9 +63,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex),
vPilotAccel(3),
vToEyePt(3)
FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGAuxiliary";
vcas = veas = mach = qbar = pt = 0;

View file

@ -1,9 +1,9 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGMatrix33.cpp
Module: FGColumnVector3.cpp
Author: Originally by Tony Peden [formatted here (and broken??) by JSB]
Date started: 1998
Purpose: FGMatrix33 class
Purpose: FGColumnVector3 class
Called by: Various
FUNCTIONAL DESCRIPTION
@ -19,8 +19,6 @@ INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGColumnVector3.h"
#include "FGMatrix33.h"
static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_COLUMNVECTOR3;
@ -39,10 +37,10 @@ FGColumnVector3::FGColumnVector3(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector3::FGColumnVector3(int m)
FGColumnVector3::FGColumnVector3(double X, double Y, double Z)
{
rowCtr = 1;
data[0]=0; data[1]=0; data[2]=0; data[3]=0;
data[0] = 0; data[eX] = X; data[eY] = Y; data[eZ] = Z;
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
}
@ -81,29 +79,6 @@ FGColumnVector3 FGColumnVector3::operator=(const FGColumnVector3& b)
return *this;
}
/* //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double& FGColumnVector3::operator()(int m) const
{
return data[m];
}
*/
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/* FGColumnVector3 operator*(const FGMatrix33& Mat, FGColumnVector3& Col)
{
FGColumnVector3 Product;
Product(1) = Col(1)*Mat(1,1) + Col(2)*Mat(1,2) + Col(3)*Mat(1,3);
Product(2) = Col(1)*Mat(2,1) + Col(2)*Mat(2,2) + Col(3)*Mat(2,3);
Product(3) = Col(1)*Mat(3,1) + Col(2)*Mat(3,2) + Col(3)*Mat(3,3);
return Product;
}
*/
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector3 FGColumnVector3::operator+(const FGColumnVector3& C)
@ -292,13 +267,6 @@ FGColumnVector3 FGColumnVector3::multElementWise(const FGColumnVector3& V)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGColumnVector3::Debug(void)
{
//TODO: Add your source code here
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ostream& operator<<(ostream& os, const FGColumnVector3& col)
{
os << col(1) << " , " << col(2) << " , " << col(3);
@ -314,3 +282,11 @@ FGColumnVector3& FGColumnVector3::operator<<(const double ff)
rowCtr = 1;
return *this;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGColumnVector3::Debug(void)
{
//TODO: Add your source code here
}

View file

@ -1,13 +1,11 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGMatrix33.h
Header: FGColumnVector3.h
Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
Date started: Unknown
HISTORY
--------------------------------------------------------------------------------
??/??/?? TP Created
03/16/2000 JSB Added exception throwing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
@ -54,7 +52,6 @@ INCLUDES
using std::string;
#endif
#include "FGMatrix33.h"
#include "FGJSBBase.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -67,8 +64,6 @@ DEFINITIONS
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGMatrix33;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DECLARATION: FGColumnVector3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@ -77,7 +72,7 @@ class FGColumnVector3 : public FGJSBBase
{
public:
FGColumnVector3(void);
FGColumnVector3(int m);
FGColumnVector3(double X, double Y, double Z);
FGColumnVector3(const FGColumnVector3& b);
~FGColumnVector3(void);
@ -104,7 +99,6 @@ public:
FGColumnVector3 Normalize(void);
friend FGColumnVector3 operator*(const double scalar, const FGColumnVector3& A);
//friend FGColumnVector3 operator*(const FGMatrix33& M, FGColumnVector3& V);
friend ostream& operator<<(ostream& os, const FGColumnVector3& col);

View file

@ -30,17 +30,18 @@ CLASS IMPLEMENTATION
FGColumnVector4::FGColumnVector4(void)
{
rowCtr = 1;
//cout << "Allocated: " << data << endl;
data[1]=0;data[2]=0;data[3]=0;data[4]=0;
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector4" << endl;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector4::FGColumnVector4(int m)
FGColumnVector4::FGColumnVector4(double A, double B, double C, double D)
{
rowCtr = 1;
data[1]=0;data[2]=0;data[3]=0;data[4]=0;
//cout << "Allocated: " << data << endl;
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector4" << endl;
}
@ -48,7 +49,6 @@ FGColumnVector4::FGColumnVector4(int m)
FGColumnVector4::~FGColumnVector4(void)
{
//cout << "Freed: " << data << endl;
if (debug_lvl & 2) cout << "Destroyed: FGColumnVector4" << endl;
}
@ -240,34 +240,6 @@ FGColumnVector4 FGColumnVector4::Normalize(void)
return *this;
}
/* //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector4 FGColumnVector4::operator*(const FGColumnVector4& V)
{
FGColumnVector4 Product;
Product(1) = data[2] * V(3) - data[3] * V(2);
Product(2) = data[3] * V(1) - data[1] * V(3);
Product(3) = data[1] * V(2) - data[2] * V(1);
return Product;
} */
/* //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGColumnVector4::operator*=(const FGColumnVector4& V)
{
double a,b,c;
a = data[1]; b=data[2]; c=data[3];
data[1] = b * V(3) - c * V(2);
data[2] = c * V(1) - a * V(3);
data[3] = a * V(2) - b * V(1);
}
*/
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector4 FGColumnVector4::multElementWise(const FGColumnVector4& V)
@ -284,13 +256,6 @@ FGColumnVector4 FGColumnVector4::multElementWise(const FGColumnVector4& V)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGColumnVector4::Debug(void)
{
//TODO: Add your source code here
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ostream& operator<<(ostream& os, FGColumnVector4& col)
{
os << col(1) << " , " << col(2) << " , " << col(3) << " , " << col(4);
@ -302,8 +267,14 @@ ostream& operator<<(ostream& os, FGColumnVector4& col)
FGColumnVector4& FGColumnVector4::operator<<(const double ff)
{
data[rowCtr] = ff;
if (++rowCtr > 4 )
rowCtr = 1;
if (++rowCtr > 4) rowCtr = 1;
return *this;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGColumnVector4::Debug(void)
{
//TODO: Add your source code here
}

View file

@ -1,13 +1,11 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGMatrix33.h
Header: FGColumnVector4.h
Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
Date started: Unknown
HISTORY
--------------------------------------------------------------------------------
??/??/?? TP Created
03/16/2000 JSB Added exception throwing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
@ -74,21 +72,19 @@ class FGColumnVector4 : public FGJSBBase
{
public:
FGColumnVector4(void);
FGColumnVector4(int m);
FGColumnVector4(double A, double B, double C, double D);
FGColumnVector4(const FGColumnVector4& b);
~FGColumnVector4(void);
FGColumnVector4 operator=(const FGColumnVector4& b);
FGColumnVector4 operator*(const double scalar);
//FGColumnVector4 operator*(const FGColumnVector4& V); // Cross product operator
FGColumnVector4 operator/(const double scalar);
FGColumnVector4 operator+(const FGColumnVector4& B); // must not return reference
FGColumnVector4 operator-(const FGColumnVector4& B);
void operator-=(const FGColumnVector4 &B);
void operator+=(const FGColumnVector4 &B);
//void operator*=(const FGColumnVector4 &B);
void operator*=(const double scalar);
void operator/=(const double scalar);
@ -97,8 +93,8 @@ public:
FGColumnVector4& operator<<(const double ff);
inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; }
inline void InitMatrix(double ff) { data[1]=ff; data[2]=ff; data[3]=ff; }
inline void InitMatrix(void) { data[1]=0; data[2]=0; data[3]=0; data[4]=0; }
inline void InitMatrix(double ff) { data[1]=ff; data[2]=ff; data[3]=ff; data[4]=ff;}
double Magnitude(void);
FGColumnVector4 Normalize(void);
@ -118,3 +114,4 @@ private:
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -583,8 +583,6 @@ bool FGFDMExec::LoadScript(string script)
cerr << "Aircraft file " << aircraft << " was not found" << endl;
exit(-1);
}
if ( ! State->Reset("aircraft", aircraft, initialize))
State->Initialize(2000,0,0,0,0,0,0.5,0.5,40000,0,0,0);
return true;
}
@ -640,6 +638,7 @@ void FGFDMExec::RunScript(void)
iC->newValue[i] = iC->OriginalValue[i] + iC->SetValue[i];
break;
case FG_BOOL:
iC->newValue[i] = iC->SetValue[i];
break;
default:
cerr << "Invalid Type specified" << endl;
@ -651,7 +650,7 @@ void FGFDMExec::RunScript(void)
switch (iC->Action[i]) {
case FG_RAMP:
newSetValue = (currentTime - iC->StartTime[i])/(iC->TC[i])
newSetValue = (currentTime - iC->StartTime[i])/(iC->TC[i])
* (iC->newValue[i] - iC->OriginalValue[i]) + iC->OriginalValue[i];
if (newSetValue > iC->newValue[i]) newSetValue = iC->newValue[i];
break;
@ -667,9 +666,6 @@ void FGFDMExec::RunScript(void)
break;
}
State->SetParameter(iC->SetParam[i], newSetValue);
if ((unsigned long int)Propulsion->GetTank(0) == 0) {
cout << "Param # getting set: " << iC->SetParam[i] << " Value: " << newSetValue << endl;
}
}
}
iC++;

View file

@ -294,18 +294,18 @@ private:
struct condition {
vector <eParam> TestParam;
vector <eParam> SetParam;
vector <double> TestValue;
vector <double> SetValue;
vector <double> TestValue;
vector <double> SetValue;
vector <string> Comparison;
vector <double> TC;
vector <double> TC;
vector <bool> Persistent;
vector <eAction> Action;
vector <eType> Type;
vector <bool> Triggered;
vector <double> newValue;
vector <double> OriginalValue;
vector <double> StartTime;
vector <double> EndTime;
vector <double> newValue;
vector <double> OriginalValue;
vector <double> StartTime;
vector <double> EndTime;
condition() {
}

View file

@ -54,18 +54,8 @@ static const char *IdHdr = ID_FORCE;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGForce::FGForce(FGFDMExec *FDMExec) :
ttype(tNone),
fdmex(FDMExec),
vFn(3),
vMn(3),
vH(3),
vFb(3),
vM(3),
vXYZn(3),
vDXYZ(3),
vSense(3),
mT(3,3)
ttype(tNone),
fdmex(FDMExec)
{
mT(1,1) = 1; //identity matrix
mT(2,2) = 1;
@ -83,15 +73,17 @@ FGForce::~FGForce()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector3& FGForce::GetBodyForces(void) {
FGColumnVector3& FGForce::GetBodyForces(void)
{
vFb = Transform()*(vFn.multElementWise(vSense));
//find the distance from this vector's location to the cg
//needs to be done like this to convert from structural to body coords
vDXYZ(1) = -(vXYZn(1) - fdmex->GetMassBalance()->GetXYZcg(1))*inchtoft;
vDXYZ(2) = (vXYZn(2) - fdmex->GetMassBalance()->GetXYZcg(2))*inchtoft; //cg and rp values are in inches
vDXYZ(3) = -(vXYZn(3) - fdmex->GetMassBalance()->GetXYZcg(3))*inchtoft;
// Find the distance from this vector's acting location to the cg; this
// needs to be done like this to convert from structural to body coords.
// CG and RP values are in inches
vDXYZ(eX) = -(vActingXYZn(eX) - fdmex->GetMassBalance()->GetXYZcg(eX))*inchtoft;
vDXYZ(eY) = (vActingXYZn(eY) - fdmex->GetMassBalance()->GetXYZcg(eY))*inchtoft;
vDXYZ(eZ) = -(vActingXYZn(eZ) - fdmex->GetMassBalance()->GetXYZcg(eZ))*inchtoft;
vM = vMn + vDXYZ*vFb;
@ -100,7 +92,8 @@ FGColumnVector3& FGForce::GetBodyForces(void) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGMatrix33 FGForce::Transform(void) {
FGMatrix33 FGForce::Transform(void)
{
switch(ttype) {
case tWindBody:
return fdmex->GetState()->GetTs2b();
@ -118,9 +111,9 @@ FGMatrix33 FGForce::Transform(void) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGForce::SetAnglesToBody(double broll, double bpitch, double byaw) {
if(ttype == tCustom) {
void FGForce::SetAnglesToBody(double broll, double bpitch, double byaw)
{
if (ttype == tCustom) {
double cp,sp,cr,sr,cy,sy;
cp=cos(bpitch); sp=sin(bpitch);
@ -139,7 +132,6 @@ void FGForce::SetAnglesToBody(double broll, double bpitch, double byaw) {
mT(3,2)=cr*sp*sy-sr*cy;
mT(3,3)=cr*cp;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -244,27 +244,49 @@ public:
inline FGColumnVector3& GetNativeForces(void) { return vFn; }
inline FGColumnVector3& GetNativeMoments(void) { return vMn; }
FGColumnVector3& GetBodyForces(void);
inline FGColumnVector3& GetMoments(void) { return vM; }
//point of application, JSBsim structural coords
//(inches, x +back, y +right, z +up)
// Normal point of application, JSBsim structural coords
// (inches, x +back, y +right, z +up)
inline void SetLocation(double x, double y, double z) {
vXYZn(1) = x;
vXYZn(2) = y;
vXYZn(3) = z;
vXYZn(eX) = x;
vXYZn(eY) = y;
vXYZn(eZ) = z;
SetActingLocation(x, y, z);
}
inline void SetLocationX(double x) {vXYZn(1) = x;}
inline void SetLocationY(double y) {vXYZn(2) = y;}
inline void SetLocationZ(double z) {vXYZn(3) = z;}
inline void SetLocation(FGColumnVector3 vv) { vXYZn = vv; }
inline double GetLocationX( void ) { return vXYZn(1);}
inline double GetLocationY( void ) { return vXYZn(2);}
inline double GetLocationZ( void ) { return vXYZn(3);}
/** Acting point of application.
JSBsim structural coords used (inches, x +back, y +right, z +up).
This function sets the point at which the force acts - this may
not be the same as where the object resides. One area where this
is true is P-Factor modeling.
@param x acting location of force
@param y acting location of force
@param z acting location of force */
inline void SetActingLocation(double x, double y, double z) {
vActingXYZn(eX) = x;
vActingXYZn(eY) = y;
vActingXYZn(eZ) = z;
}
inline void SetLocationX(double x) {vXYZn(eX) = x; vActingXYZn(eX) = x;}
inline void SetLocationY(double y) {vXYZn(eY) = y; vActingXYZn(eY) = y;}
inline void SetLocationZ(double z) {vXYZn(eZ) = z; vActingXYZn(eZ) = z;}
inline double SetActingLocationX(double x) {vActingXYZn(eX) = x; return x;}
inline double SetActingLocationY(double y) {vActingXYZn(eY) = y; return y;}
inline double SetActingLocationZ(double z) {vActingXYZn(eZ) = z; return z;}
inline void SetLocation(FGColumnVector3 vv) { vXYZn = vv; SetActingLocation(vv);}
inline void SetActingLocation(FGColumnVector3 vv) { vActingXYZn = vv; }
inline double GetLocationX( void ) { return vXYZn(eX);}
inline double GetLocationY( void ) { return vXYZn(eY);}
inline double GetLocationZ( void ) { return vXYZn(eZ);}
inline double GetActingLocationX( void ) { return vActingXYZn(eX);}
inline double GetActingLocationY( void ) { return vActingXYZn(eY);}
inline double GetActingLocationZ( void ) { return vActingXYZn(eZ);}
FGColumnVector3& GetLocation(void) { return vXYZn; }
FGColumnVector3& GetActingLocation(void) { return vActingXYZn; }
//these angles are relative to body axes, not earth!!!!!
//I'm using these because pitch, roll, and yaw are easy to visualize,
@ -274,9 +296,11 @@ public:
//They are in radians.
void SetAnglesToBody(double broll, double bpitch, double byaw);
inline void SetAnglesToBody(FGColumnVector3 vv) { SetAnglesToBody(vv(1), vv(2), vv(3));}
inline void SetAnglesToBody(FGColumnVector3 vv) {
SetAnglesToBody(vv(eRoll), vv(ePitch), vv(eYaw));
}
inline void SetSense(double x, double y, double z) { vSense(1)=x, vSense(2)=y, vSense(3)=z; }
inline void SetSense(double x, double y, double z) { vSense(eX)=x, vSense(eY)=y, vSense(eZ)=z; }
inline void SetSense(FGColumnVector3 vv) { vSense=vv; }
inline FGColumnVector3& GetSense(void) { return vSense; }
@ -298,6 +322,7 @@ private:
FGColumnVector3 vFb;
FGColumnVector3 vM;
FGColumnVector3 vXYZn;
FGColumnVector3 vActingXYZn;
FGColumnVector3 vDXYZ;
FGColumnVector3 vSense;

View file

@ -45,11 +45,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex),
vForces(3),
vMoments(3),
vMaxStaticGrip(3),
vMaxMomentResist(3)
FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex)
{
Name = "FGGroundReactions";

View file

@ -47,11 +47,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex),
vOmegaLocal(3),
vForces(3),
vRadius(3),
vGravity(3)
FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex)
{
Name = "FGInertial";

View file

@ -57,13 +57,7 @@ static const char *IdHdr = ID_LGEAR;
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
vMoment(3),
vWhlBodyVec(3),
vForce(3),
vLocalForce(3),
vWhlVelVec(3),
Exec(fdmex)
FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : Exec(fdmex)
{
string tmp;
string Retractable;
@ -202,19 +196,24 @@ FGColumnVector3& FGLGear::Force(void)
{
vForce.InitMatrix();
vMoment.InitMatrix();
if(isRetractable ) {
if( FCS->GetGearPos() < 0.01 ) {
GearUp=true;GearDown=false;
} else if(FCS->GetGearPos() > 0.99) {
GearDown=true;GearUp=false;
if (isRetractable) {
if (FCS->GetGearPos() < 0.01) {
GearUp = true;
GearDown = false;
} else if (FCS->GetGearPos() > 0.99) {
GearDown = true;
GearUp = false;
} else {
GearUp=false; GearDown=false;
GearUp = false;
GearDown = false;
}
} else {
GearUp=false; GearDown=true;
GearUp = false;
GearDown = true;
}
if( GearDown ) {
if (GearDown) {
double SteerGain = 0;
double SinWheel, CosWheel, SideWhlVel, RollingWhlVel;
double RollingForce, SideForce, FCoeff;

View file

@ -68,20 +68,22 @@ bool FGMassBalance::Run(void)
{
if (!FGModel::Run()) {
Weight = EmptyWeight + Propulsion->GetTanksWeight();
Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetPointMassWeight();
Mass = Weight / Inertial->gravity();
// Calculate new CG here.
vXYZcg = (Propulsion->GetTanksCG() + EmptyWeight*vbaseXYZcg) / Weight;
vXYZcg = (Propulsion->GetTanksCG() + EmptyWeight*vbaseXYZcg
+ GetPointMassCG() ) / Weight;
// Calculate new moments of inertia here
Ixx = baseIxx + Propulsion->GetTanksIxx(vXYZcg);
Iyy = baseIyy + Propulsion->GetTanksIyy(vXYZcg);
Izz = baseIzz + Propulsion->GetTanksIzz(vXYZcg);
Ixz = baseIxz + Propulsion->GetTanksIxz(vXYZcg);
Ixx = baseIxx + Propulsion->GetTanksIxx(vXYZcg) + GetPMIxx();
Iyy = baseIyy + Propulsion->GetTanksIyy(vXYZcg) + GetPMIyy();
Izz = baseIzz + Propulsion->GetTanksIzz(vXYZcg) + GetPMIzz();
Ixy = baseIxy + Propulsion->GetTanksIxy(vXYZcg) + GetPMIxy();
Ixz = baseIxz + Propulsion->GetTanksIxz(vXYZcg) + GetPMIxz();
if (debug_lvl > 1) Debug();
@ -93,6 +95,98 @@ bool FGMassBalance::Run(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGMassBalance::AddPointMass(double weight, double X, double Y, double Z)
{
PointMassLoc.push_back(*(new FGColumnVector3(X, Y, Z)));
PointMassWeight.push_back(weight);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGMassBalance::GetPointMassWeight(void)
{
double PM_total_weight = 0.0;
for (unsigned int i=0; i<PointMassWeight.size(); i++) {
PM_total_weight += PointMassWeight[i];
}
return PM_total_weight;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector3& FGMassBalance::GetPointMassCG(void)
{
PointMassCG.InitMatrix();
for (unsigned int i=0; i<PointMassLoc.size(); i++) {
PointMassCG += PointMassWeight[i]*PointMassLoc[i];
}
return PointMassCG;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGMassBalance::GetPMIxx(void)
{
double I = 0.0;
for (unsigned int i=0; i<PointMassLoc.size(); i++) {
I += PointMassLoc[i](eX)*PointMassLoc[i](eX)*PointMassWeight[i];
}
I /= (144.0*Inertial->gravity());
return I;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGMassBalance::GetPMIyy(void)
{
double I = 0.0;
for (unsigned int i=0; i<PointMassLoc.size(); i++) {
I += PointMassLoc[i](eY)*PointMassLoc[i](eY)*PointMassWeight[i];
}
I /= (144.0*Inertial->gravity());
return I;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGMassBalance::GetPMIzz(void)
{
double I = 0.0;
for (unsigned int i=0; i<PointMassLoc.size(); i++) {
I += PointMassLoc[i](eZ)*PointMassLoc[i](eZ)*PointMassWeight[i];
}
I /= (144.0*Inertial->gravity());
return I;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGMassBalance::GetPMIxy(void)
{
double I = 0.0;
for (unsigned int i=0; i<PointMassLoc.size(); i++) {
I += PointMassLoc[i](eX)*PointMassLoc[i](eY)*PointMassWeight[i];
}
I /= (144.0*Inertial->gravity());
return I;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double FGMassBalance::GetPMIxz(void)
{
double I = 0.0;
for (unsigned int i=0; i<PointMassLoc.size(); i++) {
I += PointMassLoc[i](eX)*PointMassLoc[i](eZ)*PointMassWeight[i];
}
I /= (144.0*Inertial->gravity());
return I;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGMassBalance::Debug(void)
{
if (debug_lvl & 16) { // Sanity check variables

View file

@ -44,6 +44,7 @@ INCLUDES
#include "FGModel.h"
#include "FGPropulsion.h"
#include <vector>
#define ID_MASSBALANCE "$Id$"
@ -65,8 +66,8 @@ public:
inline double GetIxx(void) {return Ixx;}
inline double GetIyy(void) {return Iyy;}
inline double GetIzz(void) {return Izz;}
inline double GetIxy(void) {return Ixy;}
inline double GetIxz(void) {return Ixz;}
inline double GetIyz(void) {return Iyz;}
inline FGColumnVector3& GetXYZcg(void) {return vXYZcg;}
inline double GetXYZcg(int axis) {return vXYZcg(axis);}
@ -74,9 +75,18 @@ public:
inline void SetBaseIxx(double bixx) { baseIxx = bixx;}
inline void SetBaseIyy(double biyy) { baseIyy = biyy;}
inline void SetBaseIzz(double bizz) { baseIzz = bizz;}
inline void SetBaseIxy(double bixy) { baseIxy = bixy;}
inline void SetBaseIxz(double bixz) { baseIxz = bixz;}
inline void SetBaseIyz(double biyz) { baseIyz = biyz;}
inline void SetBaseCG(const FGColumnVector3& CG) {vbaseXYZcg = CG;}
void AddPointMass(double weight, double X, double Y, double Z);
double GetPointMassWeight(void);
FGColumnVector3& GetPointMassCG(void);
double GetPMIxx(void);
double GetPMIyy(void);
double GetPMIzz(void);
double GetPMIxy(void);
double GetPMIxz(void);
private:
double Weight;
@ -85,16 +95,19 @@ private:
double Ixx;
double Iyy;
double Izz;
double Ixy;
double Ixz;
double Iyz;
double baseIxx;
double baseIyy;
double baseIzz;
double baseIxy;
double baseIxz;
double baseIyz;
FGColumnVector3 vXYZcg;
FGColumnVector3 vXYZtank;
FGColumnVector3 vbaseXYZcg;
vector <FGColumnVector3> PointMassLoc;
vector <double> PointMassWeight;
FGColumnVector3 PointMassCG;
void Debug(void);
};

View file

@ -195,6 +195,7 @@ void FGOutput::DelimitedOutput(string fname)
outstream << "Altitude, ";
outstream << "Phi, Tht, Psi, ";
outstream << "Alpha, ";
outstream << "Beta, ";
outstream << "Latitude, ";
outstream << "Longitude, ";
outstream << "Distance AGL, ";
@ -269,6 +270,7 @@ void FGOutput::DelimitedOutput(string fname)
outstream << Position->Geth() << ", ";
outstream << Rotation->GetEuler() << ", ";
outstream << Translation->Getalpha() << ", ";
outstream << Translation->Getbeta() << ", ";
outstream << Position->GetLatitude() << ", ";
outstream << Position->GetLongitude() << ", ";
outstream << Position->GetDistanceAGL() << ", ";

View file

@ -68,9 +68,7 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg)
Cycles=2;
IdleRPM=600;
// Set constants
Name = Eng_cfg->GetValue("NAME");
Eng_cfg->GetNextConfigLine();
while (Eng_cfg->GetValue() != string("/FG_PISTON")) {

View file

@ -95,10 +95,7 @@ extern double globalTriNormal[3];
extern double globalSceneryAltitude;
extern double globalSeaLevelRadius;
FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex),
vVel(3),
vVelDot(3),
vRunwayNormal(3)
FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGPosition";
LongitudeDot = LatitudeDot = RadiusDot = 0.0;

View file

@ -105,6 +105,7 @@ FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(e
Type = ttPropeller;
RPM = 0;
vTorque.InitMatrix();
if (debug_lvl & 2) cout << "Instantiated: FGPropeller" << endl;
}
@ -155,8 +156,8 @@ double FGPropeller::Calculate(double PowerAvailable)
if (P_Factor > 0.0001) {
alpha = fdmex->GetTranslation()->Getalpha();
beta = fdmex->GetTranslation()->Getbeta();
SetLocationY( GetLocationY() + P_Factor*alpha*fabs(Sense)/Sense);
SetLocationZ( GetLocationZ() + P_Factor*beta*fabs(Sense)/Sense);
SetActingLocationY( GetLocationY() + P_Factor*alpha*fabs(Sense)/Sense);
SetActingLocationZ( GetLocationZ() + P_Factor*beta*fabs(Sense)/Sense);
} else if (P_Factor < 0.000) {
cerr << "P-Factor value in config file must be greater than zero" << endl;
}
@ -175,10 +176,10 @@ double FGPropeller::Calculate(double PowerAvailable)
if (omega <= 5) omega = 1.0;
Torque = PowerAvailable / omega;
RPM = (RPS + ((Torque / Ixx) / (2.0 * M_PI)) * deltaT) * 60.0;
ExcessTorque = PowerAvailable / omega;
RPM = (RPS + ((ExcessTorque / Ixx) / (2.0 * M_PI)) * deltaT) * 60.0;
vMn = fdmex->GetRotation()->GetPQR()*vH + Torque*Sense;
vMn = fdmex->GetRotation()->GetPQR()*vH + vTorque*Sense;
return Thrust; // return thrust in pounds
}
@ -216,6 +217,8 @@ double FGPropeller::GetPowerRequired(void)
PowerRequired = cPReq*RPS*RPS*RPS*Diameter*Diameter*Diameter*Diameter
*Diameter*rho;
vTorque(eX) = PowerRequired / ((RPM/60)*2.0*M_PI);
return PowerRequired;
}

View file

@ -1,170 +1,171 @@
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGPropeller.h
Author: Jon S. Berndt
Date started: 08/24/00
------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU 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 General Public License for more
details.
You should have received a copy of the GNU 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 General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
08/24/00 JSB Created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGPROPELLER_H
#define FGPROPELLER_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGThruster.h"
#include "FGTable.h"
#include "FGTranslation.h"
#include "FGRotation.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPELLER "$Id$"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Propeller modeling class.
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGPropeller.h
Author: Jon S. Berndt
Date started: 08/24/00
------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU 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 General Public License for more
details.
You should have received a copy of the GNU 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 General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
08/24/00 JSB Created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGPROPELLER_H
#define FGPROPELLER_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGThruster.h"
#include "FGTable.h"
#include "FGTranslation.h"
#include "FGRotation.h"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPELLER "$Id$"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Propeller modeling class.
FGPropeller models a propeller given the tabular data for Ct and Cp
indexed by advance ratio "J". The data for the propeller is
stored in a config file named "prop_name.xml". The propeller config file
is referenced from the main aircraft config file in the "Propulsion" section.
See the constructor for FGPropeller to see what is read in and what should
be stored in the config file.<br>
Several references were helpful, here:<ul>
<li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
<li>Edwin Hartman, David Biermann, "The Aerodynamic Characteristics of
Full Scale Propellers Having 2, 3, and 4 Blades of Clark Y and R.A.F. 6
Airfoil Sections", NACA Report TN-640, 1938 (?)</li>
<li>Various NACA Technical Notes and Reports</li>
<ul>
@author Jon S. Berndt
@version $Id$
@see FGEngine
@see FGThruster
@see FGTable
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGPropeller : public FGThruster {
public:
/** Constructor for FGPropeller.
@param exec a pointer to the main executive object
@param AC_cfg a pointer to the main aircraft config file object */
FGPropeller(FGFDMExec* exec, FGConfigFile* AC_cfg);
/// Destructor for FGPropeller - deletes the FGTable objects
~FGPropeller();
/** Sets the Revolutions Per Minute for the propeller. Normally the propeller
instance will calculate its own rotational velocity, given the Torque
produced by the engine and integrating over time using the standard
equation for rotational acceleration "a": a = Q/I , where Q is Torque and
I is moment of inertia for the propeller.
@param rpm the rotational velocity of the propeller */
void SetRPM(double rpm) {RPM = rpm;}
/** This commands the pitch of the blade to change to the value supplied.
This call is meant to be issued either from the cockpit or by the flight
control system (perhaps to maintain constant RPM for a constant-speed
propeller). This value will be limited to be within whatever is specified
in the config file for Max and Min pitch. It is also one of the lookup
stored in a config file named "prop_name.xml". The propeller config file
is referenced from the main aircraft config file in the "Propulsion" section.
See the constructor for FGPropeller to see what is read in and what should
be stored in the config file.<br>
Several references were helpful, here:<ul>
<li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
<li>Edwin Hartman, David Biermann, "The Aerodynamic Characteristics of
Full Scale Propellers Having 2, 3, and 4 Blades of Clark Y and R.A.F. 6
Airfoil Sections", NACA Report TN-640, 1938 (?)</li>
<li>Various NACA Technical Notes and Reports</li>
<ul>
@author Jon S. Berndt
@version $Id$
@see FGEngine
@see FGThruster
@see FGTable
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGPropeller : public FGThruster {
public:
/** Constructor for FGPropeller.
@param exec a pointer to the main executive object
@param AC_cfg a pointer to the main aircraft config file object */
FGPropeller(FGFDMExec* exec, FGConfigFile* AC_cfg);
/// Destructor for FGPropeller - deletes the FGTable objects
~FGPropeller();
/** Sets the Revolutions Per Minute for the propeller. Normally the propeller
instance will calculate its own rotational velocity, given the Torque
produced by the engine and integrating over time using the standard
equation for rotational acceleration "a": a = Q/I , where Q is Torque and
I is moment of inertia for the propeller.
@param rpm the rotational velocity of the propeller */
void SetRPM(double rpm) {RPM = rpm;}
/** This commands the pitch of the blade to change to the value supplied.
This call is meant to be issued either from the cockpit or by the flight
control system (perhaps to maintain constant RPM for a constant-speed
propeller). This value will be limited to be within whatever is specified
in the config file for Max and Min pitch. It is also one of the lookup
indices to the power and thrust tables for variable-pitch propellers.
@param pitch the pitch of the blade in degrees. */
void SetPitch(double pitch) {Pitch = pitch;}
void SetPFactor(double pf) {P_Factor = pf;}
void SetSense(double s) { Sense = s;}
/// Retrieves the pitch of the propeller in degrees.
double GetPitch(void) { return Pitch; }
/// Retrieves the RPMs of the propeller
double GetRPM(void) { return RPM; }
/// Retrieves the propeller moment of inertia
double GetIxx(void) { return Ixx; }
/// Retrieves the Torque in foot-pounds (Don't you love the English system?)
double GetTorque(void) { return Torque; }
/** Retrieves the power required (or "absorbed") by the propeller -
i.e. the power required to keep spinning the propeller at the current
velocity, air density, and rotational rate. */
double GetPowerRequired(void);
/** Calculates and returns the thrust produced by this propeller.
Given the excess power available from the engine (in foot-pounds), the thrust is
calculated, as well as the current RPM. The RPM is calculated by integrating
the torque provided by the engine over what the propeller "absorbs"
(essentially the "drag" of the propeller).
@param PowerAvailable this is the excess power provided by the engine to
accelerate the prop. It could be negative, dictating that the propeller
would be slowed.
@return the thrust in pounds */
double Calculate(double PowerAvailable);
private:
int numBlades;
double RPM;
double Ixx;
double Diameter;
double MaxPitch;
double MinPitch;
double MinRPM;
double MaxRPM;
double P_Factor;
double Sense;
double Pitch;
double Torque;
FGTable *cThrust;
FGTable *cPower;
void Debug(void);
};
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif
@param pitch the pitch of the blade in degrees. */
void SetPitch(double pitch) {Pitch = pitch;}
void SetPFactor(double pf) {P_Factor = pf;}
void SetSense(double s) { Sense = s;}
/// Retrieves the pitch of the propeller in degrees.
double GetPitch(void) { return Pitch; }
/// Retrieves the RPMs of the propeller
double GetRPM(void) { return RPM; }
/// Retrieves the propeller moment of inertia
double GetIxx(void) { return Ixx; }
/// Retrieves the Torque in foot-pounds (Don't you love the English system?)
double GetTorque(void) { return vTorque(eX); }
/** Retrieves the power required (or "absorbed") by the propeller -
i.e. the power required to keep spinning the propeller at the current
velocity, air density, and rotational rate. */
double GetPowerRequired(void);
/** Calculates and returns the thrust produced by this propeller.
Given the excess power available from the engine (in foot-pounds), the thrust is
calculated, as well as the current RPM. The RPM is calculated by integrating
the torque provided by the engine over what the propeller "absorbs"
(essentially the "drag" of the propeller).
@param PowerAvailable this is the excess power provided by the engine to
accelerate the prop. It could be negative, dictating that the propeller
would be slowed.
@return the thrust in pounds */
double Calculate(double PowerAvailable);
private:
int numBlades;
double RPM;
double Ixx;
double Diameter;
double MaxPitch;
double MinPitch;
double MinRPM;
double MaxRPM;
double P_Factor;
double Sense;
double Pitch;
double ExcessTorque;
FGColumnVector3 vTorque;
FGTable *cThrust;
FGTable *cPower;
void Debug(void);
};
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif

View file

@ -62,9 +62,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec),
Forces(3),
Moments(3)
FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec)
{
Name = "FGPropulsion";
numSelectedFuelTanks = numSelectedOxiTanks = 0;
@ -90,16 +88,16 @@ bool FGPropulsion::Run(void)
double PowerAvailable;
dt = State->Getdt();
Forces.InitMatrix();
Moments.InitMatrix();
vForces.InitMatrix();
vMoments.InitMatrix();
if (!FGModel::Run()) {
for (unsigned int i=0; i<numEngines; i++) {
Thrusters[i]->SetdeltaT(dt*rate);
PowerAvailable = Engines[i]->Calculate(Thrusters[i]->GetPowerRequired());
Thrusters[i]->Calculate(PowerAvailable);
Forces += Thrusters[i]->GetBodyForces(); // sum body frame forces
Moments += Thrusters[i]->GetMoments(); // sum body frame moments
vForces += Thrusters[i]->GetBodyForces(); // sum body frame forces
vMoments += Thrusters[i]->GetMoments(); // sum body frame moments
}
return false;
} else {
@ -117,8 +115,8 @@ bool FGPropulsion::GetSteadyState(void)
int steady_count,j=0;
bool steady=false;
Forces.InitMatrix();
Moments.InitMatrix();
vForces.InitMatrix();
vMoments.InitMatrix();
if (!FGModel::Run()) {
for (unsigned int i=0; i<numEngines; i++) {
@ -138,8 +136,8 @@ bool FGPropulsion::GetSteadyState(void)
}
j++;
}
Forces += Thrusters[i]->GetBodyForces(); // sum body frame forces
Moments += Thrusters[i]->GetMoments(); // sum body frame moments
vForces += Thrusters[i]->GetBodyForces(); // sum body frame forces
vMoments += Thrusters[i]->GetMoments(); // sum body frame moments
Engines[i]->SetTrimMode(false);
}
@ -158,8 +156,8 @@ bool FGPropulsion::ICEngineStart(void)
int j;
dt = State->Getdt();
Forces.InitMatrix();
Moments.InitMatrix();
vForces.InitMatrix();
vMoments.InitMatrix();
for (unsigned int i=0; i<numEngines; i++) {
Engines[i]->SetTrimMode(true);
@ -170,8 +168,8 @@ bool FGPropulsion::ICEngineStart(void)
Thrusters[i]->Calculate(PowerAvailable);
j++;
}
Forces += Thrusters[i]->GetBodyForces(); // sum body frame forces
Moments += Thrusters[i]->GetMoments(); // sum body frame moments
vForces += Thrusters[i]->GetBodyForces(); // sum body frame forces
vMoments += Thrusters[i]->GetMoments(); // sum body frame moments
Engines[i]->SetTrimMode(false);
}
return true;

View file

@ -168,10 +168,10 @@ public:
string GetPropulsionStrings(void);
string GetPropulsionValues(void);
inline FGColumnVector3& GetForces(void) {return Forces; }
inline double GetForces(int n) { return Forces(n);}
inline FGColumnVector3& GetMoments(void) {return Moments;}
inline double GetMoments(int n) {return Moments(n);}
inline FGColumnVector3& GetForces(void) {return vForces; }
inline double GetForces(int n) { return vForces(n);}
inline FGColumnVector3& GetMoments(void) {return vMoments;}
inline double GetMoments(int n) {return vMoments(n);}
FGColumnVector3& GetTanksCG(void);
double GetTanksWeight(void);
@ -195,8 +195,8 @@ private:
unsigned int numTanks;
unsigned int numThrusters;
double dt;
FGColumnVector3 Forces;
FGColumnVector3 Moments;
FGColumnVector3 vForces;
FGColumnVector3 vMoments;
FGColumnVector3 vXYZtank;
void Debug(void);
};

View file

@ -75,14 +75,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex),
vPQR(3),
vAeroPQR(3),
vPQRdot(3),
vMoments(3),
vEuler(3),
vEulerRates(3),
vlastPQRdot(3)
FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGRotation";
cTht=cPhi=cPsi=1.0;

View file

@ -73,19 +73,7 @@ CLASS IMPLEMENTATION
// entry in the enum eParam definition in FGJSBBase.h. The ID is what must be used
// in any config file entry which references that item.
FGState::FGState(FGFDMExec* fdex) :
mTb2l(3,3),
mTl2b(3,3),
mTs2b(3,3),
mTb2s(3,3),
vQtrn(4),
vlastQdot(4),
vQdot(4),
vUVW(3),
vLocalVelNED(3),
vLocalEuler(3),
vTmp(4),
vEuler(3)
FGState::FGState(FGFDMExec* fdex)
{
FDMExec = fdex;
@ -323,13 +311,17 @@ double FGState::GetParameter(string val_string) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eParam FGState::GetParameterIndex(string val_string) {
eParam FGState::GetParameterIndex(string val_string)
{
return coeffdef[val_string];
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGState::SetParameter(eParam val_idx, double val) {
void FGState::SetParameter(eParam val_idx, double val)
{
int i;
switch(val_idx) {
case FG_ELEVATOR_POS:
FCS->SetDePos(val);
@ -350,10 +342,22 @@ void FGState::SetParameter(eParam val_idx, double val) {
FCS->SetDfPos(val);
break;
case FG_THROTTLE_POS:
FCS->SetThrottlePos(ActiveEngine,val);
if (ActiveEngine == -1) {
for (i=0; i<Propulsion->GetNumEngines(); i++) {
FCS->SetThrottlePos(i,val);
}
} else {
FCS->SetThrottlePos(ActiveEngine,val);
}
break;
case FG_MIXTURE_POS:
FCS->SetMixturePos(ActiveEngine,val);
if (ActiveEngine == -1) {
for (i=0; i<Propulsion->GetNumEngines(); i++) {
FCS->SetMixturePos(i,val);
}
} else {
FCS->SetMixturePos(ActiveEngine,val);
}
break;
case FG_ELEVATOR_CMD:
@ -375,19 +379,43 @@ void FGState::SetParameter(eParam val_idx, double val) {
FCS->SetDfCmd(val);
break;
case FG_THROTTLE_CMD:
FCS->SetThrottleCmd(ActiveEngine,val);
if (ActiveEngine == -1) {
for (i=0; i<Propulsion->GetNumEngines(); i++) {
FCS->SetThrottleCmd(i,val);
}
} else {
FCS->SetThrottleCmd(ActiveEngine,val);
}
break;
case FG_MIXTURE_CMD:
FCS->SetMixtureCmd(ActiveEngine,val);
if (ActiveEngine == -1) {
for (i=0; i<Propulsion->GetNumEngines(); i++) {
FCS->SetMixtureCmd(i,val);
}
} else {
FCS->SetMixtureCmd(ActiveEngine,val);
}
break;
case FG_MAGNETO_CMD:
Propulsion->GetEngine(ActiveEngine)->SetMagnetos((int)val); // need to account for -1
if (ActiveEngine == -1) {
for (i=0; i<Propulsion->GetNumEngines(); i++) {
Propulsion->GetEngine(i)->SetMagnetos((int)val);
}
} else {
Propulsion->GetEngine(ActiveEngine)->SetMagnetos((int)val);
}
break;
case FG_STARTER_CMD:
if (val < 0.001)
Propulsion->GetEngine(ActiveEngine)->SetStarter(false); // need to account for -1
else if (val >= 0.001)
Propulsion->GetEngine(ActiveEngine)->SetStarter(true); // need to account for -1
if (ActiveEngine == -1) {
for (i=0; i<Propulsion->GetNumEngines(); i++) {
if (val < 0.001)
Propulsion->GetEngine(i)->SetStarter(false);
else if (val >= 0.001)
Propulsion->GetEngine(i)->SetStarter(true);
}
} else {
Propulsion->GetEngine(ActiveEngine)->SetStarter(true);
}
break;
case FG_ACTIVE_ENGINE:
ActiveEngine = (int)val;

View file

@ -77,12 +77,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex),
vUVW(3),
vUVWdot(3),
vlastUVWdot(3),
mVel(3,3),
vAeroUVW(3)
FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGTranslation";
qbar = 0;