Since the past three months,while I was coding my Su-35S flanker,I had to reverse engineer and study PID systems and specially @GuyFolks codes in his various builds.One thing I saw in his f22 build is that if you remove the "clamp01()*" clutters and inverselerp stuff and other reverse functions,this is the base code you get in his jets elevators and tvc hinges
[code in the left elevator and if its invert is True.]
clamp(
PID(
Pitch + Roll,
(PitchRate/some number+abs(Pitch) *some random number)
- (RollRate/some number+abs(Roll) *some random number) +
AngleOfAttack/some number to your need +
,1.5,0,0.15),-1,1
)
[code in the right elevator and if its invert is false]
clamp(
PID(
Pitch - Roll,
(PitchRate/some number +abs(Pitch) *some random number)
+(RollRate/some number+abs(Roll) *some random number) +
AngleOfAttack/some number to your need
,1.5,0,0.15),-1,1
)
🔴It may be a bit different as I am only explaing as far what I learned.The invert stuff sometimes messes up and you might need to configure the inversion and +,- signs to match the inputs.🔴
As I tested the numbers to divide the PitchRate,RollRate and AngkeOfAttack varies with aircraft as different jets differ in com,col and weight, wing lift and engine power.I would suggest keeping the number at least 25+ for AngleOfAttack and 50+ for PitchRate or RollRate when your starting and slowly increase the numbers according to your planes needs.
here the P,I and D may vary but I saw that keeping the p near the value of 1 and D lower than P keeps the jet comparatively smooth.
🔴⏩(But I saw that if you set the D value to be zero,the shaking dosent occur anymore)⏪🔴
Also,never use integration or I unless you actualy know what your doing, othwrwise your hinges will slowly get stuck due to the small inputs summing up.
Think of the P as a dog,the more the error,the more it wants to bite,the D is like the leash on the dog so that it dosent out of control too much.
Sometimes,in his builds or in builds using PID,you'll see the jet shaking at high speeds like a bird flapping.This happends due to the fps drop. We can lower it by multiplying the whole code with a clamped inverselerp function like the below:
(The whole code)*clamp(inverselerp(2000,0,IAS)
0,1)
this lowers the sensititvity of control as speed increases.
But I suggest to just lower the D value in PID to zero,as the jet slowly gets stuck at high speeds like mach 1.5+. But if you want your jets control sensitivity to be realistica,you can use inverselerp👍
Also,sorry people,forgot to give ",-1,1" at the end of the clamp codes🫠
@32 believe me,if your goal is to just make codes for the alerons,elevators and Rudders of your plane,just set the value of D and I to zero and you wont have the problem of seeing your plane vibrating constantly and it wont flap its wing like a bird at mach speeds.
Mad respect, reading other people’s FT code is super hard and I’ve never really been good at using PIDs.
Meh easy
Light work
EZ
Ez