mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-13 04:55:44 +08:00
DEBUG
This commit is contained in:
@@ -1309,6 +1309,7 @@ namespace BlackCore::Fsd
|
||||
default: qFatal("Precondition violated"); break;
|
||||
}
|
||||
const CCallsign callsign(dataUpdate.sender(), CCallsign::Aircraft);
|
||||
Q_ASSERT(dataUpdate.isValid());
|
||||
|
||||
CAircraftSituation situation(
|
||||
callsign,
|
||||
|
||||
@@ -94,4 +94,12 @@ namespace BlackCore::Fsd
|
||||
return VisualPilotDataStopped(m_sender, m_latitude, m_longitude, m_altitudeTrue, m_heightAgl, m_pitch, m_bank, m_heading,
|
||||
m_noseGearAngle);
|
||||
}
|
||||
|
||||
bool VisualPilotDataUpdate::isValid() const
|
||||
{
|
||||
return std::isfinite(m_latitude) && std::isfinite(m_longitude) && std::isfinite(m_altitudeTrue) && std::isfinite(m_heightAgl)
|
||||
&& std::isfinite(m_pitch) && std::isfinite(m_bank) && std::isfinite(m_heading)
|
||||
&& std::isfinite(m_xVelocity) && std::isfinite(m_yVelocity) && std::isfinite(m_zVelocity)
|
||||
&& std::isfinite(m_pitchRadPerSec) && std::isfinite(m_bankRadPerSec) && std::isfinite(m_headingRadPerSec) && std::isfinite(m_noseGearAngle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ namespace BlackCore::Fsd
|
||||
//! Return a stopped update with the same values
|
||||
VisualPilotDataStopped toStopped() const;
|
||||
|
||||
//! True if this is a valid packet (no infinity or NaN)
|
||||
bool isValid() const;
|
||||
|
||||
//! Properties
|
||||
//! @{
|
||||
double m_latitude = 0.0;
|
||||
|
||||
@@ -932,10 +932,12 @@ namespace BlackMisc::Aviation
|
||||
{
|
||||
auto copy = *this;
|
||||
const double time = CAircraftVelocity::c_timeUnit.convertFrom(ms, CTimeUnit::ms());
|
||||
Q_ASSERT(std::isfinite(copy.m_position.geodeticHeight().value()));
|
||||
copy.m_position.adjust(
|
||||
{ m_velocity.getVelocityZ(CSpeedUnit::m_s()) * time, CLengthUnit::m() },
|
||||
{ m_velocity.getVelocityX(CSpeedUnit::m_s()) * time, CLengthUnit::m() },
|
||||
{ m_velocity.getVelocityY(CSpeedUnit::m_s()) * time, CLengthUnit::m() });
|
||||
Q_ASSERT(std::isfinite(copy.m_position.geodeticHeight().value()));
|
||||
copy.m_pitch.addValueSameUnit(time * m_velocity.getHeadingVelocity(m_pitch.getUnit(), CAircraftVelocity::c_timeUnit));
|
||||
copy.m_bank.addValueSameUnit(time * m_velocity.getHeadingVelocity(m_bank.getUnit(), CAircraftVelocity::c_timeUnit));
|
||||
copy.m_heading.addValueSameUnit(time * m_velocity.getHeadingVelocity(m_heading.getUnit(), CAircraftVelocity::c_timeUnit));
|
||||
@@ -951,6 +953,11 @@ namespace BlackMisc::Aviation
|
||||
const double toAlt = to.m_position.geodeticHeight().value(CAircraftVelocity::c_xyzLengthUnit);
|
||||
const double fromAlt = from.m_position.geodeticHeight().value(CAircraftVelocity::c_xyzLengthUnit);
|
||||
o_ok = distance < CLength(100, CLengthUnit::m()) && std::abs(toAlt - fromAlt) < 100;
|
||||
Q_ASSERT(std::isfinite(toAlt));
|
||||
Q_ASSERT(std::isfinite(fromAlt));
|
||||
Q_ASSERT(std::isfinite(toAlt - fromAlt));
|
||||
Q_ASSERT(std::isfinite((toAlt - fromAlt) / time));
|
||||
Q_ASSERT(std::abs(toAlt - fromAlt) < 10000);
|
||||
return
|
||||
{
|
||||
distance.value(CAircraftVelocity::c_xyzLengthUnit) * bearing.sin() / time,
|
||||
|
||||
@@ -73,6 +73,12 @@ namespace BlackMisc::Aviation
|
||||
return c_timeUnit.convertFrom(angleUnit.convertFrom(m_heading, c_pbhAngleUnit), timeUnit);
|
||||
}
|
||||
|
||||
bool CAircraftVelocity::isValid() const
|
||||
{
|
||||
return std::isfinite(m_x) && std::isfinite(m_y) && std::isfinite(m_z)
|
||||
&& std::isfinite(m_pitch) && std::isfinite(m_roll) && std::isfinite(m_heading);
|
||||
}
|
||||
|
||||
CAircraftVelocity& CAircraftVelocity::operator+=(const CAircraftVelocity& other)
|
||||
{
|
||||
m_x += other.m_x;
|
||||
|
||||
@@ -61,6 +61,9 @@ namespace BlackMisc::Aviation
|
||||
double getHeadingVelocity(PhysicalQuantities::CAngleUnit angleUnit, PhysicalQuantities::CTimeUnit timeUnit) const;
|
||||
//! @}
|
||||
|
||||
//! False if any component is NaN or infinity
|
||||
bool isValid() const;
|
||||
|
||||
//! Arithmetic operator
|
||||
//! @{
|
||||
friend CAircraftVelocity operator +(CAircraftVelocity a, const CAircraftVelocity &b) { return a += b; }
|
||||
|
||||
@@ -401,7 +401,10 @@ namespace BlackMisc::Geo
|
||||
{
|
||||
setLatitude({ latitude().value(CAngleUnit::rad()) + dLat.value(CLengthUnit::m()) / c_earthRadiusMeters<double>, CAngleUnit::rad() });
|
||||
setLongitude({ longitude().value(CAngleUnit::rad()) + dLon.value(CLengthUnit::m()) / c_earthRadiusMeters<double> / latitude().cos(), CAngleUnit::rad() });
|
||||
Q_ASSERT(std::isfinite(dAlt.value()));
|
||||
Q_ASSERT(std::isfinite(geodeticHeight().value()));
|
||||
setGeodeticHeight(geodeticHeight().withOffset(dAlt));
|
||||
Q_ASSERT(std::isfinite(geodeticHeight().value()));
|
||||
}
|
||||
|
||||
void CCoordinateGeodetic::setNormalVector(const std::array<double, 3> &normalVector)
|
||||
|
||||
@@ -30,6 +30,10 @@ namespace BlackMisc::Simulation
|
||||
{
|
||||
m_situation = extrapolated;
|
||||
m_situation.setVelocity(situation.getVelocity() + error);
|
||||
|
||||
Q_ASSERT(situation.getVelocity().isValid());
|
||||
Q_ASSERT(error.isValid());
|
||||
Q_ASSERT(m_situation.getVelocity().isValid());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -122,7 +122,10 @@ namespace BlackMisc::Simulation
|
||||
CAircraftSituation oldSituation = m_interpolant.getOldSituation();
|
||||
CAircraftSituation newSituation = m_interpolant.getNewSituation();
|
||||
|
||||
Q_ASSERT_X(newSituation.getAdjustedMSecsSinceEpoch() >= oldSituation.getAdjustedMSecsSinceEpoch(), Q_FUNC_INFO, "Wrong order");
|
||||
if (newSituation.getAdjustedMSecsSinceEpoch() <= oldSituation.getAdjustedMSecsSinceEpoch())
|
||||
{
|
||||
Q_ASSERT_X(newSituation.getAdjustedMSecsSinceEpoch() >= oldSituation.getAdjustedMSecsSinceEpoch(), Q_FUNC_INFO, "Wrong order");
|
||||
}
|
||||
|
||||
const bool updated = m_situationsLastModifiedUsed < m_situationsLastModified;
|
||||
const bool newSplit = newSituation.getAdjustedMSecsSinceEpoch() < m_currentTimeMsSinceEpoch;
|
||||
|
||||
@@ -252,12 +252,6 @@ namespace BlackMisc::Simulation
|
||||
const double dt2 = static_cast<double>(m_nextSampleAdjustedTime - m_prevSampleAdjustedTime);
|
||||
double timeFraction = dt1 / dt2;
|
||||
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
BLACK_VERIFY_X(dt1 >= 0, Q_FUNC_INFO, "Expect postive dt1");
|
||||
BLACK_VERIFY_X(dt2 > 0, Q_FUNC_INFO, "Expect postive dt2");
|
||||
BLACK_VERIFY_X(isAcceptableTimeFraction(timeFraction), Q_FUNC_INFO, "Expect fraction 0-1");
|
||||
}
|
||||
timeFraction = clampValidTimeFraction(timeFraction);
|
||||
const qint64 interpolatedTime = m_prevSampleTime + qRound64(timeFraction * dt2);
|
||||
|
||||
@@ -362,7 +356,7 @@ namespace BlackMisc::Simulation
|
||||
valid = CAircraftSituation::isValidVector(normalVector);
|
||||
if (!valid && CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
BLACK_VERIFY_X(valid, Q_FUNC_INFO, "invalid vector");
|
||||
//BLACK_VERIFY_X(valid, Q_FUNC_INFO, "invalid vector");
|
||||
CLogMessage(this).warning(u"Invalid vector for '%1' v: %2 %3 %4") <<
|
||||
currentSituation.getCallsign().asString() << normalVector[0] << normalVector[1] << normalVector[2];
|
||||
}
|
||||
|
||||
@@ -258,13 +258,6 @@ namespace BlackMisc::Simulation
|
||||
const CCallsign cs = situation.getCallsign();
|
||||
if (cs.isEmpty()) { return situation; }
|
||||
|
||||
// testing
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
BLACK_VERIFY_X(situation.getTimeOffsetMs() > 0, Q_FUNC_INFO, "Missing offset");
|
||||
BLACK_VERIFY_X(situation.isValidVectorRange(), Q_FUNC_INFO, "Invalid vector");
|
||||
}
|
||||
|
||||
// add altitude offset (for testing only)
|
||||
CAircraftSituation situationCorrected(allowTestAltitudeOffset ? this->addTestAltitudeOffsetToSituation(situation) : situation);
|
||||
|
||||
|
||||
@@ -592,10 +592,6 @@ namespace BlackMisc
|
||||
this->container().clear();
|
||||
const qint64 osTime = value.getTimeOffsetMs();
|
||||
const qint64 os = -1 * qAbs(deltaTimeMs < 0 ? osTime : deltaTimeMs);
|
||||
if (BlackConfig::CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
BLACK_VERIFY_X(os < 0, Q_FUNC_INFO, "Need negative offset time to prefill time");
|
||||
}
|
||||
this->container().push_front(value);
|
||||
for (int i = 1; i < elements; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user