rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
ErrorAccumulator Class Reference

#include <error_accumulator.h>

Collaboration diagram for ErrorAccumulator:
Collaboration graph
[legend]

Public Member Functions

void init (float ignoreError, float dt)
 
float accumulate (float error)
 
float getAccumulator () const
 
void reset ()
 

Private Attributes

float m_ignoreError = 0
 
float m_dt = 0
 
float m_errorIntegral = 0
 

Detailed Description

Definition at line 3 of file error_accumulator.h.

Member Function Documentation

◆ accumulate()

float ErrorAccumulator::accumulate ( float  error)

Definition at line 7 of file error_accumulator.cpp.

7 {
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}

Referenced by EtbController::getClosedLoop().

Here is the caller graph for this function:

◆ getAccumulator()

float ErrorAccumulator::getAccumulator ( ) const
inline

Definition at line 14 of file error_accumulator.h.

14 {
15 return m_errorIntegral;
16 }

◆ init()

void ErrorAccumulator::init ( float  ignoreError,
float  dt 
)
inline

Definition at line 5 of file error_accumulator.h.

5 {
6 m_ignoreError = ignoreError;
7 m_dt = dt;
8 }

Referenced by EtbController::init().

Here is the caller graph for this function:

◆ reset()

void ErrorAccumulator::reset ( )

Definition at line 29 of file error_accumulator.cpp.

29 {
31}

Referenced by EtbController::getClosedLoop().

Here is the caller graph for this function:

Field Documentation

◆ m_dt

float ErrorAccumulator::m_dt = 0
private

Definition at line 25 of file error_accumulator.h.

Referenced by accumulate(), and init().

◆ m_errorIntegral

float ErrorAccumulator::m_errorIntegral = 0
private

Definition at line 27 of file error_accumulator.h.

Referenced by accumulate(), getAccumulator(), and reset().

◆ m_ignoreError

float ErrorAccumulator::m_ignoreError = 0
private

Definition at line 23 of file error_accumulator.h.

Referenced by accumulate(), and init().


The documentation for this class was generated from the following files: