tici: allow fan to run to 100% (#28203)

pull/27844/head^2
Adeeb Shihadeh 2 years ago committed by GitHub
parent 577374215b
commit 7e9acfd139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      selfdrive/thermald/fan_controller.py
  2. 20
      selfdrive/thermald/tests/test_fan_controller.py

@ -8,7 +8,7 @@ from selfdrive.controls.lib.pid import PIDController
class BaseFanController(ABC):
@abstractmethod
def update(self, max_cpu_temp: float, ignition: bool) -> int:
def update(self, cur_temp: float, ignition: bool) -> int:
pass
@ -18,19 +18,19 @@ class TiciFanController(BaseFanController):
cloudlog.info("Setting up TICI fan handler")
self.last_ignition = False
self.controller = PIDController(k_p=0, k_i=4e-3, k_f=1, neg_limit=-80, pos_limit=0, rate=(1 / DT_TRML))
self.controller = PIDController(k_p=0, k_i=4e-3, k_f=1, rate=(1 / DT_TRML))
def update(self, max_cpu_temp: float, ignition: bool) -> int:
self.controller.neg_limit = -(80 if ignition else 30)
def update(self, cur_temp: float, ignition: bool) -> int:
self.controller.neg_limit = -(100 if ignition else 30)
self.controller.pos_limit = -(30 if ignition else 0)
if ignition != self.last_ignition:
self.controller.reset()
error = 70 - max_cpu_temp
error = 70 - cur_temp
fan_pwr_out = -int(self.controller.update(
error=error,
feedforward=interp(max_cpu_temp, [60.0, 100.0], [0, -80])
feedforward=interp(cur_temp, [60.0, 100.0], [0, -100])
))
self.last_ignition = ignition

@ -14,43 +14,43 @@ def patched_controller(controller_class):
class TestFanController(unittest.TestCase):
def wind_up(self, controller, ignition=True):
for _ in range(1000):
controller.update(max_cpu_temp=100, ignition=ignition)
controller.update(100, ignition)
def wind_down(self, controller, ignition=False):
for _ in range(1000):
controller.update(max_cpu_temp=10, ignition=ignition)
controller.update(10, ignition)
@parameterized.expand(ALL_CONTROLLERS)
def test_hot_onroad(self, controller_class):
controller = patched_controller(controller_class)
self.wind_up(controller)
self.assertGreaterEqual(controller.update(max_cpu_temp=100, ignition=True), 70)
self.assertGreaterEqual(controller.update(100, True), 70)
@parameterized.expand(ALL_CONTROLLERS)
def test_offroad_limits(self, controller_class):
controller = patched_controller(controller_class)
self.wind_up(controller)
self.assertLessEqual(controller.update(max_cpu_temp=100, ignition=False), 30)
self.assertLessEqual(controller.update(100, False), 30)
@parameterized.expand(ALL_CONTROLLERS)
def test_no_fan_wear(self, controller_class):
controller = patched_controller(controller_class)
self.wind_down(controller)
self.assertEqual(controller.update(max_cpu_temp=10, ignition=False), 0)
self.assertEqual(controller.update(10, False), 0)
@parameterized.expand(ALL_CONTROLLERS)
def test_limited(self, controller_class):
controller = patched_controller(controller_class)
self.wind_up(controller, ignition=True)
self.assertGreaterEqual(controller.update(max_cpu_temp=100, ignition=True), 80)
self.wind_up(controller, True)
self.assertEqual(controller.update(100, True), 100)
@parameterized.expand(ALL_CONTROLLERS)
def test_windup_speed(self, controller_class):
controller = patched_controller(controller_class)
self.wind_down(controller, ignition=True)
self.wind_down(controller, True)
for _ in range(10):
controller.update(max_cpu_temp=90, ignition=True)
self.assertGreaterEqual(controller.update(max_cpu_temp=90, ignition=True), 60)
controller.update(90, True)
self.assertGreaterEqual(controller.update(90, True), 60)
if __name__ == "__main__":
unittest.main()

Loading…
Cancel
Save