Skip to content

Commit

Permalink
feat(nws): add better NWS hacks (#8606)
Browse files Browse the repository at this point in the history
* feat(nws): enable turning of NWS when standing still

* feat(nws): limit max NWS angle to remove jitter when using rudder

* feat(nws): also add new hack to A380 NWS
  • Loading branch information
lukecologne authored Apr 7, 2024
1 parent 3b8235a commit 7b7e42b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ tailwheel_lock = 0 ; Is tailwheel lock available TRUE/FALSE
max_number_of_points = 9 ; Number of contact points
gear_locked_on_ground = 0 ; Defines whether or not the landing gear handle is locked to down when the plane is on the ground.
gear_locked_above_speed = -1 ; Defines the speed at which the landing gear handle becomes locked in the up position. (-1 = Disabled)==> Disabled is kept in favor of an XML-based solution
allow_stopped_steering = 1 ; This can be used to enable (TRUE, 1) steering when the aircraft is stopped or not (FALSE, 0).
max_speed_full_steering = 300 ; Defines the speed under which the full angle of steering is available (in feet/second).==> 20 kts or 33.7 ft/sec (was 8)
max_speed_decreasing_steering = 350 ; Defines the speed above which the angle of steering stops decreasing (in feet/second). ==> 40 kts or 67.5 ft/sec (was 50)
min_available_steering_angle_pct = 0.0 ; Defines the percentage of steering which will always be available even above max_speed_decreasing_steering (in percent over 100) ===> 6 degrees or 0.08% of 75 degrees max deflection (was 0.2 or 15 degrees)
Expand Down
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",
)?;

Ok(())
}

Expand Down Expand Up @@ -181,3 +195,13 @@ fn steering_demand_to_msfs_from_steering_angle(
// This way we end up with actual angle we required
(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
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ tailwheel_lock = 0 ; Is tailwheel lock available TRUE/FALSE
max_number_of_points = 11 ; Number of contact points
gear_locked_on_ground = 0 ; Defines whether or not the landing gear handle is locked to down when the plane is on the ground.
gear_locked_above_speed = -1 ; Defines the speed at which the landing gear handle becomes locked in the up position. (-1 = Disabled)==> Disabled is kept in favor of an XML-based solution
allow_stopped_steering = 1 ; This can be used to enable (TRUE, 1) steering when the aircraft is stopped or not (FALSE, 0).
max_speed_full_steering = 300 ; Defines the speed under which the full angle of steering is available (in feet/second).==> 20 kts or 33.7 ft/sec (was 8)
max_speed_decreasing_steering = 350 ; Defines the speed above which the angle of steering stops decreasing (in feet/second). ==> 40 kts or 67.5 ft/sec (was 50)
min_available_steering_angle_pct = 0.0 ; Defines the percentage of steering which will always be available even above max_speed_decreasing_steering (in percent over 100) ===> 6 degrees or 0.08% of 75 degrees max deflection (was 0.2 or 15 degrees)
Expand Down
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 7b7e42b

Please sign in to comment.