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_YawController.h
Views: 1798
#pragma once12#include <AP_Common/AP_Common.h>3#include <AC_PID/AC_PID.h>4#include "AP_AutoTune.h"56class AP_YawController7{8public:9AP_YawController(const AP_FixedWing &parms);1011/* Do not allow copies */12CLASS_NO_COPY(AP_YawController);1314// return true if rate control or damping is enabled15bool enabled() const { return rate_control_enabled() || (_K_D > 0.0); }1617// return true if rate control is enabled18bool rate_control_enabled(void) const { return _rate_enable != 0; }1920// get actuator output for sideslip and yaw damping control21int32_t get_servo_out(float scaler, bool disable_integrator);2223// get actuator output for direct rate control24// desired_rate is in deg/sec. scaler is the surface speed scaler25float get_rate_out(float desired_rate, float scaler, bool disable_integrator);2627void reset_I();2829void reset_rate_PID();3031/*32reduce the integrator, used when we have a low scale factor in a quadplane hover33*/34void decay_I()35{36// this reduces integrator by 95% over 2s37_pid_info.I *= 0.995f;38}3940const AP_PIDInfo& get_pid_info(void) const41{42return _pid_info;43}4445// set the PID notch sample rates46void set_notch_sample_rate(float sample_rate) { rate_pid.set_notch_sample_rate(sample_rate); }4748// start/stop auto tuner49void autotune_start(void);50void autotune_restore(void);515253static const struct AP_Param::GroupInfo var_info[];5455private:56const AP_FixedWing &aparm;57AP_Float _K_A;58AP_Float _K_I;59AP_Float _K_D;60AP_Float _K_FF;61AP_Int16 _imax;62AP_Int8 _rate_enable;63AC_PID rate_pid{0.04, 0.15, 0, 0.15, 0.666, 3, 0, 12, 150, 1};6465uint32_t _last_t;66float _last_out;67float _last_rate_hp_out;68float _last_rate_hp_in;69float _K_D_last;7071float _integrator;7273AP_AutoTune::ATGains gains;74AP_AutoTune *autotune;75bool failed_autotune_alloc;7677AP_PIDInfo _pid_info;78};798081