ETB duty cycle jitter #4833

weird, whatever for now :(
This commit is contained in:
Andrey 2022-11-27 20:54:59 -05:00
parent a10542a3d6
commit 61de170d06
2 changed files with 9 additions and 3 deletions

View File

@ -208,7 +208,7 @@ bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidPara
// Ignore 3% position error before complaining // Ignore 3% position error before complaining
m_errorAccumulator.init(3.0f, etbPeriodSeconds); m_errorAccumulator.init(3.0f, etbPeriodSeconds);
// m_dutyIntegrator.init(engineConfiguration->etbDutyThreshold, etbPeriodSeconds); m_dutyIntegrator.init(engineConfiguration->etbDutyThreshold, etbPeriodSeconds);
reset(); reset();

View File

@ -561,6 +561,10 @@ TEST(etb, setpointLuaAdder) {
} }
TEST(etb, etbTpsSensor) { TEST(etb, etbTpsSensor) {
static engine_configuration_s localConfig;
// huh? how is this breaking the test? EngineTestHelper eth(TEST_ENGINE);
engineConfiguration = &localConfig;
// Throw some distinct values on the TPS sensors so we can identify that we're getting the correct one // Throw some distinct values on the TPS sensors so we can identify that we're getting the correct one
Sensor::setMockValue(SensorType::Tps1, 25.0f, true); Sensor::setMockValue(SensorType::Tps1, 25.0f, true);
Sensor::setMockValue(SensorType::Tps2, 75.0f, true); Sensor::setMockValue(SensorType::Tps2, 75.0f, true);
@ -586,7 +590,6 @@ TEST(etb, etbTpsSensor) {
// Test wastegate control // Test wastegate control
{ {
// EngineTestHelper eth(TEST_ENGINE);
EtbController etb; EtbController etb;
etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, true); etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, true);
EXPECT_EQ(etb.observePlant().Value, 33.0f); EXPECT_EQ(etb.observePlant().Value, 33.0f);
@ -594,11 +597,11 @@ TEST(etb, etbTpsSensor) {
// Test idle valve control // Test idle valve control
{ {
// EngineTestHelper eth(TEST_ENGINE);
EtbController etb; EtbController etb;
etb.init(ETB_IdleValve, nullptr, nullptr, nullptr, true); etb.init(ETB_IdleValve, nullptr, nullptr, nullptr, true);
EXPECT_EQ(etb.observePlant().Value, 66.0f); EXPECT_EQ(etb.observePlant().Value, 66.0f);
} }
engineConfiguration = nullptr;
} }
TEST(etb, setOutputInvalid) { TEST(etb, setOutputInvalid) {
@ -743,7 +746,9 @@ TEST(etb, setOutputLimpHome) {
} }
TEST(etb, closedLoopPid) { TEST(etb, closedLoopPid) {
static engine_configuration_s localConfig;
// huh? how is this breaking the test? EngineTestHelper eth(TEST_ENGINE); // huh? how is this breaking the test? EngineTestHelper eth(TEST_ENGINE);
engineConfiguration = &localConfig;
pid_s pid = {}; pid_s pid = {};
pid.pFactor = 5; pid.pFactor = 5;
pid.maxValue = 75; pid.maxValue = 75;
@ -770,6 +775,7 @@ TEST(etb, closedLoopPid) {
// Test PID limiting // Test PID limiting
EXPECT_FLOAT_EQ(etb.getClosedLoop(50, 70).value_or(-1), -60); EXPECT_FLOAT_EQ(etb.getClosedLoop(50, 70).value_or(-1), -60);
EXPECT_FLOAT_EQ(etb.getClosedLoop(50, 30).value_or(-1), 75); EXPECT_FLOAT_EQ(etb.getClosedLoop(50, 30).value_or(-1), 75);
engineConfiguration = nullptr;
} }
TEST(etb, openLoopThrottle) { TEST(etb, openLoopThrottle) {