Skip to content

Commit

Permalink
fix(a380x): Fix max spoiler deflection in PRIM (flybywiresim#9521)
Browse files Browse the repository at this point in the history
* take max deflection for FACs

* PRIM changes

* changelog

* take spoiler lift into account

* account for spoiler lift by 5 deg

* merge conflicts

* SimConnect bugfix

---------

Co-authored-by: lukecologne <[email protected]>
  • Loading branch information
flogross89 and lukecologne authored Nov 23, 2024
1 parent c4d72f7 commit f484bde
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 102 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
1. [A380X/PFD] Add T/D Reached PFD message - @BravoMike99 (bruno_pt99)
1. [A380X/CAMERA] Showcase & pilot view camera fixes @LunakisDev (LunakisLeaks)
1. [A380X/LIGHTS] Added cockpit ambient bounce lights - @ImenesFBW (Imenes)
1. [A380X/PRIM] Fix max. spoiler deflection based on flap conf - @flogross89 (floridude)
1. [A380X/PERF] Changed managed speeds to more realistic numbers - @slightlyclueles (abnormaltoast)
1. [A380X/MFD] Add ATCCOM connect page - @heclak (heclak)
1. [A380X/PFD] Fix CP VV button turning on VV on both PFDs - @heclak (Heclak)
Expand Down
9 changes: 7 additions & 2 deletions fbw-a380x/src/wasm/fbw_a380/src/FlyByWireInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1797,11 +1797,16 @@ bool FlyByWireInterface::updateFac(double sampleTime, int facIndex) {
facs[facIndex].modelInputs.in.discrete_inputs.yaw_damper_has_hyd_press =
facIndex == 0 ? idHydGreenPressurised->get() : idHydYellowPressurised->get();

double spoilersLeftMaxDeflection =
std::max({idLeftSpoilerPosition[5]->get(), idLeftSpoilerPosition[6]->get(), idLeftSpoilerPosition[7]->get()});
double spoilersRightMaxDeflection =
std::max({idRightSpoilerPosition[5]->get(), idRightSpoilerPosition[6]->get(), idRightSpoilerPosition[7]->get()});

facs[facIndex].modelInputs.in.analog_inputs.yaw_damper_position_deg = 0;
facs[facIndex].modelInputs.in.analog_inputs.rudder_trim_position_deg = idRudderTrimActualPosition->get();
facs[facIndex].modelInputs.in.analog_inputs.rudder_travel_lim_position_deg = rudderTravelLimiterPosition;
facs[facIndex].modelInputs.in.analog_inputs.left_spoiler_pos_deg = -50. * idLeftSpoilerPosition[5]->get();
facs[facIndex].modelInputs.in.analog_inputs.right_spoiler_pos_deg = -50. * idRightSpoilerPosition[5]->get();
facs[facIndex].modelInputs.in.analog_inputs.left_spoiler_pos_deg = -50. * spoilersLeftMaxDeflection;
facs[facIndex].modelInputs.in.analog_inputs.right_spoiler_pos_deg = -50. * spoilersRightMaxDeflection;

facs[facIndex].modelInputs.in.bus_inputs.fac_opp_bus = facsBusOutputs[oppFacIndex];
facs[facIndex].modelInputs.in.bus_inputs.adr_own_bus = facIndex == 0 ? adrBusOutputs[0] : adrBusOutputs[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ bool SimConnectInterface::prepareClientDataDefinitions() {
result &= SimConnect_CreateClientData(hSimConnect, ClientData::PRIM_DISCRETE_OUTPUTS, sizeof(base_prim_discrete_outputs),
SIMCONNECT_CREATE_CLIENT_DATA_FLAG_DEFAULT);
// add data definitions
for (int i = 0; i < 19; i++) {
for (int i = 0; i < 18; i++) {
result &= SimConnect_AddToClientDataDefinition(hSimConnect, ClientData::PRIM_DISCRETE_OUTPUTS, SIMCONNECT_CLIENTDATAOFFSET_AUTO,
SIMCONNECT_CLIENTDATATYPE_INT8);
}
Expand Down
94 changes: 51 additions & 43 deletions fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer.cpp

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class A380PrimComputer final
rtDW_RateLimiter_A380PrimComputer_g_T sf_RateLimiter_lm;
rtDW_RateLimiter_A380PrimComputer_g_T sf_RateLimiter_mn;
rtDW_RateLimiter_A380PrimComputer_g_T sf_RateLimiter_au;
rtDW_RateLimiter_A380PrimComputer_i_T sf_RateLimiter_h;
rtDW_RateLimiter_A380PrimComputer_i_T sf_RateLimiter_mv;
rtDW_RateLimiter_A380PrimComputer_i_T sf_RateLimiter_cp;
rtDW_RateLimiter_A380PrimComputer_d_T sf_RateLimiter_md;
rtDW_RateLimiter_A380PrimComputer_d_T sf_RateLimiter_me;
Expand Down Expand Up @@ -353,12 +355,14 @@ class A380PrimComputer final
real_T RateLimiterGenericVariableTs5_lo;
real_T RateLimiterVariableTs4_lo;
real_T RateLimiterVariableTs6_lo;
real_T RateLimiterGenericVariableTs28_lo;
real_T RateLimiterGenericVariableTs24_lo;
real_T RateLimiterGenericVariableTs25_lo;
real_T RateLimiterGenericVariableTs8_lo;
real_T RateLimiterGenericVariableTs9_lo;
real_T RateLimiterGenericVariableTs10_lo;
real_T RateLimiterGenericVariableTs11_lo;
real_T RateLimiterGenericVariableTs27_lo;
real_T RateLimiterGenericVariableTs14_lo;
real_T RateLimiterGenericVariableTs15_lo;
real_T RateLimiterGenericVariableTs12_lo;
Expand Down Expand Up @@ -401,12 +405,14 @@ class A380PrimComputer final
real_T RateLimiterGenericVariableTs5_up;
real_T RateLimiterVariableTs4_up;
real_T RateLimiterVariableTs6_up;
real_T RateLimiterGenericVariableTs28_up;
real_T RateLimiterGenericVariableTs24_up;
real_T RateLimiterGenericVariableTs25_up;
real_T RateLimiterGenericVariableTs8_up;
real_T RateLimiterGenericVariableTs9_up;
real_T RateLimiterGenericVariableTs10_up;
real_T RateLimiterGenericVariableTs11_up;
real_T RateLimiterGenericVariableTs27_up;
real_T RateLimiterGenericVariableTs14_up;
real_T RateLimiterGenericVariableTs15_up;
real_T RateLimiterGenericVariableTs12_up;
Expand Down Expand Up @@ -583,8 +589,10 @@ class A380PrimComputer final
boolean_T Delay_InitialCondition_o;
boolean_T Logic_table_j[16];
boolean_T Logic_table_n[16];
boolean_T reset_Value_h;
boolean_T reset_Value_f;
boolean_T reset_Value_l;
boolean_T reset_Value_d;
boolean_T reset_Value_a;
boolean_T Constant1_Value_f;
boolean_T Constant_Value_ba;
Expand Down
12 changes: 12 additions & 0 deletions fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ A380PrimComputer::Parameters_A380PrimComputer_T A380PrimComputer::A380PrimComput

-17.0,

-0.03,

-5.0,

-5.0,
Expand All @@ -638,6 +640,8 @@ A380PrimComputer::Parameters_A380PrimComputer_T A380PrimComputer::A380PrimComput

-40.0,

-0.03,

-40.0,

-40.0,
Expand Down Expand Up @@ -722,6 +726,8 @@ A380PrimComputer::Parameters_A380PrimComputer_T A380PrimComputer::A380PrimComput

17.0,

0.03,

5.0,

5.0,
Expand All @@ -734,6 +740,8 @@ A380PrimComputer::Parameters_A380PrimComputer_T A380PrimComputer::A380PrimComput

40.0,

0.03,

40.0,

40.0,
Expand Down Expand Up @@ -3641,6 +3649,10 @@ A380PrimComputer::Parameters_A380PrimComputer_T A380PrimComputer::A380PrimComput

false,

false,

false,

true,

false,
Expand Down
112 changes: 56 additions & 56 deletions fbw-a380x/src/wasm/fbw_a380/src/model/A380PrimComputer_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,49 @@ enum class SignStatusMatrix

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_prim_discrete_inputs_
#define DEFINED_TYPEDEF_FOR_base_prim_discrete_inputs_

struct base_prim_discrete_inputs
{
boolean_T prim_overhead_button_pressed;
boolean_T is_unit_1;
boolean_T is_unit_2;
boolean_T is_unit_3;
boolean_T capt_priority_takeover_pressed;
boolean_T fo_priority_takeover_pressed;
boolean_T ap_1_pushbutton_pressed;
boolean_T ap_2_pushbutton_pressed;
boolean_T fcu_healthy;
boolean_T athr_pushbutton;
boolean_T ir_3_on_capt;
boolean_T ir_3_on_fo;
boolean_T adr_3_on_capt;
boolean_T adr_3_on_fo;
boolean_T rat_deployed;
boolean_T rat_contactor_closed;
boolean_T pitch_trim_up_pressed;
boolean_T pitch_trim_down_pressed;
boolean_T green_low_pressure;
boolean_T yellow_low_pressure;
};

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_prim_pitch_surface_positions_
#define DEFINED_TYPEDEF_FOR_base_prim_pitch_surface_positions_

struct base_prim_pitch_surface_positions
{
real_T left_inboard_elevator_deg;
real_T right_inboard_elevator_deg;
real_T left_outboard_elevator_deg;
real_T right_outboard_elevator_deg;
real_T ths_deg;
};

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_arinc_429_
#define DEFINED_TYPEDEF_FOR_base_arinc_429_

Expand Down Expand Up @@ -76,33 +119,6 @@ struct base_sec_out_bus

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_lgciu_bus_
#define DEFINED_TYPEDEF_FOR_base_lgciu_bus_

struct base_lgciu_bus
{
base_arinc_429 discrete_word_1;
base_arinc_429 discrete_word_2;
base_arinc_429 discrete_word_3;
base_arinc_429 discrete_word_4;
};

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_prim_pitch_surface_positions_
#define DEFINED_TYPEDEF_FOR_base_prim_pitch_surface_positions_

struct base_prim_pitch_surface_positions
{
real_T left_inboard_elevator_deg;
real_T right_inboard_elevator_deg;
real_T left_outboard_elevator_deg;
real_T right_outboard_elevator_deg;
real_T ths_deg;
};

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_prim_out_bus_
#define DEFINED_TYPEDEF_FOR_base_prim_out_bus_

Expand Down Expand Up @@ -166,6 +182,19 @@ struct base_prim_out_bus

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_lgciu_bus_
#define DEFINED_TYPEDEF_FOR_base_lgciu_bus_

struct base_lgciu_bus
{
base_arinc_429 discrete_word_1;
base_arinc_429 discrete_word_2;
base_arinc_429 discrete_word_3;
base_arinc_429 discrete_word_4;
};

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_time_
#define DEFINED_TYPEDEF_FOR_base_time_

Expand All @@ -192,35 +221,6 @@ struct base_sim_data

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_prim_discrete_inputs_
#define DEFINED_TYPEDEF_FOR_base_prim_discrete_inputs_

struct base_prim_discrete_inputs
{
boolean_T prim_overhead_button_pressed;
boolean_T is_unit_1;
boolean_T is_unit_2;
boolean_T is_unit_3;
boolean_T capt_priority_takeover_pressed;
boolean_T fo_priority_takeover_pressed;
boolean_T ap_1_pushbutton_pressed;
boolean_T ap_2_pushbutton_pressed;
boolean_T fcu_healthy;
boolean_T athr_pushbutton;
boolean_T ir_3_on_capt;
boolean_T ir_3_on_fo;
boolean_T adr_3_on_capt;
boolean_T adr_3_on_fo;
boolean_T rat_deployed;
boolean_T rat_contactor_closed;
boolean_T pitch_trim_up_pressed;
boolean_T pitch_trim_down_pressed;
boolean_T green_low_pressure;
boolean_T yellow_low_pressure;
};

#endif

#ifndef DEFINED_TYPEDEF_FOR_base_prim_analog_inputs_
#define DEFINED_TYPEDEF_FOR_base_prim_analog_inputs_

Expand Down

0 comments on commit f484bde

Please sign in to comment.