mirror of
https://github.com/mck1117/wideband.git
synced 2026-09-30 09:57:06 -04:00
29 lines
429 B
C++
29 lines
429 B
C++
#pragma once
|
|
|
|
struct PidConfig
|
|
{
|
|
float kP;
|
|
float kI;
|
|
float kD;
|
|
float clamp;
|
|
};
|
|
|
|
class Pid
|
|
{
|
|
public:
|
|
Pid(const PidConfig& config, float periodMs)
|
|
: m_config(config)
|
|
, m_periodSec(1e-3 * periodMs)
|
|
{
|
|
}
|
|
|
|
float GetOutput(float setpoint, float observation);
|
|
|
|
private:
|
|
const PidConfig& m_config;
|
|
const float m_periodSec;
|
|
|
|
float m_lastError = 0;
|
|
float m_integrator = 0;
|
|
};
|