mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T778, added "likelyOnGroundElevation" as parameter for "ememberElevationAndSimulatorCG"
This commit is contained in:
committed by
Mat Sutcliffe
parent
09a2377197
commit
829777bf3a
@@ -220,7 +220,7 @@ namespace BlackSimPlugin
|
||||
situation.setPitch({ m_flightgearData.pitchDeg, CAngleUnit::deg() });
|
||||
situation.setBank({ m_flightgearData.rollDeg, CAngleUnit::deg() });
|
||||
situation.setGroundSpeed({ m_flightgearData.groundspeedKts, CSpeedUnit::kts() });
|
||||
situation.setGroundElevation(CAltitude(m_flightgearData.groundElevation,CAltitude::MeanSeaLevel,CLengthUnit::m()),CAircraftSituation::FromProvider);
|
||||
situation.setGroundElevation(CAltitude(m_flightgearData.groundElevation, CAltitude::MeanSeaLevel, CLengthUnit::m()), CAircraftSituation::FromProvider);
|
||||
|
||||
// Updates
|
||||
// Do not update ICAO codes, as this overrides reverse lookups
|
||||
@@ -750,13 +750,20 @@ namespace BlackSimPlugin
|
||||
BLACK_VERIFY_X(fgAircraft.hasCallsign(), Q_FUNC_INFO, "Need callsign");
|
||||
if (!fgAircraft.hasCallsign()) { continue; }
|
||||
|
||||
const double cgValue = verticalOffsetsMeters[i]; // FG offset is swift CG
|
||||
const CAltitude elevationAlt = std::isnan(elevationsMeters[i]) ? CAltitude::null() : CAltitude(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
|
||||
const CElevationPlane elevation(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
|
||||
CElevationPlane elevation = CElevationPlane::null();
|
||||
if (!std::isnan(elevationsMeters[i]))
|
||||
{
|
||||
const CAltitude elevationAlt = CAltitude(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
|
||||
elevation = CElevationPlane(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
|
||||
}
|
||||
|
||||
const double cgValue = verticalOffsetsMeters[i]; // XP offset is swift CG
|
||||
const CLength cg = std::isnan(cgValue) ?
|
||||
CLength::null() :
|
||||
CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft());
|
||||
this->rememberElevationAndSimulatorCG(cs, fgAircraft.getAircraftModel(), elevation, cg);
|
||||
|
||||
// if we knew "on ground" here we could set it as parameter of rememberElevationAndSimulatorCG
|
||||
this->rememberElevationAndSimulatorCG(cs, fgAircraft.getAircraftModel(), false, elevation, cg);
|
||||
|
||||
// loopback
|
||||
if (logCallsigns.contains(cs))
|
||||
@@ -827,10 +834,11 @@ namespace BlackSimPlugin
|
||||
bool CSimulatorFlightgear::requestElevation(const BlackMisc::Geo::ICoordinateGeodetic &reference, const BlackMisc::Aviation::CCallsign &callsign)
|
||||
{
|
||||
if (this->isShuttingDownOrDisconnected()) { return false; }
|
||||
if(reference.isNull()) { return false; }
|
||||
if (reference.isNull()) { return false; }
|
||||
|
||||
CCoordinateGeodetic pos(reference);
|
||||
if(!pos.hasMSLGeodeticHeight()){
|
||||
if (!pos.hasMSLGeodeticHeight())
|
||||
{
|
||||
// testing showed: height has an influence on the returned result
|
||||
// - the most accurate value seems to be returned if the height is close to the elevation
|
||||
// - in normal scenarios there is no much difference of the results if 0 is used
|
||||
|
||||
@@ -836,25 +836,21 @@ namespace BlackSimPlugin
|
||||
// Near ground we use faster updates
|
||||
const CCallsign cs(simObject.getCallsign());
|
||||
CAircraftSituation lastSituation = m_lastSentSituations[cs];
|
||||
const bool moving = lastSituation.isMoving();
|
||||
const bool moving = lastSituation.isMoving();
|
||||
const bool onGround = remoteAircraftData.isOnGround();
|
||||
|
||||
// CElevationPlane: deg, deg, feet
|
||||
// we only remember near ground
|
||||
CElevationPlane elevation;
|
||||
const CElevationPlane elevation = CElevationPlane(remoteAircraftData.latitudeDeg, remoteAircraftData.longitudeDeg, remoteAircraftData.elevationFt, CElevationPlane::singlePointRadius());
|
||||
if (remoteAircraftData.aboveGroundFt() < 250)
|
||||
{
|
||||
const CLength cg(remoteAircraftData.cgToGroundFt, CLengthUnit::ft());
|
||||
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), elevation, cg);
|
||||
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), onGround, elevation, cg);
|
||||
}
|
||||
|
||||
const bool log = this->isLogCallsign(cs);
|
||||
if (log)
|
||||
{
|
||||
if (elevation.isNull())
|
||||
{
|
||||
elevation = CElevationPlane(remoteAircraftData.latitudeDeg, remoteAircraftData.longitudeDeg, remoteAircraftData.elevationFt, CElevationPlane::singlePointRadius());
|
||||
}
|
||||
|
||||
// update lat/lng/alt with real data from sim
|
||||
const CAltitude alt(remoteAircraftData.altitudeFt, CAltitude::MeanSeaLevel, CAltitude::TrueAltitude, CLengthUnit::ft());
|
||||
lastSituation.setPosition(elevation);
|
||||
@@ -894,7 +890,7 @@ namespace BlackSimPlugin
|
||||
so.setAircraftModelString(modelString);
|
||||
|
||||
// update in 2 providers
|
||||
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), CElevationPlane::null(), cg); // env. provider
|
||||
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), false, CElevationPlane::null(), cg); // env. provider
|
||||
this->updateCGAndModelString(cs, cg, modelString); // remote aircraft provider
|
||||
}
|
||||
|
||||
|
||||
@@ -1064,13 +1064,20 @@ namespace BlackSimPlugin
|
||||
BLACK_VERIFY_X(xpAircraft.hasCallsign(), Q_FUNC_INFO, "Need callsign");
|
||||
if (!xpAircraft.hasCallsign()) { continue; }
|
||||
|
||||
CElevationPlane elevation = CElevationPlane::null();
|
||||
if (!std::isnan(elevationsMeters[i]))
|
||||
{
|
||||
const CAltitude elevationAlt = CAltitude(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
|
||||
elevation = CElevationPlane(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
|
||||
}
|
||||
|
||||
const double cgValue = verticalOffsetsMeters[i]; // XP offset is swift CG
|
||||
const CAltitude elevationAlt = std::isnan(elevationsMeters[i]) ? CAltitude::null() : CAltitude(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
|
||||
const CElevationPlane elevation(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
|
||||
const CLength cg = std::isnan(cgValue) ?
|
||||
CLength::null() :
|
||||
CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft());
|
||||
this->rememberElevationAndSimulatorCG(cs, xpAircraft.getAircraftModel(), elevation, cg);
|
||||
|
||||
// if we knew "on ground" here we could set it as parameter of rememberElevationAndSimulatorCG
|
||||
this->rememberElevationAndSimulatorCG(cs, xpAircraft.getAircraftModel(), false, elevation, cg);
|
||||
|
||||
// loopback
|
||||
if (logCallsigns.contains(cs))
|
||||
|
||||
Reference in New Issue
Block a user