Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/models/FGAuxiliary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
vAeroPQR.InitMatrix();
vMachUVW.InitMatrix();
vEulerRates.InitMatrix();
vNEUFromStart.InitMatrix();
NEUFromStartInitialized = false;

bind();

Expand Down Expand Up @@ -116,6 +118,8 @@ bool FGAuxiliary::InitModel(void)
vAeroPQR.InitMatrix();
vMachUVW.InitMatrix();
vEulerRates.InitMatrix();
vNEUFromStart.InitMatrix();
NEUFromStartInitialized = false;

return true;
}
Expand Down Expand Up @@ -180,7 +184,15 @@ bool FGAuxiliary::Run(bool Holding)
vMachUVW(eV) = vAeroUVW(eV) / in.SoundSpeed;
vMachUVW(eW) = vAeroUVW(eW) / in.SoundSpeed;

// Position
// Position tracking in local frame with local frame origin at lat, lon of initial condition
// and at 0 altitude relative to the reference ellipsoid. Position is NEU (North, East, UP) in feet.
if (!NEUFromStartInitialized) {
NEUStartLocation = FDMExec->GetIC()->GetPosition();
NEUStartLocation.SetPositionGeodetic(NEUStartLocation.GetLongitude(), NEUStartLocation.GetGeodLatitudeRad(), 0.0);
NEUFromStartInitialized = true;
}
Comment on lines +187 to +193
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather initialize NEUStartLocation in a method that would be called by FGFDMExec::Initialize:

jsbsim/src/FGFDMExec.cpp

Lines 676 to 681 in 83e3df2

void FGFDMExec::Initialize(const FGInitialCondition* FGIC)
{
Propagate->SetInitialState(FGIC);
Winds->SetWindNED(FGIC->GetWindNEDFpsIC());
Run();
}

Since FGFDMExec::Initialize is called itself by FGFDMExec::RunIC that would ensure that NEUStartLocation would be initialized at the same time than the rest of the simulation. And that would save te usage of the flag NEUFromStartInitialized.

vNEUFromStart = NEUStartLocation.LocationToLocal(in.vLocation);
vNEUFromStart(3) *= -1.0; // Flip sign for Up, so + for altitude above reference ellipsoid

Vground = sqrt( in.vVel(eNorth)*in.vVel(eNorth) + in.vVel(eEast)*in.vVel(eEast) );

Expand Down Expand Up @@ -355,15 +367,15 @@ double FGAuxiliary::GetNlf(void) const
double FGAuxiliary::GetLongitudeRelativePosition(void) const
{
return in.vLocation.GetDistanceTo(FDMExec->GetIC()->GetLongitudeRadIC(),
in.vLocation.GetGeodLatitudeRad())* fttom;
in.vLocation.GetGeodLatitudeRad());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear why the unit conversion from feet to meters is removed ? This method is used to compute the property position/distance-from-start-lon-mt which is expressed in meters.

PropertyManager->Tie("position/distance-from-start-lon-mt", this, &FGAuxiliary::GetLongitudeRelativePosition);

}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

double FGAuxiliary::GetLatitudeRelativePosition(void) const
{
return in.vLocation.GetDistanceTo(in.vLocation.GetLongitude(),
FDMExec->GetIC()->GetGeodLatitudeRadIC())* fttom;
FDMExec->GetIC()->GetGeodLatitudeRadIC());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. This method is used to compute the property position/distance-from-start-lat-mt which is expressed in meters.

PropertyManager->Tie("position/distance-from-start-lat-mt", this, &FGAuxiliary::GetLatitudeRelativePosition);

}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand All @@ -372,7 +384,7 @@ double FGAuxiliary::GetDistanceRelativePosition(void) const
{
auto ic = FDMExec->GetIC();
return in.vLocation.GetDistanceTo(ic->GetLongitudeRadIC(),
ic->GetGeodLatitudeRadIC())* fttom;
ic->GetGeodLatitudeRadIC());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. This method is used to compute the property position/distance-from-start-mag-mt which is expressed in meters.

PropertyManager->Tie("position/distance-from-start-mag-mt", this, &FGAuxiliary::GetDistanceRelativePosition);

}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -437,6 +449,10 @@ void FGAuxiliary::bind(void)
PropertyManager->Tie("position/vrp-gc-latitude_deg", &vLocationVRP, &FGLocation::GetLatitudeDeg);
PropertyManager->Tie("position/vrp-longitude_deg", &vLocationVRP, &FGLocation::GetLongitudeDeg);
PropertyManager->Tie("position/vrp-radius-ft", &vLocationVRP, &FGLocation::GetRadius);

PropertyManager->Tie("position/neu-n-ft", this, eX, &FGAuxiliary::GetNEUPositionFromStart);
PropertyManager->Tie("position/neu-e-ft", this, eY, &FGAuxiliary::GetNEUPositionFromStart);
PropertyManager->Tie("position/neu-u-ft", this, eZ, &FGAuxiliary::GetNEUPositionFromStart);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
13 changes: 13 additions & 0 deletions src/models/FGAuxiliary.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ class JSBSIM_API FGAuxiliary : public FGModel {
double GetLatitudeRelativePosition (void) const;
double GetDistanceRelativePosition (void) const;

/** The North East Up (NEU) frame is a local tangential frame fixed in the ECEF
frame (i.e following the Earth's rotation).
The NEU frame's origin is fixed at the aircrat's initial lat, lon position
and at an altitude of 0 ft relative to the reference ellipsoid.
The NEU frame is a left-handed coordinate system, unlike the NED frame. So
beware of differences when computing cross products. */
double GetNEUPositionFromStart(int idx) const { return vNEUFromStart(idx); }
const FGColumnVector3& GetNEUPositionFromStart() const { return vNEUFromStart; }

void SetAeroPQR(const FGColumnVector3& tt) { vAeroPQR = tt; }

struct Inputs {
Expand Down Expand Up @@ -329,6 +338,10 @@ class JSBSIM_API FGAuxiliary : public FGModel {
FGColumnVector3 vMachUVW;
FGLocation vLocationVRP;

bool NEUFromStartInitialized;
FGLocation NEUStartLocation;
FGColumnVector3 vNEUFromStart;

double Vt, Vground;
double Mach, MachU;
double qbar, qbarUW, qbarUV;
Expand Down
Loading