This repository has been archived on 2025-06-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
compLIB/server/include/pid.hpp
2022-04-02 22:49:04 +01:00

30 lines
No EOL
635 B
C++

#ifndef COMPLIB_SERVER_PID_HPP
#define COMPLIB_SERVER_PID_HPP
#include <chrono>
#define PID_RESET_DELAY_S 0.1L
class PID
{
public:
PID(float P, float I, float D, float ramp, float limit);
~PID() = default;
float operator() (float setpoint, float process_variable);
void reset();
float P = 1;
float I = 0;
float D = 0;
float setpoint_ramp = 0;
float limit = 0;
protected:
float error_prev = 0;
float setpoint_prev = 0;
float integral_prev = 0;
std::chrono::system_clock::time_point timestamp_prev = std::chrono::high_resolution_clock::now();
};
#endif // COMPLIB_SERVER_PID_HPP