From 492498f8d00fa761df40a8f823cccc05beb5562e Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 25 Nov 2020 04:27:24 -0800 Subject: [PATCH] Boost tolerance (#1986) * tolerate invalid closed loop config when in open loop mode * fix test --- firmware/controllers/actuators/boost_control.cpp | 6 ++++++ unit_tests/tests/test_boost.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/firmware/controllers/actuators/boost_control.cpp b/firmware/controllers/actuators/boost_control.cpp index 1b07502cdc..5c41624698 100644 --- a/firmware/controllers/actuators/boost_control.cpp +++ b/firmware/controllers/actuators/boost_control.cpp @@ -67,6 +67,12 @@ expected BoostController::observePlant() const { } expected BoostController::getSetpoint() const { + // If we're in open loop only mode, disregard any target computation. + // Open loop needs to work even in case of invalid closed loop config + if (engineConfiguration->boostType != CLOSED_LOOP) { + return 0; + } + float rpm = GET_RPM(); auto tps = Sensor::get(SensorType::DriverThrottleIntent); diff --git a/unit_tests/tests/test_boost.cpp b/unit_tests/tests/test_boost.cpp index 0ee8b94d96..20eb7bdfcc 100644 --- a/unit_tests/tests/test_boost.cpp +++ b/unit_tests/tests/test_boost.cpp @@ -15,6 +15,7 @@ TEST(BoostControl, Setpoint) { .WillRepeatedly([](float xRpm, float tps) { return tps * 2; }); WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + engineConfiguration->boostType = CLOSED_LOOP; BoostController bc; INJECT_ENGINE_REFERENCE(&bc);