23#ifdef PID_CONTROLLER_TUNING_AID_ADDRESS
27#include <sys/socket.h>
40 : proportionalGain(kp),
89 LOGWARNING(
"pidcontroller: max output value exceeded. Resetting.");
92#ifdef PID_CONTROLLER_TUNING_AID_ADDRESS
112#ifdef PID_CONTROLLER_TUNING_AID_ADDRESS
124void cPidController::SendTuningAidData(
double pTerm,
double iTerm,
double dTerm,
double input,
double output,
double targetValue)
126 static int sock = -1;
127 static struct sockaddr_in dest_addr;
131 sock = socket(AF_INET, SOCK_DGRAM, 0);
133 memset(&dest_addr, 0,
sizeof(dest_addr));
134 dest_addr.sin_family = AF_INET;
135 dest_addr.sin_port = htons(9870);
136 inet_pton(AF_INET, PID_CONTROLLER_TUNING_AID_ADDRESS, &dest_addr.sin_addr);
141 int len = snprintf(payload,
sizeof(payload),
142 "{\"bufferFillLevelMs\":%g,\"targetBufferFillLevelMs\":%g,\"pTerm\":%g,\"iTerm\":%g,\"dTerm\":%g,\"outputPpm\":%g}",
146 sendto(sock, payload, len, 0, (
struct sockaddr*)&dest_addr,
sizeof(dest_addr));
double integralGain
Integral Gain (Ki) - Drift correction.
double targetValue
The desired buffer fill level in frames.
double integralSum
Accumulator for the I-term.
void Reset()
Resets the internal state (integral sum and error history)
double maxOutput
Hard limit for output correction.
double maxIntegral
Anti-windup limit for the integral term.
double iTerm
Integral term.
cPidController(double, double, double, double)
Constructor for the PID Controller.
double dTerm
Derivative term.
double proportionalGain
Proportional Gain (Kp) - Reaction strength.
double Update(double, double)
Calculates the new output value.
double pTerm
Proportional term.
bool firstRun
Flag for first run.
double previousError
Error from the previous step (for D-term)
double derivativeGain
Derivative Gain (Kd) - Dampening.
Logger class header file.
Proportinal, Integral, Derivative Controller.