From f61e08c1a8918259bb326ac51738aa23d4262ab7 Mon Sep 17 00:00:00 2001 From: Lukas Michels Date: Thu, 4 Apr 2024 17:16:32 +0200 Subject: [PATCH] feat(nws): also add new hack to A380 NWS --- .../src/nose_wheel_steering.rs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/fbw-a380x/src/wasm/systems/a380_systems_wasm/src/nose_wheel_steering.rs b/fbw-a380x/src/wasm/systems/a380_systems_wasm/src/nose_wheel_steering.rs index 3140c8dc2eb0..b96d30ba4788 100644 --- a/fbw-a380x/src/wasm/systems/a380_systems_wasm/src/nose_wheel_steering.rs +++ b/fbw-a380x/src/wasm/systems/a380_systems_wasm/src/nose_wheel_steering.rs @@ -132,16 +132,30 @@ pub(super) fn nose_wheel_steering(builder: &mut MsfsAspectBuilder) -> Result<(), steering_demand_to_msfs_from_steering_angle(nose_wheel_position, rudder_position) }, - Variable::aspect("STEERING_ANGLE"), + Variable::aspect("STEERING_ANGLE_COMMAND"), + ); + + builder.map( + ExecuteOn::PostTick, + Variable::aspect("NOSE_WHEEL_POSITION_RATIO"), + steering_max_demand_to_msfs_from_steering_angle, + Variable::aspect("STEERING_ANGLE_MAX_COMMAND"), ); builder.variable_to_event( - Variable::aspect("STEERING_ANGLE"), + Variable::aspect("STEERING_ANGLE_COMMAND"), VariableToEventMapping::EventData32kPosition, VariableToEventWriteOn::EveryTick, "STEERING_SET", )?; + builder.variable_to_event( + Variable::aspect("STEERING_ANGLE_MAX_COMMAND"), + VariableToEventMapping::EventData32kPosition, + VariableToEventWriteOn::EveryTick, + "NOSE_WHEEL_STEERING_LIMIT_SET", + )?; + // Adds rotational speed to nose wheel based on steering angle const STEERING_RATIO_TO_WHEEL_ANGLE_GAIN: f64 = 80.; builder.map_many( @@ -207,6 +221,16 @@ fn steering_demand_to_msfs_from_steering_angle( (1. - steering_ratio_converted) + (rudder_position - 0.5) } +fn steering_max_demand_to_msfs_from_steering_angle(nose_wheel_position: f64) -> f64 { + const MAX_MSFS_STEERING_ANGLE_DEGREES: f64 = 180.; + + // Steering in msfs is the max we want rescaled to the max in msfs + nose_wheel_position.abs() * MAX_CONTROLLABLE_STEERING_ANGLE_DEGREES + / MAX_MSFS_STEERING_ANGLE_DEGREES + / 2. + + 0.5 +} + fn normalise_angle(angle: f64) -> f64 { let raw = angle % 360.;