Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

LibrePilot has ported Tau Labs / dRonin "Autotune" into a coming version of the LibrePilot firmware.

First some precautions.  Tuning caries a risk of oscillation and for LibrePilot firmware, oscillation tends to effectively move the throttle toward 50%.  If your copter requires more than 50% power to hover, then oscillation will make it descend.  If your copter needs less than 50% to hover, then obviously 50% will have it climbing.  In extreme cases any throttle above 0% will effectively be 50%.  Remember that zero throttle stick will stop the motors.  Don't make any changes to this important "motor off" safety feature.  Tuning is known to fail in some cases.  These same cases fail dRonin Autotune as well.  Be prepared.

Oscillation generally comes in 3 forms.  Normal oscillation is a rhythmic motion that is generally visible and audible.  It is usually caused by PIDs being too high.  Jerkiness is random, and is not actually an oscillation.  It is usually caused by too much vibration.  Replace or straighten bent shafts, balance and track your props, and if that is not enough, increase GCS -> Configuration -> Stabilization -> Expert -> Gyro Noise Filtering.  Invisible oscillation generally cannot be seen or heard.  The way you know you have it is that all throttle stick positions act as if they were closer to the middle.  Powerful copters (those that require less than 50% power to hover) will take off with less throttle than expected.  Weak copters (those that require more than 50% power to hover) will need more power than expected to take off, or will not take off even at full power.  Note that there have been reports of this also causing motors to run hot.

This version of AutoTune puts the copter into a special version of Attitude flight mode that shakes the copter and measures the motions.  As a pilot, you should be able to confidently fly in Attitude mode because it will be a bit more difficult than normal to maintain control.  Tuning also needs a larger area than simple hovering in case something goes wrong.

Multicopters fly better if they have "Light Damping (BLHeli)" or "COMP_PWM + MOTOR_BRAKE (SimonK)".  Without these, when there is a lot of stick control happening, the copter tends to climb.  You may notice this when AutoTune mode starts shaking the copter.

AutoTune is not currently supported on CC3D.   Also, there will be a GCS GUI for all this at some time, but it was designed to make it possible to set it up at home and be run at the flying field without requiring use of the GCS.

Currently you must be able to compile LibrePilot software / firmware yourself to be able to use this.  The pre-release source code can be found at: https://bitbucket.org/TheOtherCliff/librepilot/branch/theothercliff/LP-76_Port_Autotune_from_dRonin

Cloning Instructions (tested on Linux):
It is assumed that you have a working development environment:
git  clone  https://bitbucket.org/TheOtherCliff/librepilot.git  autotune
cd  autotune
git  checkout  theothercliff/LP-76_Port_Autotune_from_dRonin
ln  -s  ../downloads  ../tools  .  (or whatever you need to do for downloads and tools)
nice -n15 make  -j4  gcs  revolution  revonano  (the 4 is however many real CPU cores you have, not critical)  (gcs might take 30 minutes to build)  (or remove 'nice -n15')
./build/librepilot-gcs_release/bin/librepilot-gcs  (runs the GCS that you just built)

With GCS running and firmware built, go to the Firmware page, press Halt (wait about 15 seconds for the Flash button to appear), press Flash.  You will also have to erase settings and run the setup wizard again.

When AutoTune is complete, it writes the calculated PIDs into the destination stabilization (PID) bank which by default is configured to be bank 2.  The standard procedure has you flying the AutoTune mode on bank 1 and writing the new PIDs to bank 2.

Flight Mode Switch setup:
The recommended setup for running AutoTune uses a 3 position Flight Mode Switch.  With this, you can fly Attitude with default PIDs, AutoTune with default PIDs and Attitude with new PIDs, all without using the GCS:
Pos#1 - Attitude mode using bank 1
Pos#2 - AutoTune using bank 1 with SystemIdent.DestinationPidBank set to 2 (that is the default)
Pos#3 - Attitude mode using bank 2 (bank 2 is where the tuned PIDs are written by default)
You also must enable the AutoTune module in GCS -> System -> Settings -> HwSettings -> OptionalModules -> AutoTune -> "set to Enabled", highlight OptionalModules by clicking on it, and press the red up arrow at the top of the screen to save it permanently.  This setup can all be done at home, and everything else can be done at the flying field, without using the GCS. 

