APM:Libraries
Macros | Variables
AP_AutoTune.cpp File Reference
#include "AP_AutoTune.h"
#include <AP_Common/AP_Common.h>
#include <AP_HAL/AP_HAL.h>
#include <AP_Math/AP_Math.h>
#include <stdio.h>
Include dependency graph for AP_AutoTune.cpp:

Go to the source code of this file.

Macros

#define AUTOTUNE_SAVE_PERIOD   10000U
 
#define AUTOTUNE_OVERSHOOT_TIME   100
 
#define AUTOTUNE_UNDERSHOOT_TIME   200
 
#define AUTOTUNE_INCREASE_STEP   5
 
#define AUTOTUNE_DECREASE_STEP   8
 
#define AUTOTUNE_MAX_P   5.0f
 
#define AUTOTUNE_MIN_P   0.3f
 
#define AUTOTUNE_MAX_TAU   0.7f
 
#define AUTOTUNE_MIN_TAU   0.2f
 
#define AUTOTUNE_MIN_IMAX   2000
 
#define AUTOTUNE_MAX_IMAX   4000
 
#define Debug(fmt, args ...)   do {::printf("%s:%d: " fmt "\n", __FUNCTION__, __LINE__, ## args); } while(0)
 

Variables

const AP_HAL::HALhal
 -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- More...
 
struct {
   float   tau
 
   float   Dratio
 
   float   rmax
 
tuning_table []
 

Macro Definition Documentation

◆ AUTOTUNE_DECREASE_STEP

#define AUTOTUNE_DECREASE_STEP   8

Definition at line 55 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::check_state_exit().

◆ AUTOTUNE_INCREASE_STEP

#define AUTOTUNE_INCREASE_STEP   5

Definition at line 52 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::check_state_exit().

◆ AUTOTUNE_MAX_IMAX

#define AUTOTUNE_MAX_IMAX   4000

Definition at line 66 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::start().

◆ AUTOTUNE_MAX_P

#define AUTOTUNE_MAX_P   5.0f

Definition at line 58 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::check_state_exit().

◆ AUTOTUNE_MAX_TAU

#define AUTOTUNE_MAX_TAU   0.7f

Definition at line 62 of file AP_AutoTune.cpp.

◆ AUTOTUNE_MIN_IMAX

#define AUTOTUNE_MIN_IMAX   2000

Definition at line 65 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::start().

◆ AUTOTUNE_MIN_P

#define AUTOTUNE_MIN_P   0.3f

Definition at line 59 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::check_state_exit().

◆ AUTOTUNE_MIN_TAU

#define AUTOTUNE_MIN_TAU   0.2f

Definition at line 63 of file AP_AutoTune.cpp.

◆ AUTOTUNE_OVERSHOOT_TIME

#define AUTOTUNE_OVERSHOOT_TIME   100

Definition at line 46 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::check_state_exit().

◆ AUTOTUNE_SAVE_PERIOD

#define AUTOTUNE_SAVE_PERIOD   10000U

Definition at line 43 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::check_save().

◆ AUTOTUNE_UNDERSHOOT_TIME

#define AUTOTUNE_UNDERSHOOT_TIME   200

Definition at line 49 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::check_state_exit().

◆ Debug

#define Debug (   fmt,
  args ... 
)    do {::printf("%s:%d: " fmt "\n", __FUNCTION__, __LINE__, ## args); } while(0)

Variable Documentation

◆ Dratio

float Dratio

Definition at line 95 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::start().

◆ hal

const AP_HAL::HAL& hal

-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-

The strategy for roll/pitch autotune is to give the user a AUTOTUNE flight mode which behaves just like FBWA, but does automatic tuning.

While the user is flying in AUTOTUNE the gains are saved every 10 seconds, but the saved gains are not the current gains, instead it saves the gains from 10s ago. When the user exits AUTOTUNE the gains are restored from 10s ago.

This allows the user to fly as much as they want in AUTOTUNE mode, and if they are ever unhappy they just exit the mode. If they stay in AUTOTUNE for more than 10s then their gains will have changed.

Using this approach users don't need any special switches, they just need to be able to enter and exit AUTOTUNE mode

Definition at line 14 of file AC_PID_test.cpp.

◆ rmax

float rmax

Definition at line 96 of file AP_AutoTune.cpp.

Referenced by AP_AutoTune::start().

◆ tau

float tau

◆ tuning_table

const { ... } tuning_table[]
Initial value:
= {
{ 0.70f, 0.050f, 20 },
{ 0.65f, 0.055f, 30 },
{ 0.60f, 0.060f, 40 },
{ 0.55f, 0.065f, 50 },
{ 0.50f, 0.070f, 60 },
{ 0.45f, 0.075f, 75 },
{ 0.40f, 0.080f, 90 },
{ 0.30f, 0.085f, 120 },
{ 0.20f, 0.090f, 160 },
{ 0.10f, 0.095f, 210 },
{ 0.05f, 0.100f, 300 },
}

Referenced by AP_AutoTune::check_state_exit(), and AP_AutoTune::start().