Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: clarify simplest instructions


...

Warning
titleNo AutoTune for STM32F1 based hardware

AutoTune is currently not built into CC3D

...

/Atom firmware, due to small CPU and lack of memory.


LibrePilot version 16.09 and later has AutoTune.  Here is the simplest version of how to use AutoTune for those that don't want details.  If you don't read the details (problems to avoid and useful features you didn't know existed) and ask questions that are answered farther down in the details, be prepared for a bit of derision.  (smile)

Simplest use of AutoTune:
- use stock PIDs (or known, slow, smooth PIDs that do not have "invisible oscillation") in bank #1
- set up and save FMS (Flight Mode Switch) for
--- FMS#1 Attitude mode manual throttle (Stabilized 1) on bank 1
--- FMS#2 AutoTune mode (like Attitude mode but with shaking) on bank 1
--- FMS#3 Attitude mode manual throttle (Stabilized 1) on bank 3
- take off with FMS #1
- switch to FMS #2 and after saving, power off and on the FC so it sees AutoTune and enables the AutoTune module
- take off with FMS #1
- switch to FMS #2 and after 2 seconds, it will shake around for 60 seconds
- land after shaking stops
- disarm
- switch to FMS #3
- arm
- carefully take off to test the new PIDs (be ready to instantly drop by using zero throttle if anything strange happens)

...

For the slightly less impatient, skip down to the section titled "Cloning Instructions" or "Flight Mode Switch setup".

Background and Details"
LibrePilot has ported Tau Labs / dRonin "Autotune" into 'next' and the coming 16.09 release (including RC#'s).

...

Invisible oscillation (sometimes D term oscillation or yaw oscillation) generally cannot be seen or heard.  One way you know you have it is that all throttle stick positions can act as if they were closer to the middle.  Another way you know is if you have two FMS positions that use different PID banks (and manual thrust), and one set of PIDs has significantly lower D terms (or a lower yaw PID) and you are hovering and switch from one to the other, you may notice that you need to add power to maintain altitude.  Increased thrust from the high D term / high yaw PID is caused by the ESCs being commanded up and down and being quicker when increasing RPM than when decreasing it.  You may find that motors tend to run hotter and batteries don't last as long as they should.  Powerful copters (those that require less than 50% power to hover) will take off with much 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.  Try reducing your D terms (Stabilization -> Advanced), reducing your yaw PID, or increasing (doubling) GyroTau (GCS -> Configuration -> Stabilization -> Expert > Gyro Noise Filtering), but realize that increasing GyroTau requires rerunning the AutoTune flight and will make AutoTune create very slow smooth PIDs.

Oscillation can cause AutoTune to fail.  If AutoTune internal sanity checks fail, it won't write PIDs.  It's also possible to get PIDs that don't fly well.  If you have a problem with oscillation, it must be corrected before running AutoTune.  This is especially true of invisible oscillations.

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.  As a point of reference, a good pilot should be able to do a tuning in a single car garage stall.

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 (or oscillation) happening, the copter tends to climb because the motors speed up more quickly than they slow down.  With slow or undamped/unbraked ESCs you may notice this when AutoTune mode starts shaking the copter.

AutoTune is not currently supported on CC3D, although it is hoped that a CC3D firmware can be made that removes other features to add AutoTune.  This would be flashed temporarily just to run AutoTune and then normal firmware would be reflashed.  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 run it at the flying field without requiring use of the GCS at the flying field.

AutoTune is merged into both 'next' and 'rel-16.09' branches and is available in 16.09 RC#'s.

Before you uninstall or overwrite your old software / firmware you should run the old GCS, plug the FC (flight controller) into USB, and do a "File → Export UAV Settings" to save your old settings in case you want to know how it was set up.  You should also do screen captures (print screen) on all the setup pages you have used (and thus have non-default values).  These could be valuable later on.

Cloning Instructions (tested on Linux):
It is assumed that you have a working development environment:
git  clone  https://bitbucket.org/librepilot/librepilot.git
cd  librepilot
git  checkout  rel-16.09
make  build_sdk_install   (I avoid this by sym linking my global downloads and tools directories into this directory, so whatever you need to do for downloads and tools)
nice  -n15  make  -j4  gcs  revolution  revonano    sparky2   (the 4 is however many real CPU cores you have to keep all of them busy, it still works even if it is wrong)  (gcs might take 30 minutes to build)  (or remove 'nice -n15' which says to run it at low priority in case you want to do something else with the computer while it is making the software)
./build/librepilot-gcs_release/bin/librepilot-gcs   (runs the GCS that you just built) (in Linux that is ./b <tab> l (lower case L) <tab> b <tab> <tab>)

The instructions above are written with several spaces between each word for clarity.  They work just as well with only one space.

Updating an old clone:
The old branch has been rebased onto next (and rel-16.09) and uploaded with push -f.  That means you will have problems if you originally started from the version before the rebase.  AutoTune has been merged into rel-16.09, so the best way now is to delete the old directory and clone rel-16.09.
With GCS running and firmware built, go to the Firmware page, press Halt.  Wait about 15 seconds for the Flash button to appear.  Also, it should automatically select firmware that matches your flight controller.  Press Flash.  You will also have to erase settings and run the setup wizard again.  With that complete, you need to do your calibrations before anything elseIf your multicopter is already tuned and you reduce performance by adding weight like a camera or larger battery (with same cell count); or reducing power (fewer cells in battery, different props) then you have created an oscillation.

On the other hand, if you remove a camera from a multicopter that is tuned to fly with the camera (or generally do something to increase performance), it wont' oscillate, it just won't be quite as quick reacting as it could be.  It will fly a bit "like it has a camera mounted" even when it doesn't.  That isn't so bad.

So if you are only going to do one tune, then do it with the camera on.  You can fly this tune with or without the camera.  Be aware that PID banks are excellent for storing different PIDs if you want different tunes for e.g. with / without a camera.  You can use one PID bank for with camera and one PID bank for without camera.

Oscillation can cause AutoTune to fail and even to crash.  If you have a problem with oscillation, it must be corrected before running AutoTune.  This is especially true of invisible oscillations if only because they are not obvious.  This is also especially true if you are adding a camera to a multicopter that is already tuned.

Ringing (Attitude mode) is when you move the stick suddenly and it doesn't immediately settle at the new bank angle.  Instead it oscillates a few times, but the oscillations die out quickly.

Assume that stock PIDs may oscillate or ring, especially with small multicopters or adding cameras.  Cutting your R/P/Y PI's in half will usually remove oscillation or ringing and make it safe to run AutoTune.

If AutoTune internal sanity checks fail, it won't write PIDs.  It's also possible to get PIDs that don't fly well.  This was more true in earlier versions of AutoTune.

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.  As a point of reference, a good pilot should be able to do a tuning in a single car garage stall.

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 (or oscillation) happening, the copter tends to climb because the motors speed up more quickly than they slow down.  With slow or undamped/unbraked ESCs you may notice this when AutoTune mode starts shaking the copter.

AutoTune is not currently supported on CC3D, although it is hoped that a CC3D firmware can be made that removes other features to add AutoTune.  This would be flashed temporarily just to run AutoTune and then normal firmware would be reflashed.  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 run it at the flying field without requiring use of the GCS at the flying field.

Flight Mode Switch setup:
Note that when AutoTune is complete, it writes the calculated PIDs into the destination stabilization (PID) bank which by default is configured to be bank 3.  The standard AutoTune procedure has you flying the AutoTune mode on bank 1 and writing the new PIDs to bank 3 (default destination PID bank was changed from 2 to 3).

...

The recommended setup for running AutoTune uses a 3 position FMS (Flight Mode Switch).  With this, you can take off and fly Attitude mode with known working PIDs, run AutoTune with known working PIDs and fly Attitude mode with new PIDs, all without using the GCS:
Pos#1 - Attitude mode using bank 1
Pos#2 - AutoTune using bank 1 with SystemIdentSettings.DestinationPidBank set to 3 (that is the default)
Pos#3 - Attitude mode using bank 3 (bank 3 is where the tuned PIDs are written by default)
PID bank 1 should have default PIDs or something that is at least known to fly without oscillations.
PID bank 3 should have default PIDs or something that is at least known to fly without oscillations in case you use it before successfully completing a tune.
This setup can all be done at home, and everything else can be done at the flying field, without using the GCS.
With this FMS setup, you always have Pos#1 to fall back on.  Use Pos#1 to recover from any bad situation or to start over and run AutoTune again.

An alternate FMS setup for a 2 position FMS removes the ability to fly with default PIDs once you have run AutoTune:
Pos#1 - Attitude mode using bank 3 (bank 3 is where the tuned PIDs are written by default)
Pos#2 - AutoTune using bank 1 with SystemIdentSettings.DestinationPidBank set to 3 (that is the default)
PID bank 1 should have default PIDs or something that is at least known to fly without oscillations.
PID bank 3 should have default PIDs or something that is at least known to fly without oscillations.
PID bank 3 starts out with the same PIDs as bank 1, but the PIDs will be changed by AutoTune.
It is possible to arm in Pos#1, then switch to Pos#2 and immediately take off before the AutoTune shaking starts (two seconds), if your tuned PIDs don't work and you want to retune.

...

If you intend to fly this copter both with and without a significant payload attached (like a camera) or with different batteries (weight, cell count) then ideally you would tune each case separately and store them in different PID banks.  Probably the easiest way to handle the simple case of with/without a camera is to tune with the camera, copy bank2 bank 3 to bank3bank 2, retune without the camera and leave that in bank 23.  Then remove AutoTune from your FMS and add flight modes that include both bank 2 3 (without camera) and bank 3 2 (with camera).  Note that the lighter total weight has smaller PIDs.  Smaller PIDs will work when carrying an extra load that wasn't there when tuning (it is a bit mushy), but if you use the larger PIDs that come from tuning with a camera mounted when the camera is not mounted, you may get some minor oscillations.

...

DataObjects.SystemIdentState
- Is not stored permanently (Goes away when power is removed)
- Is logged
- HoverThrottle is the average throttle used during tuning.  It is a reasonable value to use in Settings.AltitudeHoldSettings.ThrustLimits.Neutral although it is usually a little smaller than it should be due to throttle bloom during shaking.
- The 3 values in Noise tell you how much vibration you have on the 3 axes.  Normal values range from about 100 to about 1000.  For high values, or jittery response to the PIDs created, balance your props and if that doesn't help, you may want to increase Settings.StabilizationSettings.GyroTau (found in the GCS GUI at Configuration -> Stabilization -> Expert -> GyroNoiseFiltering) and retune (you must actually fly the tuning flight again).  Now you know how much vibration you actually have.
- Contains fields that may be useful if debugging problems with AutoTune
- Contains copies (for logging purposes) of some fields from System.SystemIdentSettings

GyroReadTimeAverage