Line |
Branch |
Decision |
Exec |
Source |
1 |
|
|
|
#pragma once |
2 |
|
|
|
|
3 |
|
|
|
class ErrorAccumulator { |
4 |
|
|
|
public: |
5 |
|
|
41 |
void init(float ignoreError, float dt) { |
6 |
|
|
41 |
m_ignoreError = ignoreError; |
7 |
|
|
41 |
m_dt = dt; |
8 |
|
|
41 |
} |
9 |
|
|
|
|
10 |
|
|
|
// Accumulate the current error, returning the total integrated error |
11 |
|
|
|
float accumulate(float error); |
12 |
|
|
|
|
13 |
|
|
|
// Get the current accumulator value |
14 |
|
|
3 |
float getAccumulator() const { |
15 |
|
|
3 |
return m_errorIntegral; |
16 |
|
|
|
} |
17 |
|
|
|
|
18 |
|
|
|
// Reset the integrator to 0 error. |
19 |
|
|
|
void reset(); |
20 |
|
|
|
|
21 |
|
|
|
private: |
22 |
|
|
|
// more or less threshold parameter |
23 |
|
|
|
float m_ignoreError = 0; |
24 |
|
|
|
// time parameter |
25 |
|
|
|
float m_dt = 0; |
26 |
|
|
|
// current state |
27 |
|
|
|
float m_errorIntegral = 0; |
28 |
|
|
|
}; |
29 |
|
|
|
|