mirror of
https://github.com/mck1117/wideband.git
synced 2026-11-04 19:36:30 -05:00
14 lines
295 B
C++
14 lines
295 B
C++
#include "pid.h"
|
|
|
|
float Pid::GetOutput(float setpoint, float observation)
|
|
{
|
|
// TODO: is this backwards?
|
|
float error = setpoint - observation;
|
|
|
|
// Integrate error
|
|
m_integrator += error * m_period;
|
|
|
|
// Multiply by gains and sum
|
|
return m_kp * error + m_ki * m_integrator;
|
|
}
|