Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: First hydraulic system implementation #3782

Merged
merged 184 commits into from
May 12, 2021

Conversation

crocket63
Copy link
Contributor

@crocket63 crocket63 commented Mar 2, 2021

This feature request is linked #2840 but not fixed yet by this PR.
This PR is a based on PR #2767, and can replace it

Summary of Changes

Implementation of A320neo's hydraulic system using Rust and WASM.

First thing first, many thanks to:
@davidwalschots for EXTENSIVE support
@wpine215 for launching the first stage of hydraulics (and extensive support)
@CPUBlanc for starting it
@komp1821 and @avteknysian For HUGE support on all kinds of technical details
Everyone helping me getting up to speed on all different subjects in this project

First ever PR for me, and no previous knowledge on various subjects, so be patient I'll improve lot of stuff or someone will :)

Summary
This is a difficult task, and can be done at any level of details. The global target for this is aiming at the extreme limit of every details that can be implemented, without needing overkill performance, or overkill details that would bring nothing to the experience.
Further analysis on the current performance hit of this subsystem will later bring us to upgrade / downgrade details.
You won't see the internal parts of a pump moving, but you should see the landing gear swinging back and forth while retracting using only yellow electric pump and PTU providing pressure to green loop.

Important note
This first PR brings the first brick of hydraulics, and has NO INTENTED impact on FS2020 physics. Meaning actuators are not connected, brakes shows accordingly in pressure gauges but DO NOT control the braking force of the plane. Brake accumulator empty and parking brake shows 0 pressure. But FS2020 would still be applying the brakes. Or if default FS2020 hydraulics are off, plane would not brake while you have actual brake pressure available from accumulator.
Of course everything will get connected later step by step.
Next PRs will focus on documentation and code refactoring if needed (and lot is needed)

Implementation overview
Now the fun part:
This is NOT a simulation of internal pumps parts, plungers, solenoid valves.
This is NOT a simulation of all hydraulic pipes connection solving navier stokes equations on each tube node
This is NOT a faked hydraulic simulation that increments pressures on screen until it reaches 3000 psi and decrement it when pump is off.

Every pump has a dynamic displacement logic. It takes fluid from a reservoir and throw it into its hydraulic loop. The pump regulation is for now "perfect", but can be simulated in real time basically in one line of code: this only depends on performance concerns and can evolve in the future. First implementation (and that was not easy...) tries to model all of this at a low fixed rate of 10Hz, higher rates could enable us to add some more regulation details in the future.

An hydraulic loop will take fluid from any connected pump. Fluid is compressed according to its real life bulk modulus properties (you can chose your fluid if you want :)).
As every part is connected, failures that will come later should impact all the hydraulics and connected systems accordingly without any scripted faked behaviour.

As a lot of parameters are either unknown or an approximation of a real behavior for performances reasons , and as this is a representation of my current system knowledge, a lot of hydraulic performance tuning can AND WILL happen.

Feel free to note any detail that looks weird, it can either be a simple number to change, or everything to rewrite from scratch :)

Building blocks

  • Hydraulic loop implementation
  • Reservoir
  • Accumulator
  • Interaction with pumps
  • Electric pump implementation
  • Engine pump implementation
  • Ram air pump implementation
  • Fire shut off valves
  • Internal static leaks
  • Leak measurement valve (Targeted on later PR)
  • Pressure relief valve (Targeted on later PR)
  • Priority valve (Targeted on later PR)
  • Basic failures (Targeted on later PR)
  • Check valves with separate loop sections (Targeted on later PR)

LOGIC

  • Basic auto EDPumps
  • Blue auto Epump
  • PTU inhibit logic
  • Brakes main/alternate logic
  • Rat deployment (Based on engine master off, next PR for ELEC interactions)
  • Cargo door uses Yellow pump from external panel
  • Blue Elec generator (Targeted on later PR shared with ELEC)
  • Logic based on electrical state (Targeted on later PR)

PTU

  • PTU basic model
  • PTU physical based model (Targeted on later PR if base model does not reach targeted details)

