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.h
Views: 1798
#pragma once12/// @file AC_PD.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>7#include <stdlib.h>8#include <cmath>910/// @class AC_P11/// @brief Object managing one P controller12class AC_P {13public:1415/// Constructor for P that saves its settings to EEPROM16///17/// @note PIs must be named to avoid either multiple parameters with the18/// same name, or an overly complex constructor.19///20/// @param initial_p Initial value for the P term.21///22AC_P(const float &initial_p = 0.0f) :23default_kp(initial_p)24{25AP_Param::setup_object_defaults(this, var_info);26}2728CLASS_NO_COPY(AC_P);2930/// Iterate the P controller, return the new control value31///32/// Positive error produces positive output.33///34/// @param error The measured error value35/// @param dt The time delta in milliseconds (note36/// that update interval cannot be more37/// than 65.535 seconds due to limited range38/// of the data type).39///40/// @returns The updated control output.41///42float get_p(float error) const;4344/// Load gain properties45///46void load_gains();4748/// Save gain properties49///50void save_gains();5152/// @name parameter accessors53//@{5455// accessors56AP_Float &kP() { return _kp; }57const AP_Float &kP() const { return _kp; }58void set_kP(const float v) { _kp.set(v); }5960static const struct AP_Param::GroupInfo var_info[];6162private:63AP_Float _kp;6465const float default_kp;66};676869