Profile image

This is some Maddening code right here... Because of how simple it bloody is.

8,667 RestlessGalaxies  one month ago

Has anyone made an AoA limiter And G limiter that increases sensitivity depending on speed, reliably keeping the G's Under a certain target value at almost all speed?

And that, without a PID, I mean.


So a code that someone who isn't well acquainted with PID inputs can use...
Proud to say that me and Tom worked something out for everyone here... and since it's so simple, a similar code might even work in Simple planes 2, so yeah, this code might actually help out a lot of people... I do request you read everything below carefully, though.


For the Pitch input, I took this as a variable that I lovingly called "PitchyWitchy" (Call the variable whatever you want)

 GS [Lesser than sign] 277.165 ? AoA1 + smooth(Pitch/1.66,10) - PitchRate/500 : smooth(Pitch*4,2)/Geez + AoA1 - smooth(PitchRate/GSMultiplier,1.3)     

As you can see, there are 3 variables in the code above... AoA1, Geez and GSMultiplier.


The input in AoA1 Is this:

 AngleOfSlip [ Lesser than sign ] 90 ? clamp(-AngleOfAttack/19,-3,3) : -1*clamp(-AngleOfAttack/19,-3,3)  

It takes the normal AngleOfAttack values, as you'd expect it to work..clamps it, then checks for whether the plane is flying in reverse... so like Guyfolk did it. If the craft is in reverse, then it inverts the limiters input... therefore accounting for reverse airflow.


Then Geez is well... The GForce input. Self Explanatory TBH. Just copy the code below in the Variable input.

 smooth(clamp(GForce*GS/200,0.5,6),3.5)     

Yes, it is Ground speed relative as well. Always a bonus.


GSMultiplier is... well it's a bit of monstrousity to look at with first impressions but it gets exponentially simplified when you realise how extremely simple it is.


 clamp(1/(GS/12877),20,45)

basically, I found that at 600Mph, PitchRate/45 worked well, but as the craft slowly accelerated... there were issues were pitchRate/45 just wasnt enough limiting...
So what this code above does is a reliably return outputs that starts at 45 during 600mph, and then gradually lowers as speed increases...
Until it hits a minimum of 20, which is kind of like a hard limit before the values become too sensitive for simple planes to reliably simulate.



https://www.simpleplanes.com/a/F9pMP1/QUECHALS-GHOST
This is the demonstrator for the code in action. It works on pretty much all physics settings as well since we aren't doing complex calculus or PID, it just works. I have been lenient with how much it limits, so under 600mph, it still does cross well over 13G's if you Really push it, but it likely tones it down quickly and keeps a nice 12G's sustained.... And yes, this thing IS relaxed stability and the code above would likely work pretty well for TVC and PSM planes!

If you do wish to use it, no credit required... just tag me on the build because I really wanna see what people come up with using this, since I've not seen anyone else take it to this extent before.

I highly suggest you combine these codes for the normal aero surfaces on your plane, then add some code fromt he basic Thrust vectoring Guyfolk did a tutorial on. You should hopefully get a plane that is extremely realistic in it's flight model, fun to fly AND doesn't have a complex PID input system along with many wasted hours of testing and fine tuning.


If you Do not want the thing to pull as many G's, All you have to do is play around a little with the GSMultiplier values (The higher the GS Multiplier returns, the more Sensitive your limiter is) and for the under 600mph regime, just play around with the pitch divider. I suggest anywhere between Pitch/2.5 and Pitch/1.3


This permanently changes how simple planes builds will be in the future... The only case where this might become redundant is in simple planes 2, where they may introduce integrated Fly by wire system where you only have to use sliders. Even then, this code will hold up for SP 1 builds. I'm 4 years late to the party of Funky trees pros, but I've gotten there. This system is a code literally anyone can just basically pick up and use... It does needs some fine tuning hopping from build to build, but it works... and works consistently well on all physics settings, at that... So yes.

You absolutely do not need to credit me if you use this. Spread it around a little make it a default until SP 2 for all relaxed stability or... really just any design that inherently pulls too many G's. I only ask that you tag me because I really want to see all the creativity flow out now with having a system that skips you the pain of engineering a working FBW!

