Servers by jDrones

New fixed wing PID system and autotune


Last month we finally merged the new fixed wing control code slated for the ArduPilot plane 4.1 release. This provides a major improvement in several areas:

  • much better manual PID tuning, with clearer parameters and much improved filtering
  • new fixed wing AUTOTUNE system which produces a much better tune for a wider range of aircraft

The key change in the PIDs is we are switching to use the same PID code that is used for VTOL aircraft in ArduPilot. This leverages the great work that @Leonardthall has done to improve that PID system for the 4.1 release and gives us a common framework.

Old PID System
The old fixed wing PID system had some unusual properties that were left over from the very early days of ArduPilot. Specifically, the feed-forward gain was calculated using a combination of the P, I, D and time-constant. This was originally done to preserve parameter value behaviour for people running very early versions of ArduPilot. That odd feed-forward calculation did work, but made it harder to properly tune the aircraft for someone who does understand how PIDs work. For example, if you increased RLL2SRV_D in the old code to get a bit more damping then that would also, as a side effect, decrease the feed-forward gain, which is probably not what the user really wanted.

New PID System
The new PID system uses new names for the rate gains. For example, the full set of roll controller gains are now:

  • RLL2SRV_RMAX
  • RLL2SRV_TCONST
  • RLL_RATE_FF
  • RLL_RATE_P
  • RLL_RATE_I
  • RLL_RATE_D
  • RLL_RATE_FLTD
  • RLL_RATE_FLTE
  • RLL_RATE_FLTT
  • RLL_RATE_IMAX
  • RLL_RATE_SMAX

The same parameters are available for pitch, but with a PTCH prefix instead of RLL.
The RMAX and TCONST parameters are the same as before, and are the key parameters for determining the feel of the tune. If you want a very sharp response then you need a high RMAX and a low TCONST. For a gentle tune (eg. a glider) use low RMAX and high TCONST.
The rate PID itself now has 4 gain parameters, FF, P, I and D. In nearly all fixed wing aircraft the FF (feed-forward) term dominates, and is the most important parameter to get right. Luckily you can read the right FF value from any log where the pilot has commanded a sustained rate in the axis of the FF (eg. commanded a full right roll, or pitch up).
The P and D terms are the correction terms, and they are the ones that will most likely drive an oscillation if you push them too high. That is why we have a new slew limiter feature that can detect this oscillation and automatically back off the P and D components of the PID to reduce the oscillation.

New Fixed Wing AUTOTUNE Mode
Along with the new PID system we also have a new AUTOTUNE mode. This is a big improvement over the old AUTOTUNE, and is able to correctly setup your FF parameters as well as P, I and D. It should work on a much wider range of aircraft than the old AUTOTUNE.
As always, please report any issues you find with the new code! If you’d like to try it then just load the ‘latest’ firmware and go for it! Post any issues here.
When you update it will auto-convert your old PIDs to the new system.

17 Likes

Is this model able to be imported into UE4 to run with Airsim (in place of their default quadcopter)?

it would take a lot of work to replace the quad with a fixed wing in airsim. It would be a great project, but not easy.

How much is alot of work? And you mean mainly editing the json and c++ files? I have about a week or two - I’m a graduate aerospace engineer at the moment, needing this for school - to dedicate towards getting the model (I’m experienced with UE4 and somewhat with C++, not so much with air sim or ardupilot though)

yes, just need to replace the quadrotor model with a fixed wing model, and also work out a takeoff process and ground interaction. Good luck with it!

1 Like

Anyone knows when the motor is spinning randomly in 4.1 dev when the plane is disarmed?
It seems it’s doing this only when in RTL failsafe mode.

fly witn 4.1.0 beta. Matek f405 wing. sonicmodell binary 1200
Run new autotune. Not found any big improvement for traditional 4 channel plane
here logs https://1drv.ms/u/s!AuFPVI_eDaZbhbwWqZzoPirkPVgl2g?e=Sscwi8
plane have jerks on roll axis



and here video of flying
https://youtu.be/1yFLdk9Yi3E

I’m not sure to understand what does it means in @tridge comments of the release Luckily you can read the right FF value from any log where the pilot has commanded a sustained rate in the axis of the FF (eg. commanded a full right roll, or pitch up). If I look my log after an autotune flight: try to visualize Max Roll with FF parameter

(logs are already posted in Autotune plane: need help > desired Roll and achieved Roll )

Kind regards.

@tridge Hello,
I have tried the new autotune from level 6 to level4. The server jitter sometimes, Probably by every few seconds. The pitch does more than the roll. And the level 4 does more than level 6. Can you tell me how to fix it?

Can I tune the pid page on the gcs while the plane is in the air?

Thank you for any help.

Hi,the initial PID setting seems too low in firmware 4.1, is this the different unit compare to old PID setting?

the defaults in 4.1 are equivalent to the defaults in 4.0. The meanings of the parameters are different.
In the 4.1 defaults the most important value is the feed-forward (FF). In 4.0 the default FF was calculated based on the P value.

and i have problem in firmware4.1,it always show unhealth AHRS,but the plane fly well,is that a bug ?

Thanks tridge,do the PID or FF value will change if i update to 4.1 from 4.0? and if i feel the plane turn slow after autotune,can i just only increse FF ?sorry i don’t queit understand what FF mean,but i can understand the PID.

the new PID values will be automatically upgraded to equivalent values when you go from 4.0 to 4.1

no, it is probably that you have the AUTOTUNE_LEVEL set too low for the responsiveness you want. If you post a log we can take a look

tridge,can you tell if the unhealth AHRS is bug or some wrong in firmware 4.1,i can arm the plane but it always show unhealth AHRS,I’m not sure if my FC have a problem.the gps is ok .

I guess the problem is in EKF3,but i don’t know much about EKF

I can’t tell what is happening without logs. Both tlog and bin log from sdcard if possible

OK,thanks I will sent the log later

Servers by jDrones