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/AC_PID/AC_P_1D.h
Views: 1798
#pragma once12/// @file AC_P_1D.h3/// @brief Generic P controller, with EEPROM-backed storage of constants.45#include <AP_Common/AP_Common.h>6#include <AP_Param/AP_Param.h>78/// @class AC_P_1D9/// @brief Object managing one P controller10class AC_P_1D {11public:1213// constructor14AC_P_1D(float initial_p);1516CLASS_NO_COPY(AC_P_1D);1718// update_all - set target and measured inputs to P controller and calculate outputs19// target and measurement are filtered20float update_all(float &target, float measurement) WARN_IF_UNUSED;2122// set_limits - sets the maximum error to limit output and first and second derivative of output23void set_limits(float output_min, float output_max, float D_Out_max = 0.0f, float D2_Out_max = 0.0f);2425// set_error_limits - reduce maximum position error to error_max26// to be called after setting limits27void set_error_limits(float error_min, float error_max);2829// get_error_min - return minimum position error30float get_error_min() const { return _error_min; }3132// get_error_max - return maximum position error33float get_error_max() const { return _error_max; }3435// save gain to eeprom36void save_gains() { _kp.save(); }3738// accessors39AP_Float &kP() WARN_IF_UNUSED { return _kp; }40const AP_Float &kP() const WARN_IF_UNUSED { return _kp; }41float get_error() const { return _error; }4243// set accessors44void set_kP(float v) { _kp.set(v); }4546// parameter var table47static const struct AP_Param::GroupInfo var_info[];4849private:5051// parameters52AP_Float _kp;5354// internal variables55float _error; // time step in seconds56float _error_min; // error limit in negative direction57float _error_max; // error limit in positive direction58float _D1_max; // maximum first derivative of output5960const float default_kp;61};626364