Actuators

  • Full actuator implementation (Targeted on later PR)
  • Rat deployment and propeller basic aerodynamic model
  • All flight control actuators (Targeted on later PR)
  • Landing gear actuators (Targeted on later PR, only tested as proof of concept)
  • Cargo door actuators (Targeted on later PR)
  • Electric pump connections to AC busses (Targeted on later PR)
  • Blue hydraulic system connection to emergency generator (Targeted on later PR)
  • Bleed air connection to reservoir to prevent cavitation (Targeted on later PR)
  • Each flight computer implementation commands from FBW to relevant actuator (Targeted on later PR)

Brakes

  • Green braking system model
  • Yellow alternate braking system model
  • Yellow accumulator
  • Brakes actually connected to hydraulic circuits
  • Braking circuit static leaks (parking brake lost after 12h standing)
  • Antiskid (Targeted on later PR,some proto code already implemented)
  • Auto brakes (Targeted on later PR,some proto code already implemented)

Overhead

  • ENG 1 PUMP ON/OFF
  • ENG 1 PUMP FAIL
  • ENG 2 PUMP ON/OFF
  • ENG 2 PUMP FAIL
  • RAT MAN ON (guarded)
  • BLUE ELEC PUMP (guarded)
  • BLUE ELEC PUMP FAIL
  • PTU
  • PTU FAIL (Targeted on later PR)
  • YELLOW ELEC PUMP
  • YELLOW ELEC PUMP FAIL
  • BLUE PUMP OVRD (guarded)
  • G LEAK MEASUREMENT VALVE (guarded) (Targeted on later PR)
  • B LEAK MEASUREMENT VALVE (guarded) (Targeted on later PR)
  • Y LEAK MEASUREMENT VALVE (guarded) (Targeted on later PR)

Temperature

  • Temperature impacts fluid properties (Targeted on later PR)
  • Each block produces heat (Targeted on later PR)
  • Heat causes damages and failures (Targeted on later PR)
  • Brakes heat impacts the fluid (Targeted on later PR)

DOCUMENTATION

  • Sources of technical data added in the project (Targeted on later PR)
  • Documentation about every implemented model so it can be tuned/replaced by anyone (Targeted on later PR)
  • Add all new SIMVARS in relevant doc file
  • Some unit test need rewrite

HYD ECAM SD Page
-In progress in #3833

Known issues
PTU model is currently simplified and has some impacts like slow yellow brake accumulator recharge on elec pump, or too much impact on yellow pressure when powering green side on epump only
Time acceleration might cause high CPU usage due to hydraulics trying to update at a fixed rate

Screenshots (if necessary)

References

Additional context

Discord username : Just yell prayers in Hydraulic room

Testing instructions

This first implementation has NO IMPACT on the plane, apart from triple pressure gauge visuals.
ECAM will come just after in a next PR, so please rely on available local vars to report issues:
Use (developer mode/model behaviors/local vars) then filter those variables using "A32NX_HYD" filter.

ECAM HYD screen is available if you test using #4777. Please keep reporting results here and rely on variables only for final issue observations.

Special note: Plane is spawned with yellow brake accumulator half filled. This explains yellow level to be over max until first yellow pressurisation that will fill alternate brake accumulator accordingly.

