Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/APM_Control/AP_PitchController.h
Views: 1798
#pragma once12#include <AP_Common/AP_Common.h>3#include "AP_AutoTune.h"4#include <AP_Math/AP_Math.h>5#include <AC_PID/AC_PID.h>67class AP_PitchController8{9public:10AP_PitchController(const AP_FixedWing &parms);1112/* Do not allow copies */13CLASS_NO_COPY(AP_PitchController);1415float get_rate_out(float desired_rate, float scaler);16float get_servo_out(int32_t angle_err, float scaler, bool disable_integrator, bool ground_mode);1718// setup a one loop FF scale multiplier. This replaces any previous scale applied19// so should only be used when only one source of scaling is needed20void set_ff_scale(float _ff_scale) { ff_scale = _ff_scale; }2122void reset_I();2324/*25reduce the integrator, used when we have a low scale factor in a quadplane hover26*/27void decay_I()28{29// this reduces integrator by 95% over 2s30_pid_info.I *= 0.995f;31rate_pid.set_integrator(rate_pid.get_i() * 0.995);32}3334void autotune_start(void);35void autotune_restore(void);3637const AP_PIDInfo& get_pid_info(void) const38{39return _pid_info;40}4142// set the PID notch sample rates43void set_notch_sample_rate(float sample_rate) { rate_pid.set_notch_sample_rate(sample_rate); }4445static const struct AP_Param::GroupInfo var_info[];4647AP_Float &kP(void) { return rate_pid.kP(); }48AP_Float &kI(void) { return rate_pid.kI(); }49AP_Float &kD(void) { return rate_pid.kD(); }50AP_Float &kFF(void) { return rate_pid.ff(); }51AP_Float &tau(void) { return gains.tau; }5253void convert_pid();5455private:56const AP_FixedWing &aparm;57AP_AutoTune::ATGains gains;58AP_AutoTune *autotune;59bool failed_autotune_alloc;60AP_Int16 _max_rate_neg;61AP_Float _roll_ff;62float _last_out;63AC_PID rate_pid{0.04, 0.15, 0, 0.345, 0.666, 3, 0, 12, 150, 1};64float angle_err_deg;65float ff_scale = 1.0;6667AP_PIDInfo _pid_info;6869float _get_rate_out(float desired_rate, float scaler, bool disable_integrator, float aspeed, bool ground_mode);70float _get_coordination_rate_offset(float &aspeed, bool &inverted) const;71};727374