Skip to content

Commit

Permalink
feat(nws): also add new hack to A380 NWS
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecologne committed Apr 4, 2024
1 parent f630362 commit f61e08c
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.;

Expand Down

0 comments on commit f61e08c

Please sign in to comment.