With this setup, you arm and take off in Pos#1 which is Attitude mode with default (or other) PIDs.  These PIDs must not oscillate for the tuning to work.  You switch to Pos#2 which is AutoTune mode which is also configured to use default (or other) PIDs.  After a few seconds the copter begins to shake.  Don't let the copter touch anything (such as the ground) while tuning is running.  60 seconds after that, the shaking stops and the tuning is complete.  The PIDs have been written to the destination PID bank, but are only stored in RAM memory at this point.  The PIDs will be written to permanent settings if you disarm before powering off.  The PIDs will be discarded if the copter is powered off without disarming it.

Any time after tuning is complete, you can switch to Pos#3 which is Attitude mode using the tuned PIDs to test them.  Use caution!  It is recommended that when tuning completes you land and disarm.  It is a good idea to examine the new PIDs with GCS before you fly them.  If they are very different than expected, you may decide to not even test fly them.  If you do decide to test fly them, switch to Pos#3 (Attitude with tuned PIDs), arm, and cautiously take off.  Before you take off, mentally prepare yourself to immediately apply zero throttle if something doesn't feel right.  You can simply retune by running AutoTune again if you want to.  The use of Attitude mode when testing the new PIDs is recommended (but not required), even for experts.  In the worst case scenario, oscillation will cause you to climb, and the only way to get down is to cut power and let if fall for short periods.  Automatic leveling in that case is very desirable.

SmoothQuickSource:
There is a virtual slider called SmoothQuick, and the PIDs you get are in the middle of the slider.  At one end is smooth which may be preferred for photography.  At the other end is quick which may be preferred for racing.  Once you have run the tuning, the FC will remember the tuning and allow you to change PIDs along this sliding scale at any time in the future (as long as you don't start the AutoTune process by staying in AutoTune mode for over 2 seconds while armed, even if you do accidentally start an unwanted new tuning you can just power it off without disarming to forget the new tuning before making it permanent).  SystemIdentSettings -> SmoothQuickSource is where you configure how to adjust the slider (it is not where you adjust it).  SmoothQuickSource = 0 disables this entirely.  The default of 25 says to access the next of 5 points on the slider by toggling the Flight Mode Switch (starting outside of AutoTune) into AutoTune and back out, 3 times (less than 2 seconds), but only if armed.  If you think of the slider as a scale from 0 to 100, with smoothest being 0 and quickest being 100, then you start out at 50.  The first time you do the fast FMS 3x toggle it will move you to 75 on the slider, then 100, then 0, then 25, then back to 50, etc.  So while you are flying the new PIDs, you can adjust them in real time.  If you do the fast FMS 3x toggle while disarmed, it will always set it to 50.  You can also set SmoothQuickSource to be a number from 10 to 13 which corresponds to using Accessory0 to Accessory3 to directly adjust the slider, in real time, while you are flying the tuned PID bank.  The settings needed to be able to set PIDs this way are all in SystemIdentSettings.  They are Tau and the 3 Beta values.  'Complete' must also be True.  You can copy these from another FC or from a previous tuning session and 'export' your PIDs with SmoothQuick.

AutoTune tries to produce results that to make the tuning flight correctly tuned.  That does not take into account the non-linearity of thrust response.  To remove high thrust oscillations (or increase stability during descent), use TPS to decrease PIDs at high thrust (and if necessary, increase PIDs at low thrust).  Typically you want the TPS curve/line to cross the horizontal axis at the point (thrust value) where the copter hovers.  Examine SystemIdentState -> HoverThrottle after tuning and before you power off (not saved) to see what your hover thrust is.  Beware of throttle bloom that happens when slow responding ESC's make a copter climb just because of the fast RPY controls.

  • No labels