firmware/controllers/math/torque_estimator.cpp
| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | ||||
| 3 | ✗ | void estimateTorqueTable() { | ||
| 4 | ✗ | for (int rpmIndex = 0;rpmIndex<TORQUE_CURVE_RPM_SIZE;rpmIndex++) { | ||
| 5 | ✗ | for (int loadIndex = 0;loadIndex<TORQUE_CURVE_SIZE;loadIndex++) { | ||
| 6 | ✗ | float rpmValue = config->torqueRpmBins[rpmIndex]; | ||
| 7 | ||||
| 8 | // let's assume speed density for now | |||
| 9 | // here we assume load is MAP while older parts of codebase have TPS, maybe for no good reason | |||
| 10 | // TODO: clean this up, see 'torqueLoadBins' usages | |||
| 11 | ✗ | float mapValue = config->torqueLoadBins[loadIndex]; | ||
| 12 | ||||
| 13 | ✗ | percent_t veValue = interpolate3d( | ||
| 14 | ✗ | config->veTable, | ||
| 15 | ✗ | config->veLoadBins, mapValue, | ||
| 16 | ✗ | config->veRpmBins, rpmValue | ||
| 17 | ); | |||
| 18 | ✗ | float estimated = engineConfiguration->referenceTorqueForGenerator | ||
| 19 | ✗ | * veValue / engineConfiguration->referenceVeForGenerator | ||
| 20 | ✗ | * mapValue / engineConfiguration->referenceMapForGenerator; | ||
| 21 | ||||
| 22 | ✗ | config->torqueTable[loadIndex][rpmIndex] = estimated; | ||
| 23 | ✗ | if (loadIndex == 0 && rpmIndex == 0) { | ||
| 24 | ✗ | efiPrintf("estimateTorqueTable [%f] %f", veValue, estimated); | ||
| 25 | } | |||
| 26 | ||||
| 27 | } | |||
| 28 | } | |||
| 29 | ||||
| 30 | ✗ | } | ||
| 31 |