Profile image

Realistic Landing Gear operation with smooth function (Beta)

9,275 vcharng  10 months ago

So, asteroidbook345 was asking about a landing gear system that operates like real airliners, with correctly sequenced landing gear and gear door operation.
Let's start with an example.

(please disregard the landing gear on the far side, it's using a different setting.)

Now, time for math.
Let's start with "smooth function"
What is smooth function?
Smooth function means the output will follow the input at a set speed.
If your input changes from 0 to 1 instantly, and have smooth(input, 1), it will take one second for the output of the smooth function to actually go from 0 to 1, although input has been 1 the first instance.
in 1.9.202, landing gear input is 1 when gear down, -1 when gear up.
Without smooth function, the LG input will jump from 1 to -1 instantaneously, disallowing us to make any sequential programming.
However, with smooth function, we can make LG output something that "smoothly" changes from 1 to -1 in a duration. With that, we can set a series of mechanisms to be triggered with different value of Smooth(LG), thereby giving us a sequential landing gear operation.

Check this: (I am more used for -1 = down, 1 = up, so I will use "-LandingGear" for funky tree inputs for the rest of this tutorial)
Landing Gear Value for plain LG input:
-1>1
(all mechanisms triggered at the same time, no sequence)

Landing Gear Value for smooth function: (Smooth(- LandingGear, 0.25))
-1>>(2 sec)>>-0.5>>(2 sec)>>0>>(2 sec)>>0.5>>(2 sec)>>1
(Landing Gear retracting)>>>>>>>>(Gear Bay Door Closing)

This is the basic principle we can use.
For this example, all bay doors are left open when the gear is down. This will be referred to as "WWII style" operation hereon.

(all gear/door actuators in this tutorial use 1 input for "up/closed" position and 0 for "down/open" position)

For this example, the inputs are like these:
Landing Gear Actuator:
clamp01(smooth(- LandingGear, 0.25) + 1)
Gear Door Actuator:
clamp01(smooth(- LandingGear, 0.25))

The clamp function effectively disables all the function changes beyond 0 and 1, so for the landing gear, the movement started when smooth function reaches -1 (which is, immediately after "Gear Up" command), and ends its movement when the function reaches 0 (i.e. 4 seconds after the command). There are additional 4 seconds of smooth function input, but they are disabled by the clamp function.

On the other hand, for the gear doors, it starts moving when the smooth function reaches 0 (i.e. 4 seconds after command; right after gear fully retracted), and stops moving when the function reaches 1 (i.e. the finish point). The smooth function started changing right after the gear up command, but the first 4 seconds are disabled by the clamp function.

And that's what the result looks like:

Landing Gear retracts for the first 4 seconds, then the last 4 seconds are for landing gear closing.

Now, I can hear some people yelling "but this is not what we saw at the beginning!"
Yeah, right, we have to start with something simple, right?

Now, for modern airliner-ish landing gear doors (hereafter referred to as "modern type"), the sequence is more complicated.
Modern airliners have two sets of bay doors, the smaller one ("auxiliary bay door") will remain open when the gear is down to allow the gear to protrude the gear bay, while the bigger one ("main bay door") will only open when the gear is in transition to allow passage.
So, the sequence for a modern type landing gear will be like this:
-1>>>>>>-0.5>>>>>>0>>>>>>0.5>>>>>>1
main open>>gear retraction>>>main and aux door close
Which means we need three different inputs, gear, main door, and auxiliary door.

Their funky tree input are as follows:
Landing Gear Actuator:
clamp01(smooth(- LandingGear, 0.25) + 0.5)
Main Door Actuator:
clamp01(2 * abs(smooth(- LandingGear, 0.25)) - 1)
Auxiliary Door Actuator:
clamp01(2 * smooth(- LandingGear, 0.25) - 1)

For the gear actuator, instead of being triggered between smooth function -1 and 1, it is now being triggered between -0.5 and 0.5, to empty up space for both 0.5~1 ranges for door operation.

For the Main door, since its behaviour is symmetric on either side of zero input, I used an absolute function to make its output symmetric. It will be triggered when the smooth function is between absolute value of 0.5 to 1. The 2x multiplier at the front means it has to open/close twice as fast, since unlike the WWII style, in modern style operation you only have 0.5 input range for gear doors.

For the Auxiliary door it is almost the same as the main door, except that it does NOT close when the smooth input is on the minus (gear down) side. It will wait until the gear is fully retracted, and use the last 0.5 input range to close the doors.

This aircraft has been uploaded for reference
Link to the Ju-288G-2 Landing Gear demonstrator

  • Log in to leave a comment
  • Profile image
    1,307 Macrophage

    @vcharng Gosh I almost died reading this (You know it's hyperbole) And yes, it helps a lot!!! Now I can make my beluga better! But I think I need a tutorial of how to make heavy plane with small wings fly...

    16 days ago
  • Profile image
    2,518 Darkhound

    thanks for the codes man, even tho i used these for an openable hollow nose cone housing radar systems. @vcharng

    3 months ago
  • Profile image
    6,041 Meowsers

    @vcharng oh okay

    8 months ago
  • Profile image
    9,275 vcharng

    @WingworksDesignCo Please refer to the later 1.9.203 version

    8 months ago
  • Profile image
    6,041 Meowsers

    @vcharng The Auxiliary door doesn't close for some reason. Is it something that can be fixed?

    +1 8 months ago
  • Profile image

    I used a similar function derived from this for my next build, so this was really helpful. Thanks! @asteroidbook345

    +1 10 months ago
  • Profile image
    9,275 vcharng

    @asteroidbook345 Yo, a new version is up, I tagged you.

    10 months ago
  • Profile image
    9,275 vcharng

    @asteroidbook345 I know.
    I'm also investigating possibilities to enhance the function of these landing gears, so the update will come with the upgrade.

    10 months ago
  • Profile image
    12.4k SovietBun

    Thanks a lot

    10 months ago
  • Profile image
    98.8k Wallaby

    @asteroidbook345 ah thats true

    10 months ago
  • Profile image
    98.8k Wallaby

    @asteroidbook345 Beta never wipes my data

    +1 10 months ago
  • Profile image
    98.8k Wallaby

    I managed to tweak the code to set the delay and speed of the rotators as I wanted them after a few hours of frustration. Thanks for this code.

    10 months ago
  • Profile image
    9,275 vcharng

    @asteroidbook345 go set properties on steam to "public test" and you'll get 1.9.202 beta.

    10 months ago
  • Profile image
    98.8k Wallaby

    These functions are so confusing but I'm starting to understand them slightly

    +1 10 months ago
  • Profile image
    98.8k Wallaby

    I figured out how to make my landing gear rotate faster, but it comes at the cost of also changing the sequential delay.

    10 months ago
  • Profile image
    98.8k Wallaby

    Currently manipulating this input to match my landing gear, thanks a lot.

    10 months ago
  • Profile image
    98.8k Wallaby

    I was hoping for this

    10 months ago
  • Profile image
    31.0k CRJ900Pilot

    This is awesome! It would certainly help with my overly complicated landing gear

    +2 10 months ago
  • Profile image

    This is amazing

    10 months ago
  • Profile image
    9,275 vcharng

    @asteroidbook345

    10 months ago