Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(flight_model): Add drag from landing lights #8554

Merged
merged 12 commits into from
Apr 9, 2024
Prev Previous commit
Next Next commit
Auto stash before checking out "origin/master"
  • Loading branch information
crocket63 committed Mar 7, 2024
commit 7ffd15cc10fbf59cdcfc6dfb3619561db47ea0f7
12 changes: 9 additions & 3 deletions fbw-a32nx/src/wasm/systems/a320_systems_wasm/src/gear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use systems_wasm::aspects::{
};
use systems_wasm::{set_data_on_sim_object, Variable};

/// Gear status feedback to MSFS
/// Note this is also used to inject plane drag from landing lights/RAT/Sat antenna
pub(super) fn gear(builder: &mut MsfsAspectBuilder) -> Result<(), Box<dyn Error>> {
// Read gear demand from all sim sim events and mask them
builder.event_to_variable(
Expand Down Expand Up @@ -87,24 +89,28 @@ impl VariablesToObject for GearPosition {
Variable::named("GEAR_DOOR_RIGHT_POSITION"),
Variable::named("LANDING_2_POSITION"),
Variable::named("LANDING_3_POSITION"),
Variable::named("RAT_STOW_POSITION"),
]
}

fn write(&mut self, values: Vec<f64>) -> ObjectWrite {
// Ratio of MSFS gear drag corresponding to door drag
const FAKE_GEAR_POSITION_FOR_DOOR_DRAG: f64 = 0.10;
const FAKE_GEAR_POSITION_FOR_DOOR_DRAG: f64 = 0.1;
// Ratio of MSFS gear drag corresponding to landing light drag
const FAKE_GEAR_POSITION_FOR_LANDING_LIGHT_DRAG: f64 = 0.03;
const FAKE_GEAR_POSITION_FOR_LANDING_LIGHT_DRAG: f64 = 0.006;
// Ratio of MSFS gear drag corresponding to RAT deployed
const FAKE_GEAR_POSITION_FOR_RAT_DRAG: f64 = 0.0226;

let gear_deployed = values[0] > 5. || values[1] > 5. || values[2] > 5.;

// Nose msfs gear value is gear position + door drag
let nose_value_after_drag =
(values[3] / 100.) * FAKE_GEAR_POSITION_FOR_DOOR_DRAG + values[0] / 100.;

// Left msfs gear value is gear position + left door drag + left landing light drag
// Left msfs gear value is gear position + left door drag + left landing light drag + RAT drag
let left_value_after_drag = (values[4] / 100.) * FAKE_GEAR_POSITION_FOR_DOOR_DRAG
+ (values[6] / 100.) * FAKE_GEAR_POSITION_FOR_LANDING_LIGHT_DRAG
+ values[8] * FAKE_GEAR_POSITION_FOR_RAT_DRAG
+ values[1] / 100.;

// Right msfs gear value is gear position + right door drag + right landing light drag
Expand Down