Developer

Rate PI Autotuning - A third attempt

Hi again all, Two blog posts in two days... i'm on a roll. I just finished the next set of revisions to my autotuning code. I have shifted from tuning the stab gains to tuning the rate gains. This is more dangerous but also more rewarding.

Here are the major changes:

1. Stab gains no longer tuned, switched to rate gains.

2. Addressed the issue of inconsistent user induced disturbances. Previously if the user disturbance was not consistent, the calculated performance value would be inaccurate. Now it is a scaled based on the initial pitch/roll of the copter.

3. Lowered the initial amount of gain change to 25% to mitigate the risk of in flight gain changes.

4. Added a safeguard against a gain that is too low and never returns the copter to level.

5. Moved all autotuning related logic into its own .pde file so it is easy to find

Instructions:

1. Upload the modified code (see attached zip based on v2.3)

2. Set your stab p gain to 1, stab i and d to zero

3. Set your rate p gain to some ballpark number, rate i and d to zero

4. Start your simulator

5. Bring the copter to a hover

6. Flip the ch 7 switch to the high position

7. Introduce a pitch or roll disturbance. This should be a quick movement and then return the stick to center (see video) (repeat 10 times at least).

8. Flip the ch 7 switch to the low position

9. Go to the planner and refresh the param list.

10. Set stab p = 1 + the value from rate p (maybe a little lower), stab i = 0 and stab d = .002

11. Set rate d = rate i - .003

12. Write the new values and observe in the simulator.

That should get you very close to rock solid. I have found the need to play with the stab p gain a little bit, but other than that I have had good results. Steps 10 - 12 are a bit hazy at the moment and will require some additional manual tuning.  Those last steps are based on observations that I have made, not specific processes that I can guarantee will work for everyone. I am hoping some others can chime in here with some insight. Perhaps some devs can get eyes on this as well. I did try to push this into my git branch, but I am having some authentication issues at the moment.

Please watch the video for more information.... It is still uploading as of now, so if you can't see it yet just give it another 20 min or so. My videos are in 1080p so you can read my screen.

Thanks,

Adam

Autotuning_AdamRivera_02032012.zip

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Hey, has anyone tested this code in flight? I'm really interested in testing this since tuning has been a challenge.

    Great work!

  • T3
    Thanks Adam, nice work. The more we play the better we get and the more we understand. Tuning is one of those things, people have a hard time with. I know I've hard time wrapping my head around it. Thanks again.
  • Developer

    Thanks! Hopefully it will help some tuning casualties at some point.

  • Developer

    Very cool stuff Adam.

  • Developer

    @Michael: Also, what was your general impression of the tuning result? How did the quad feel?

  • Developer

    @Michael: Perfect thanks... I'll give that a shot tonight. Also, thanks for testing... I notice that your stab P value is quite high. Did you have to keep upping that to get it to be responsive enough?

  • Developer

    for the latest plaugin you need
    http://www.aerosimrc.com/downloads/AeroSIMRC_3.83-3.81.exe

    and this is the instructions i sent to the dev list

    ok new APMQUAD plugin. this passes direct pwms to channels 34-38 in aerosimrc.

    1. in the planner tick quad instead of heli

     2. the gains now do nothing. as this passes through pwms, they will affect the display graph though, but that is all.

    3. in aerosim rc, you need to modify a quad. i have yet found good paramaters, so please be my guest and find something that is stable.

     

    Aerosim

     

    1. press F12 - editor

    2. to get something flyable modify aerodynamic drag angular damping both to 0.1 - increasing this slows down overall responce.

    3. in speed controllers modify the channel to 34 to 38 for sc_1 to sc_4

    4. remove AP and Gyro is you like. 5. ive been testing with the QUAD-IV

     

    and here are some pids i found using your tunning code

    Stabalize P = 3.7 i = 0 Stabalize D = 0.002
    Rate p = 0.96 i = 0.014 d = 0.011
    and in aerosim, angualr drag x2 = 0.16

  • Developer

    @Michael: Does the latest AeroSim plugin in the Mission Planner work with the latest version of AeroSim or is that still in the works. AeroSim displayed an error when I attempted to load the latest plugin version.

This reply was deleted.