mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 21:05:34 +08:00
Ref T261, calculate scenery deviation
This commit is contained in:
committed by
Roland Winklmeier
parent
29407d113e
commit
2a86378f79
@@ -85,6 +85,13 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
CLength CAircraftSituationChange::getGuessedSceneryDeviation(const CLength &cg) const
|
||||
{
|
||||
if (cg.isNull()) { return this->guessedSceneryDeviation(); }
|
||||
if (this->guessedSceneryDeviation().isNull()) { return CLength::null(); }
|
||||
return this->guessedSceneryDeviation() - cg;
|
||||
}
|
||||
|
||||
QString CAircraftSituationChange::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
@@ -101,6 +108,7 @@ namespace BlackMisc
|
||||
QStringLiteral(" | accelerating.: ") % boolToYesNo(this->isConstAccelerating()) % QStringLiteral(" decelarating: ") % boolToYesNo(this->isConstDecelarating()) %
|
||||
QStringLiteral(" | rotate up: ") % boolToYesNo(this->isRotatingUp()) %
|
||||
QStringLiteral(" | push back: ") % boolToYesNo(this->containsPushBack()) %
|
||||
QStringLiteral(" | scenery delta: ") % m_guessedSceneryDeviation.valueRoundedWithUnit(1) %
|
||||
QStringLiteral(" | alt.delta: ") % m_altAglMean.valueRoundedWithUnit(1) % QStringLiteral("/") % m_altAglStdDev.valueRoundedWithUnit(1) %
|
||||
QStringLiteral(" | std.dev: pitch ") % m_pitchMean.valueRoundedWithUnit(1) % QStringLiteral("/") % m_pitchStdDev.valueRoundedWithUnit(1) %
|
||||
QStringLiteral(" gs ") % m_gsMean.valueRoundedWithUnit(1) % QStringLiteral("/") % m_gsStdDev.valueRoundedWithUnit(1) %
|
||||
@@ -156,6 +164,22 @@ namespace BlackMisc
|
||||
{
|
||||
if (situations.isEmpty()) { return false; }
|
||||
|
||||
const QList<double> gsValues = situations.groundSpeedValues(CSpeedUnit::kts());
|
||||
if (gsValues.size() == situations.size())
|
||||
{
|
||||
const QPair<double, double> gsKts = CMathUtils::standardDeviationAndMean(gsValues);
|
||||
m_gsStdDev = CSpeed(gsKts.first, CSpeedUnit::kts());
|
||||
m_gsMean = CSpeed(gsKts.second, CSpeedUnit::kts());
|
||||
}
|
||||
|
||||
const QList<double> pitchValues = situations.pitchValues(CAngleUnit::deg());
|
||||
if (gsValues.size() == situations.size())
|
||||
{
|
||||
const QPair<double, double> pitchDeg = CMathUtils::standardDeviationAndMean(pitchValues);
|
||||
m_pitchStdDev = CAngle(pitchDeg.first, CAngleUnit::deg());
|
||||
m_pitchMean = CAngle(pitchDeg.second, CAngleUnit::deg());
|
||||
}
|
||||
|
||||
const QList<double> altValues = situations.altitudeValues(CLengthUnit::ft());
|
||||
if (altValues.size() == situations.size())
|
||||
{
|
||||
@@ -182,24 +206,10 @@ namespace BlackMisc
|
||||
const QPair<double, double> deltaFt = CMathUtils::standardDeviationAndMean(altElvDeltas);
|
||||
m_altAglStdDev = CLength(deltaFt.first, CLengthUnit::ft());
|
||||
m_altAglMean = CLength(deltaFt.second, CLengthUnit::ft());
|
||||
|
||||
this->guessSceneryDeviation();
|
||||
}
|
||||
}
|
||||
|
||||
const QList<double> gsValues = situations.groundSpeedValues(CSpeedUnit::kts());
|
||||
if (gsValues.size() == situations.size())
|
||||
{
|
||||
const QPair<double, double> gsKts = CMathUtils::standardDeviationAndMean(gsValues);
|
||||
m_gsStdDev = CSpeed(gsKts.first, CSpeedUnit::kts());
|
||||
m_gsMean = CSpeed(gsKts.second, CSpeedUnit::kts());
|
||||
}
|
||||
|
||||
const QList<double> pitchValues = situations.pitchValues(CAngleUnit::deg());
|
||||
if (gsValues.size() == situations.size())
|
||||
{
|
||||
const QPair<double, double> pitchDeg = CMathUtils::standardDeviationAndMean(pitchValues);
|
||||
m_pitchStdDev = CAngle(pitchDeg.first, CAngleUnit::deg());
|
||||
m_pitchMean = CAngle(pitchDeg.second, CAngleUnit::deg());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,5 +218,26 @@ namespace BlackMisc
|
||||
static const CAircraftSituationChange null;
|
||||
return null;
|
||||
}
|
||||
|
||||
void CAircraftSituationChange::guessSceneryDeviation()
|
||||
{
|
||||
m_guessedSceneryDeviation = CLength::null();
|
||||
if (m_altAglStdDev.isNull()) { return; }
|
||||
if (m_altAglMean.isNull()) { return; }
|
||||
|
||||
// only for a small deviation we can calculate scenery differemce
|
||||
static const CLength maxDeviation(2, CLengthUnit::ft());
|
||||
|
||||
// Only on ground
|
||||
if (this->wasConstOnGround())
|
||||
{
|
||||
if (m_altAglStdDev > maxDeviation) { return; }
|
||||
m_guessedSceneryDeviation = m_altAglMean;
|
||||
}
|
||||
else if (this->wasConstOnGround())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -123,6 +123,13 @@ namespace BlackMisc
|
||||
//! Pitch values
|
||||
QPair<PhysicalQuantities::CAngle, PhysicalQuantities::CAngle> getPitchStdDevAndMean() const { return QPair<PhysicalQuantities::CAngle, PhysicalQuantities::CAngle>(m_pitchStdDev, m_pitchMean); }
|
||||
|
||||
//! Scnenery deviation (if it can be calculated, otherwise PhysicalQuantities::CLength::null)
|
||||
//! This is without CG, so substract CG to get deviation
|
||||
const PhysicalQuantities::CLength &guessedSceneryDeviation() const { return m_guessedSceneryDeviation; }
|
||||
|
||||
//! Get scenery deviation under consideration of CG
|
||||
PhysicalQuantities::CLength getGuessedSceneryDeviation(const PhysicalQuantities::CLength &cg) const;
|
||||
|
||||
//! \copydoc Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -139,6 +146,9 @@ namespace BlackMisc
|
||||
static const CAircraftSituationChange &null();
|
||||
|
||||
private:
|
||||
//! Guess scenery deviation
|
||||
void guessSceneryDeviation();
|
||||
|
||||
int m_situationsCount = -1;
|
||||
CCallsign m_correspondingCallsign;
|
||||
// latest -> m_timestampMSecsSinceEpoch
|
||||
@@ -167,6 +177,7 @@ namespace BlackMisc
|
||||
PhysicalQuantities::CAngle m_pitchMean = PhysicalQuantities::CAngle::null();
|
||||
PhysicalQuantities::CLength m_altAglStdDev = PhysicalQuantities::CLength::null();
|
||||
PhysicalQuantities::CLength m_altAglMean = PhysicalQuantities::CLength::null();
|
||||
PhysicalQuantities::CLength m_guessedSceneryDeviation = PhysicalQuantities::CLength::null();
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAircraftSituationChange,
|
||||
@@ -190,6 +201,7 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(altAglMean),
|
||||
BLACK_METAMEMBER(pitchStdDev),
|
||||
BLACK_METAMEMBER(pitchMean),
|
||||
BLACK_METAMEMBER(guessedSceneryDeviation),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch),
|
||||
BLACK_METAMEMBER(oldestTimestampMSecsSinceEpoch),
|
||||
BLACK_METAMEMBER(oldestAdjustedTimestampMSecsSinceEpoch),
|
||||
|
||||
Reference in New Issue
Block a user