rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
util
math
error_accumulator.cpp
Go to the documentation of this file.
1
#include "
pch.h
"
2
3
#include "
error_accumulator.h
"
4
5
// todo: shall we rename to StatsIntegrator or SomethingIntegrator assuming we see not "Error Accumulator" usages?
6
// todo: ValueIntegrator maybe?
7
float
ErrorAccumulator::accumulate
(
float
error) {
8
// We only care about the absolute value of the error
9
error = absF(error);
10
11
// If m_ignoreError is 5, for example:
12
// 0 error -> bleeds down at 5 per second
13
// 5 error -> integral stays where it is
14
// 10 error -> integral grows at 5 per second
15
float
accumulationRate = error -
m_ignoreError
;
16
17
float
newIntegral = accumulationRate *
m_dt
+
m_errorIntegral
;
18
19
// Don't allow less than 0 error
20
if
(newIntegral < 0) {
21
newIntegral = 0;
22
}
23
24
m_errorIntegral
= newIntegral;
25
26
return
newIntegral;
27
}
28
29
void
ErrorAccumulator::reset
() {
30
m_errorIntegral
= 0;
31
}
ErrorAccumulator::accumulate
float accumulate(float error)
Definition
error_accumulator.cpp:7
ErrorAccumulator::reset
void reset()
Definition
error_accumulator.cpp:29
ErrorAccumulator::m_ignoreError
float m_ignoreError
Definition
error_accumulator.h:23
ErrorAccumulator::m_errorIntegral
float m_errorIntegral
Definition
error_accumulator.h:27
ErrorAccumulator::m_dt
float m_dt
Definition
error_accumulator.h:25
error_accumulator.h
pch.h
Generated on Fri Sep 26 2025 00:10:16 for rusEFI by
1.9.8