From c5a5d7f6eb0c2f3bf0b99d742afd247096a11418 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 27 Nov 2022 20:54:59 -0500 Subject: [PATCH] ETB duty cycle jitter #4833 weird, whatever for now :( --- firmware/controllers/actuators/electronic_throttle.cpp | 2 +- unit_tests/tests/actuators/test_etb.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 52131ff0a9..5b8507777b 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -208,7 +208,7 @@ bool EtbController::init(etb_function_e function, DcMotor *motor, pid_s *pidPara // Ignore 3% position error before complaining m_errorAccumulator.init(3.0f, etbPeriodSeconds); -// m_dutyIntegrator.init(engineConfiguration->etbDutyThreshold, etbPeriodSeconds); + m_dutyIntegrator.init(engineConfiguration->etbDutyThreshold, etbPeriodSeconds); reset(); diff --git a/unit_tests/tests/actuators/test_etb.cpp b/unit_tests/tests/actuators/test_etb.cpp index d58d973848..24fed5eab1 100644 --- a/unit_tests/tests/actuators/test_etb.cpp +++ b/unit_tests/tests/actuators/test_etb.cpp @@ -561,6 +561,10 @@ TEST(etb, setpointLuaAdder) { } 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 Sensor::setMockValue(SensorType::Tps1, 25.0f, true); Sensor::setMockValue(SensorType::Tps2, 75.0f, true); @@ -586,7 +590,6 @@ TEST(etb, etbTpsSensor) { // Test wastegate control { -// EngineTestHelper eth(TEST_ENGINE); EtbController etb; etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, true); EXPECT_EQ(etb.observePlant().Value, 33.0f); @@ -594,11 +597,11 @@ TEST(etb, etbTpsSensor) { // Test idle valve control { -// EngineTestHelper eth(TEST_ENGINE); EtbController etb; etb.init(ETB_IdleValve, nullptr, nullptr, nullptr, true); EXPECT_EQ(etb.observePlant().Value, 66.0f); } + engineConfiguration = nullptr; } TEST(etb, setOutputInvalid) { @@ -743,7 +746,9 @@ TEST(etb, setOutputLimpHome) { } TEST(etb, closedLoopPid) { + static engine_configuration_s localConfig; // huh? how is this breaking the test? EngineTestHelper eth(TEST_ENGINE); + engineConfiguration = &localConfig; pid_s pid = {}; pid.pFactor = 5; pid.maxValue = 75; @@ -770,6 +775,7 @@ TEST(etb, closedLoopPid) { // Test PID limiting EXPECT_FLOAT_EQ(etb.getClosedLoop(50, 70).value_or(-1), -60); EXPECT_FLOAT_EQ(etb.getClosedLoop(50, 30).value_or(-1), 75); + engineConfiguration = nullptr; } TEST(etb, openLoopThrottle) {