From e8ad309831d9ab1d11034b87faada182bef7baa7 Mon Sep 17 00:00:00 2001 From: Andru Liu <90433630+WallabyLester@users.noreply.github.com> Date: Tue, 8 Oct 2024 20:21:02 -0700 Subject: [PATCH] Adding Doxygen style comments to header file. --- CPP_Implementation/apid_controller.h | 58 ++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/CPP_Implementation/apid_controller.h b/CPP_Implementation/apid_controller.h index 3bc95a6..5456ab2 100644 --- a/CPP_Implementation/apid_controller.h +++ b/CPP_Implementation/apid_controller.h @@ -1,24 +1,76 @@ #ifndef APID_CONTROLLER_H #define APID_CONTROLLER_H +/** + * @class aPIDController + * @brief Adaptive PID Controller class for control systems. + * + * This class implements a simple adaptive PID controller that can be used + * to control a system by adjusting the output based on the error + * between a target value and a measured value. + */ class aPIDController { public: + /** + * @brief Constructor to initialize PID gains and time step. + * + * @param kp Proportional gain. + * @param ki Integral gain. + * @param kd Derivative gain. + * @param dt Time step. + */ aPIDController(double kp=0.0, double ki=0.0, double kd=0.0, double dt=0.1); + /** + * @brief Update the PID output based on the target and measured value. + * + * @param target The desired target value. + * @param measured_value The current measured value. + * @return The computed control output. + */ double update(double target, double measured_value); + /** + * @brief Set the proportional gain. + * @param kp The new proportional gain. + */ void set_Kp(double kp) {Kp = kp;} + + /** + * @brief Set the integral gain. + * @param ki The new integral gain. + */ void set_Ki(double ki) {Ki = ki;} + + /** + * @brief Set the derivative gain. + * @param kd The new derivative gain. + */ void set_Kd(double kd) {Kd = kd;} + /** + * @brief Get the proportional gain. + * @return The current proportional gain. + */ double get_Kp() const { return Kp; } + + /** + * @brief Get the integral gain. + * @return The current integral gain. + */ double get_Ki() const { return Ki; } + + /** + * @brief Get the derivative gain. + * @return The current derivative gain. + */ double get_Kd() const { return Kd; } private: - double Kp, Ki, Kd, dt; - double integral; - double prev_err; + double Kp, Ki, Kd; // PID gains + double dt; // Time step + double integral; // Integral term + double prev_err; // Previous error }; #endif // APID_CONTROLLER_H