Here are all the codes with corresponding variable for you to copy paste (copy everything but the curly brackets.

For Variable {{ PitchyWitchy }} : {{ GS < 277.165 ? AoA1 + smooth(Pitch/1.66,10) - PitchRate/500 : smooth(Pitch*4,2)/Geez + AoA1 - smooth(PitchRate/GSMultiplier,1.3) }}

For Variable {{ AoA1 }} : {{ GS>1? (AngleOfSlip < 90 ? clamp(-AngleOfAttack/23,-3,3) : -1*clamp(-AngleOfAttack/22,-3,3)) : 0 }}

For Variable {{ Geez }} : {{ smooth(clamp(GForce*GS/200,0.5,6),3.5) }}

For Variable {{ GSMultiplier }} : {{ clamp(1/(GS/12877),20,45) }}

ENJOY!

  • Log in to leave a comment
  • Profile image

    I should also tell that @ThomasRoderick Had a big hand in this. The Idea to have it get more limiting as speed increased was his. He did try to code it in, but he went for something that would work with real life variables, not simpleplanes. I just managed to make something that works suprisingly well with the idea. I've been trying to make it work like that, where it increases limiting factor so that the amoung of g's pulled is constantly below a hard limit throughout the flight for years now, But I didn't have that breakthrough point until Tom tried an equation, which made my mind work.

    Pinned one month ago
  • Profile image

    @overlord5453 hey, any updates?

    one month ago
  • Profile image

    @Rb2h the issue is that wobble happens even with PID limiters. Crazy stuff, Simpleplanes.

    +1 one month ago
  • Profile image
    9,156 Rb2h

    @GalaxiesDontSlleep gosh the wobble is bad
    I've reduced it a lot with some edits to the code but it still completely stops the turning speed at high speeds for a moment

    one month ago
  • Profile image

    @Rb2h bruh.
    XD
    Sorry for the lack of clarity then. You were supposed to replace. My bad on that, but glad to know it's working! Let me know if it gets wobbly past 1300mph. Ive been working on improving it and noticed that was a redundancy too, the wobble.

    +1 one month ago
  • Profile image
    9,156 Rb2h

    @GalaxiesDontSlleep got it working
    Just had to delete the old code for AoA1

    one month ago
  • Profile image

    @Rb2h weird, because it's working for me. Hold on, ill send mine to you

    +1 one month ago
  • Profile image
    9,156 Rb2h
    one month ago
  • Profile image

    @Rb2h GS>1? (AngleOfSlip < 90 ? clamp(-AngleOfAttack/25,-3,3) : -1*clamp(-AngleOfAttack/25,-3,3)) : 0
    Try this then? The brackets should help isolate the codes.

    +1 one month ago
  • Profile image
    9,156 Rb2h

    @GalaxiesDontSlleep when the game says no
    Might just be stupid

    +1 one month ago
  • Profile image
    9,156 Rb2h

    @GalaxiesDontSlleep Koltobanian

    +1 one month ago
  • Profile image

    @Rb2h use the actual "<" instead of "lesser than sign"?
    I edited the previous comment as well.
    Also, Novaran fighter?

    +1 one month ago
  • Profile image
    9,156 Rb2h

    @GalaxiesDontSlleep can't do an Unlisted bc it's linked to a challenge and doing that will bypass the autocredit

    one month ago
  • Profile image
    9,156 Rb2h

    @GalaxiesDontSlleep ???

    +1 one month ago
  • Profile image

    @Rb2h landed and stopped right? Just add a condition so that it only activates above a certain GS. Or... Give me an unlisted link or I do it for you. Thanks for letting me know btw. I'll be putting up some updates mid December or so after I post the Ghost of Quechal (The demonstrator for this code)


    But basically, go to AoA1, then do...
    {{ GS>3 ? AngleOfSlip < 90 ? clamp(-AngleOfAttack/19,-3,3) : -1*clamp(-AngleOfAttack/19,-3,3) : 0 }}

    +1 one month ago
  • Profile image
    9,156 Rb2h

    Put this on my jet
    Works well
    But the elevator likes to go crazy when landed

    +1 one month ago
  • Profile image

    @Rb2h Which one? The condition for if above a certain speed then change programme is in "PitchyWitchy", where the condition asks if GS<(Insert value here) ?
    The value to be inserted must be in M/s

    +1 one month ago
  • Profile image
    9,156 Rb2h

    How do you edit the speed regime of the limiter

    +1 one month ago
  • Profile image

    @overlord5453 Yes. AoA and G's.

    +1 one month ago
  • Profile image
    13.7k overlord5453

    @GalaxiesDontSlleep ohh. Thanks again.

    +1 one month ago
  • Profile image
    13.7k overlord5453

    Hang on, is this a two in one code? Limiting AOA and G's at the same time?
    You mad man

    +1 one month ago
  • Profile image

    @overlord5453 Having spent 4 Years banging my head on the wall that is relaxed stability did actually help me become someone who knows a thing or two about it. Again, let me know if you ever need some help!


    Just saw the edit, may wanna increase the pitch divider for under 600mph

    +1 one month ago
  • Profile image
    13.7k overlord5453

    @GalaxiesDontSlleep it's not behind but right on each other. But thanks for the advice. I need it. I did get it to work at higher speeds. The problem occurs at lower speeds. Requires more fine tuning.

    +1 one month ago
  • Profile image

    @Grob0s0VBRa Np. I made an addendum at the very bottom so that people can just directly copy and paste if they must.
    Bonus toward you because this looks better thank Red markups.

    one month ago
  • Log in to see more comments