From c513de7c41d8b30085548828d28cfc371748a2e2 Mon Sep 17 00:00:00 2001 From: deanlee Date: Fri, 7 Jan 2022 16:43:12 +0800 Subject: [PATCH 1/2] check all valid in if statement --- selfdrive/controls/controlsd.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index d193d27288a0e1..fe86dca8d0a216 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -366,8 +366,7 @@ def data_sample(self): self.sm.update(0) - all_valid = CS.canValid and self.sm.all_alive_and_valid() - if not self.initialized and (all_valid or self.sm.frame * DT_CTRL > 3.5 or SIMULATION): + if not self.initialized and ((CS.canValid and self.sm.all_alive_and_valid()) or self.sm.frame * DT_CTRL > 3.5 or SIMULATION): if not self.read_only: self.CI.init(self.CP, self.can_sock, self.pm.sock['sendcan']) self.initialized = True From b9ff8ed9ed1858825e0bedc0f7fff746489a4286 Mon Sep 17 00:00:00 2001 From: deanlee Date: Fri, 7 Jan 2022 19:19:59 +0800 Subject: [PATCH 2/2] apply review --- selfdrive/controls/controlsd.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index fe86dca8d0a216..9a0e352850126a 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -366,11 +366,13 @@ def data_sample(self): self.sm.update(0) - if not self.initialized and ((CS.canValid and self.sm.all_alive_and_valid()) or self.sm.frame * DT_CTRL > 3.5 or SIMULATION): - if not self.read_only: - self.CI.init(self.CP, self.can_sock, self.pm.sock['sendcan']) - self.initialized = True - Params().put_bool("ControlsReady", True) + if not self.initialized: + all_valid = CS.canValid and self.sm.all_alive_and_valid() + if all_valid or self.sm.frame * DT_CTRL > 3.5 or SIMULATION: + if not self.read_only: + self.CI.init(self.CP, self.can_sock, self.pm.sock['sendcan']) + self.initialized = True + Params().put_bool("ControlsReady", True) # Check for CAN timeout if not can_strs: