mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
Fix wrong pitch and bank value interpolation
Pitch and bank angle in CAircraftSituation are according to the common aeronautical convention: * Bank in degrees, positive = roll right * Pitch in degrees, positive = pitch up Microsoft Flight Simulator is using inverted angles, which was incorrectly adjusted in the interpolator. This caused wrong values for X-Plane. This angle correction is now moved into the MSFS specific plugins. Additionally, so far the pitch and bank angles from own aircraft were not yet corrected for MSFS. So we did send wrong values to the network. refs #790
This commit is contained in:
committed by
Klaus Basan
parent
44fcba296b
commit
42737faf2c
@@ -161,20 +161,12 @@ namespace BlackMisc
|
|||||||
CAngle pitchBegin = oldSituation.getPitch();
|
CAngle pitchBegin = oldSituation.getPitch();
|
||||||
CAngle pitchEnd = newSituation.getPitch();
|
CAngle pitchEnd = newSituation.getPitch();
|
||||||
CAngle pitch = (pitchEnd - pitchBegin) * simulationTimeFraction + pitchBegin;
|
CAngle pitch = (pitchEnd - pitchBegin) * simulationTimeFraction + pitchBegin;
|
||||||
|
|
||||||
// TODO: According to the specification, pitch above horizon should be negative.
|
|
||||||
// But somehow we get positive pitches from the network.
|
|
||||||
pitch *= -1;
|
|
||||||
currentSituation.setPitch(pitch);
|
currentSituation.setPitch(pitch);
|
||||||
|
|
||||||
// Interpolate bank: Bank = (BankB - BankA) * t + BankA
|
// Interpolate bank: Bank = (BankB - BankA) * t + BankA
|
||||||
CAngle bankBegin = oldSituation.getBank();
|
CAngle bankBegin = oldSituation.getBank();
|
||||||
CAngle bankEnd = newSituation.getBank();
|
CAngle bankEnd = newSituation.getBank();
|
||||||
CAngle bank = (bankEnd - bankBegin) * simulationTimeFraction + bankBegin;
|
CAngle bank = (bankEnd - bankBegin) * simulationTimeFraction + bankBegin;
|
||||||
|
|
||||||
// TODO: According to the specification, banks to the right should be negative.
|
|
||||||
// But somehow we get positive banks from the network.
|
|
||||||
bank *= -1.0;
|
|
||||||
currentSituation.setBank(bank);
|
currentSituation.setBank(bank);
|
||||||
|
|
||||||
currentSituation.setGroundSpeed((newSituation.getGroundSpeed() - oldSituation.getGroundSpeed())
|
currentSituation.setGroundSpeed((newSituation.getGroundSpeed() - oldSituation.getGroundSpeed())
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ namespace BlackSimPlugin
|
|||||||
pbhstrct.hdg = newSituation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
pbhstrct.hdg = newSituation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
||||||
pbhstrct.pitch = newSituation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
pbhstrct.pitch = newSituation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
||||||
pbhstrct.bank = newSituation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
pbhstrct.bank = newSituation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
||||||
|
// MSFS has inverted pitch and bank angles
|
||||||
|
pbhstrct.pitch = -pbhstrct.pitch;
|
||||||
|
pbhstrct.bank = -pbhstrct.bank;
|
||||||
positionVelocity.pbh = pbhstrct.pbh;
|
positionVelocity.pbh = pbhstrct.pbh;
|
||||||
|
|
||||||
// Ground velocity
|
// Ground velocity
|
||||||
@@ -107,6 +110,9 @@ namespace BlackSimPlugin
|
|||||||
pbhstrct.hdg = situation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
pbhstrct.hdg = situation.getHeading().value(CAngleUnit::deg()) * CFs9Sdk::headingMultiplier();
|
||||||
pbhstrct.pitch = situation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
pbhstrct.pitch = situation.getPitch().value(CAngleUnit::deg()) * CFs9Sdk::pitchMultiplier();
|
||||||
pbhstrct.bank = situation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
pbhstrct.bank = situation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier();
|
||||||
|
// MSFS has inverted pitch and bank angles
|
||||||
|
pbhstrct.pitch = -pbhstrct.pitch;
|
||||||
|
pbhstrct.bank = -pbhstrct.bank;
|
||||||
positionSlewMode.pbh = pbhstrct.pbh;
|
positionSlewMode.pbh = pbhstrct.pbh;
|
||||||
|
|
||||||
return positionSlewMode;
|
return positionSlewMode;
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ namespace BlackSimPlugin
|
|||||||
if (bank > 180.0)
|
if (bank > 180.0)
|
||||||
bank -= 360;
|
bank -= 360;
|
||||||
|
|
||||||
|
// MSFS has inverted pitch and bank angles
|
||||||
|
pitch = -pitch;
|
||||||
|
bank = -bank;
|
||||||
situation.setPitch(CAngle(pitch, CAngleUnit::deg()));
|
situation.setPitch(CAngle(pitch, CAngleUnit::deg()));
|
||||||
situation.setBank(CAngle(bank, CAngleUnit::deg()));
|
situation.setBank(CAngle(bank, CAngleUnit::deg()));
|
||||||
situation.setHeading(CHeading(pbhstrct.hdg / CFs9Sdk::headingMultiplier(), CHeading::Magnetic, CAngleUnit::deg()));
|
situation.setHeading(CHeading(pbhstrct.hdg / CFs9Sdk::headingMultiplier(), CHeading::Magnetic, CAngleUnit::deg()));
|
||||||
|
|||||||
@@ -358,6 +358,9 @@ namespace BlackSimPlugin
|
|||||||
situation.setPosition(position);
|
situation.setPosition(position);
|
||||||
|
|
||||||
// speeds, situation
|
// speeds, situation
|
||||||
|
// MSFS has inverted pitch and bank angles
|
||||||
|
pitchRaw = -pitchRaw;
|
||||||
|
bankRaw = -bankRaw;
|
||||||
const double angleCorrectionFactor = 360.0 / 65536.0 / 65536.0; // see FSUIPC docu
|
const double angleCorrectionFactor = 360.0 / 65536.0 / 65536.0; // see FSUIPC docu
|
||||||
CAngle pitch = CAngle(pitchRaw * angleCorrectionFactor, CAngleUnit::deg());
|
CAngle pitch = CAngle(pitchRaw * angleCorrectionFactor, CAngleUnit::deg());
|
||||||
CAngle bank = CAngle(bankRaw * angleCorrectionFactor, CAngleUnit::deg());
|
CAngle bank = CAngle(bankRaw * angleCorrectionFactor, CAngleUnit::deg());
|
||||||
|
|||||||
@@ -378,6 +378,9 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
BlackMisc::Aviation::CAircraftSituation aircraftSituation;
|
BlackMisc::Aviation::CAircraftSituation aircraftSituation;
|
||||||
aircraftSituation.setPosition(position);
|
aircraftSituation.setPosition(position);
|
||||||
|
// MSFS has inverted pitch and bank angles
|
||||||
|
simulatorOwnAircraft.pitch = -simulatorOwnAircraft.pitch;
|
||||||
|
simulatorOwnAircraft.bank = -simulatorOwnAircraft.bank;
|
||||||
aircraftSituation.setPitch(CAngle(simulatorOwnAircraft.pitch, CAngleUnit::deg()));
|
aircraftSituation.setPitch(CAngle(simulatorOwnAircraft.pitch, CAngleUnit::deg()));
|
||||||
aircraftSituation.setBank(CAngle(simulatorOwnAircraft.bank, CAngleUnit::deg()));
|
aircraftSituation.setBank(CAngle(simulatorOwnAircraft.bank, CAngleUnit::deg()));
|
||||||
aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeading, CHeading::True, CAngleUnit::deg()));
|
aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeading, CHeading::True, CAngleUnit::deg()));
|
||||||
|
|||||||
Reference in New Issue
Block a user