Testing will focus on:
Specific:

  1. Basic logic is respected on the triple pressure gauge (https://www.youtube.com/watch?v=J31OyM78nOk&t=2s)
  2. PTU inhibited accordingly by pushback tug and cargo door used by ground crew (not by push button ON as shown here https://user-images.githubusercontent.com/38904654/110203279-961dc300-7e6d-11eb-9ae9-230fc4844203.png)
  3. Yellow epump activates when cargo door operated by ground crew, then stops after a delay.

General:

  1. Making sure nothing crashes the sim
  2. No stupid pressure numbers appears
  3. Reservoirs do not lose fluid after a long time and have expected levels
  4. Performance impact is neglictable
  5. Make sure the fixed step mechanism does not cause stutters: hydraulics will not update on every sim frame if sim is running ultra smooth.
  6. Robustness to starting position : cold/runway/in air
  7. Robustness to time acceleration

How to download the PR for QA

Every new commit to this PR will cause a new A32NX artifact to be created and uploaded.
The build script will have already been run with the latest changes, so no need to rerun it once you download the zip.

  1. Make sure you are signed in to GitHub
  2. Click on the Checks tab on the PR
  3. On the right side, click on the Artifacts drop down and click the A32NX link

@crocket63 crocket63 changed the title FEAT: First hydraulic system implementation feat: First hydraulic system implementation Mar 2, 2021
@crocket63 crocket63 force-pushed the hydraulics_updated branch from 96fcff1 to ebff2c1 Compare March 3, 2021 08:47
@beheh beheh marked this pull request as ready for review March 5, 2021 19:19
@beheh beheh marked this pull request as draft March 5, 2021 19:19
@wpine215
Copy link
Member

wpine215 commented Mar 6, 2021

Someone with experience working on the real plane can probably provide better feedback than me, but my initial observation is that it seems that the PTU on/off cycle is too slow, especially for yellow to green power transfer (based off the timing of the "barks" seen in reference videos). Also, on the ground (before taxi) the PTU should be inhibited when only one engine is running, or if the parking brake is set - it seemed like the first condition wasn't modeled when I tested it out.

Otherwise, great work so far!

@Benjozork Benjozork added this to the v0.6.0 milestone Mar 6, 2021
@crocket63
Copy link
Contributor Author

Someone with experience working on the real plane can probably provide better feedback than me, but my initial observation is that it seems that the PTU on/off cycle is too slow, especially for yellow to green power transfer (based off the timing of the "barks" seen in reference videos). Also, on the ground (before taxi) the PTU should be inhibited when only one engine is running, or if the parking brake is set - it seemed like the first condition wasn't modeled when I tested it out.

Otherwise, great work so far!

So for PTU I tuned it so it's not too fast using only yellow electric pump, as you should have almost continuous PTU active state from some feedback we already get. Do you mention a case using yellow EDP there not electric? I can easily tune that behavior but it's sadly a balance between electric pump slow behaviour and EDP fast behaviour :p
Important note for PTU: keep in mind I don't have for now ANY hydraulic consumers but static leaks, and that will definitely increase flow usage and thus PTU frequency.

For the logic it should be completely 100% as real life. What was your test case exactly?
This is what is "intented" to be implemented:
image
If you have only one engine active, but braking prake is off (one engine taxi case) PTU should indeed work.

Copy link
Contributor

@Kimbyeoungjang Kimbyeoungjang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just simple fix for you.
if fix this, lint error will disappear :)

@RichardPilbery
Copy link
Contributor

ECAM SD page: #3833

Copy link
Member

@davidwalschots davidwalschots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall we're nearly there. Few small things to think about and after that it's approval time. I really look forward to seeing all of this in action in the sim. Cool stuff! 🥳

I have some remarks to smoothen future PRs a bit:

  • Read through the Rust style guide. It's a good resource. Something us non-Rust developers aren't used to is how getters are written: without a get_ prefix.
  • Read through Visibility and Privacy in the Rust reference. Another language thing we're not used to: everything is public within the module by default. I've removed quite a few pub usages, and sometimes replaced them with pub(super) or pub(crate).
  • Try to design the software structure such that it's a DAG as much as possible. I can understand that given that it's the first time you've used the language (as have I) it's sometimes a bit of a struggle. I for sure have struggled with it at times! Still, this is a key thing.
  • Try to apply the Law of Demeter as much as you can, at least outside of tests. By also applying it within tests, you'll get a better feel for the "interface" you're exposing. In summary: try to avoid self.field.fields_field.do_something(), but instead write: self.field.do_something() and let that function handle how to do it.
  • Understand that the topic at hand is complicated. You've by now researched a lot of hydraulics and thus are fully understanding most of it. However, for someone new to the topic the code will be challenging. The better the naming and abstractions, the easier it is for someone other than yourself to continue improving on top of your work. Keep challenging yourself in this area! 😀
  • One particular area that I think is interesting to think about in terms of abstraction is the code around time stepping in A320Hydraulic.update. In a way the function goes from high level abstractions to low level abstractions and back again. It might be worthwhile to extract the way of time stepping out into a separate type at some point. Something to think about.
  • The default SimulationElement.accept implementation already visits the element itself. Thus if that's all you want to do, you don't have to implement that function again. I've removed a few usages like this.
  • Format comments according to the style guide: // A comment. Prefer to write the comment above instead of next to the code.
  • Write out words as much as possible. ena => enable(d), dmnd => demand, cmnd => command, hyd => hydraulic, etc.

src/systems/systems/src/hydraulic/mod.rs Show resolved Hide resolved
src/systems/systems/src/hydraulic/brake_circuit.rs Outdated Show resolved Hide resolved
src/systems/a320_systems/src/hydraulic.rs Outdated Show resolved Hide resolved
src/systems/a320_systems/src/hydraulic.rs Outdated Show resolved Hide resolved
@crocket63
Copy link
Contributor Author

Overall we're nearly there. Few small things to think about and after that it's approval time. I really look forward to seeing all of this in action in the sim. Cool stuff! 🥳

Thanks a lot for the help! Lot of stuff yet to improve I know :p

@crocket63
Copy link
Contributor Author

crocket63 commented May 8, 2021

ECAM hyd available here #4777

@Kimbyeoungjang
Copy link
Contributor

Kimbyeoungjang commented May 9, 2021

Category: Contributor
Name: 김병장#7165 ( Kimbyeongjang )
Date of testing: 2021 / 05 / 09
Version of the sim: 1.15.8.0
PR Tested: #3782
Tier of testing: QA Tier 2
Changes to observe: First hydraulic system implementation

Testing technique: Perform Full Flight

Origin : RKSI RW15R ( depart direct to MONSI )

Legs
MONSI - BULTI - MEKIL - GONAX - BEDES - ELPOS - MANGI - DALSU - DOTOL - KIDOS

Destination : RKPC RW25 ( arrival direct to RKPC, ILS RW25 )

Steps you've made to test the Pull Request:

  1. Spawn on gate - check C&D hydraulic gauge via developer mode
  2. On gate, power up - check ELEC Hydraulic to use Brake
  3. Engine Start - Check Yellow / Green / Blue / ELEC Pumps (Turn on & off and check hydraulics), and check FIRE PB is working
  4. Takeoff - Test as number 3.
  5. Perform full flight with normal condition

Media:

C&D:
image

there is only brake hydraulics ( others value : 14.7 )
if parking brake on & off and use brake, brake hydraulics loss some pressure.

GPU Connected :
image

Only ELEC Pump on, PTU working well, pressure is stable.

brake gauge also working well

idk IRL reference but in sim,
Max value : Yellow reach 3000 / Green reach 2850
normal value : Yellow 2800 ~ 3000 / Green 2500 ~ 2850

image
PTU off, Green loss pressure, Yellow maintain 3000

image

Brake gauge also working well

turn off all hydraulic & repeat engage parking brake on / off.

Engine Start :
image

Hydraulics from Engine Driven Pump is alive.

Takeoff and do some test:

image

Check Green / Blue / Yellow pump is alive ( Turn on / off to test value )

all working well.

image
Check Hydraulics when use Fire PB

image

Working well ( I Turn off PUT to test Green is dead )

and approach / landing. normally done

Issues (If Any): there is no issue about hydraulics.

As a description on PR, Hydraulics alive but not applied on physics ( F/CTL, actual brake )

Overall Rating: Good

Conclusions of the testing: Thank you for make this awesome feature! Every value working as well :D

@BritishAvgeek
Copy link

Category: QA Tester
Name: BritishAvgeek#1436
Date of testing: 12/05/2021
Version of the sim: 1.15.8.0
PR Tested: #3782
Tier of testing: 2
Changes to observe: First implementation of hydraulic systems into the A32NX

Testing technique: Full Flight from EGLL to EGCC for testing - offline and not streamed

Steps you've made to test the Pull Request:

  1. Spawned Cold and Dark at EGLL and configured for a flight to Manchester EGCC using Simbrief. Completed all necessary steps in the MCDU
  2. Whilst on stand, turned various hydraulic combinations off and monitored the reaction in the three gauges. Triggered the turnaround so the cargo door would be opened - PTU was inhibited as described, yellow pump activated and stopped a short while after. Checked this again with pushback tug connected
  3. No issues at this stage, pushed back and started - during taxi, braked in various ways and applied park brake. I watched the video mentioned above in the testing instructions and tried to replicate that behaviour also
  4. During flight, switched one hydraulic system off and checked the gauges at a time - no adverse affects
  5. Landed

Flight notes (When done a full flight):

Media: N/A

Issues (If Any): None found during this test

Overall Rating: Good
Conclusions of the testing: Hopefully we get some additional QA Tests over the coming days. Thanks for your work - I had no issues during this, look forward to the future PRs too

@tareksabet
Copy link
Contributor

tareksabet commented May 12, 2021

Changes to observe:

First hydraulics system implementation

Testing technique: Tryout

Steps you've made to test the Pull Request:

1. Spawned at HECA in C&D

2. Turned On the Yellow system from the electric pump with with PTU off

3. Turned On the Yellow system from the electric pump with with PTU On then yellow suppling the green system

4. Started Engine 1 with PTU off

5. Started Engine 1 with PTU ON

6. Took off then turned off both engines to simulate both Engines failure and HYD G+Y failure

7. Checked the RAT deployed and suppling the Blue HYD sys

8. Spawned again took off, did a circuit then landed

9. Tried the cargo door operations and checked the values

10. Turned off the engines, turned off Anti Skid and tried to empty the brakes ACCU

Flight notes (When done a full flight):

Did a quick circuit over the airport and checked different parameters

Media:

  • Image 1: Triple gauge with ACCU empty
    Microsoft Flight Simulator Screenshot 2021 05 08 - 02 18 07 04
Microsoft_Flight_Simulator_2021.05.08_-_03.20.36.02-1.mp4
  • Image 2: Yellow system supplied by the ELEC Pump with PTU off

Microsoft Flight Simulator Screenshot 2021 05 12 - 12 54 13 05

  • Image 3: Yellow system supplied by the ELEC Pump with PTU ON

Microsoft Flight Simulator Screenshot 2021 05 12 - 12 54 39 80

  • Image 4: Engine 1 On with PTU Off

Microsoft Flight Simulator Screenshot 2021 05 12 - 12 59 05 53

  • Image 5: Engine 1 On with PTU ON

Microsoft Flight Simulator Screenshot 2021 05 12 - 13 08 48 60

  • Image 6: Engine 1 and 2 On with Yellow Elec Pump On

Microsoft Flight Simulator Screenshot 2021 05 12 - 13 04 15 12

  • Image 7: Flying with Both Engines OFF to simulate Both Engines failure

Microsoft Flight Simulator Screenshot 2021 05 12 - 13 40 17 68

  • Image 8: exterior view with the Landing gear lever down but landing gears not down

Microsoft Flight Simulator Screenshot 2021 05 12 - 13 42 46 89

Fun part

Tried my best to survive with both engines failure

Microsoft Flight Simulator Screenshot 2021 05 12 - 13 43 27 71

Overall Rating: Good

Conclusions of the testing:

I had lots of fun testing this Pr and I was with Shomas to have another set of eyes while testing your Pr. Tested all the stuff you implemented and all of them are working fine and as intended. Thanks for your amazing work on this system as it's not a simple system, hopefully seeing the rest of the stuff implemented. Good job ! 👏

@davidwalschots davidwalschots merged commit 015286a into flybywiresim:master May 12, 2021
m10ust pushed a commit to m10ust/a32nx that referenced this pull request May 21, 2021
Co-authored-by: davydecorps <38904654+davydecorps@users.noreply.github.com>
Co-authored-by: Will Pine <wpine215@gmail.com>
Co-authored-by: David Walschots <davidwalschots@users.noreply.github.com>
Co-authored-by: komp1821 <71044068+komp1821@users.noreply.github.com>
@crocket63 crocket63 deleted the hydraulics_updated branch July 4, 2021 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.