Skip to content

Commit

Permalink
feat(flight_model): Add drag from landing lights (flybywiresim#8554)
Browse files Browse the repository at this point in the history
* add landing light drag

* Doc and naming

* typo

* Auto stash before checking out "origin/master"

* Updated drag values

* changelog

* Update cruise.FLT

---------

Co-authored-by: 2hwk <[email protected]>
Co-authored-by: donstim <[email protected]>
  • Loading branch information
3 people authored Apr 9, 2024
1 parent e285e71 commit f9f2818
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
1. [EFB] Added missing localization for SimBridge related settings in SimOptions page - @implasmatbh (Plasma)
1. [FWC] Implement non-cancellable master warning for overspeed and gear not down - @tracernz (Mike)
1. [EFB] Checklist restructure to add more capabilities and use json configs - @frankkopp (Frank Kopp)
1. [FLIGHTMODEL] Landing lights or RAT extended now have drag - @Crocket63 (crocket)

## 0.11.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ A32NX_OVHD_PRESS_MAN_VS_CTL_SWITCH = 1
A32NX_TRANSPONDER_MODE = 1
A32NX_SWITCH_ATC_ALT = 1
A32NX_GEAR_LEVER_POSITION_REQUEST = 0
LIGHTING_LANDING_2 = 2
LIGHTING_LANDING_3 = 2
LIGHTING_LANDING_1 = 2
LANDING_2_Retracted = 1
LANDING_3_Retracted = 1

[Gauges.0]
KollsmanSetting=29.921342849731445313
Expand Down
43 changes: 30 additions & 13 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 @@ -85,25 +87,40 @@ impl VariablesToObject for GearPosition {
Variable::named("GEAR_DOOR_CENTER_POSITION"),
Variable::named("GEAR_DOOR_LEFT_POSITION"),
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 {
const GEAR_POSITION_FOR_FAKE_DOOR_DRAG: f64 = 0.10;
// Ratio of MSFS gear drag corresponding to door drag
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.021;
// Ratio of MSFS gear drag corresponding to RAT deployed
const FAKE_GEAR_POSITION_FOR_RAT_DRAG: f64 = 0.070;

let gear_deployed = values[0] > 5. || values[1] > 5. || values[2] > 5.;
let door_opened = values[3] > 10. || values[4] > 10. || values[5] > 10.;

// If doors are deployed we fake gear going down a bit to get some door drag effect from the sim
if door_opened && !gear_deployed {
self.nose_position = (values[3] / 100.).min(GEAR_POSITION_FOR_FAKE_DOOR_DRAG);
self.left_position = (values[4] / 100.).min(GEAR_POSITION_FOR_FAKE_DOOR_DRAG);
self.right_position = (values[5] / 100.).min(GEAR_POSITION_FOR_FAKE_DOOR_DRAG);
} else {
self.nose_position = values[0] / 100.;
self.left_position = values[1] / 100.;
self.right_position = values[2] / 100.;
}

// 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 + 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
let right_value_after_drag = (values[5] / 100.) * FAKE_GEAR_POSITION_FOR_DOOR_DRAG
+ (values[7] / 100.) * FAKE_GEAR_POSITION_FOR_LANDING_LIGHT_DRAG
+ values[2] / 100.;

self.nose_position = nose_value_after_drag.min(1.).max(0.);
self.left_position = left_value_after_drag.min(1.).max(0.);
self.right_position = right_value_after_drag.min(1.).max(0.);

self.gear_handle_position = if gear_deployed { 1. } else { 0. };

Expand Down

0 comments on commit f9f2818

Please sign in to comment.