check not is ready once

This commit is contained in:
Jason Wen
2024-09-14 22:31:41 -04:00
parent 6aaba7bda4
commit 53bed607bb
2 changed files with 11 additions and 7 deletions
@@ -41,6 +41,7 @@ class CustomStockLongitudinalControllerBase(ABC):
self.m_tsc = 0
self.is_ready = False
self.is_ready_prev = False
self.cruise_button = None
self.speed = 0
self.speed_steady = 0
@@ -106,6 +107,8 @@ class CustomStockLongitudinalControllerBase(ABC):
self.cruise_button = self.button_states[self.button_state](self)
self.is_ready_prev = self.is_ready
def update(self, CS: car.CarState, CC: car.CarControl) -> list[SendCan]:
can_sends = []
@@ -15,9 +15,9 @@ class ButtonStateBase(ABC):
self.timer = INACTIVE_TIMER
def __call__(self, controller) -> int | None:
if not controller.is_ready:
self.timer = INACTIVE_TIMER
if not controller.is_ready and controller.is_ready_prev:
controller.button_state = ButtonControlState.inactive
return None
return self.handle(controller)
@@ -30,11 +30,12 @@ class InactiveState(ButtonStateBase):
def handle(self, controller) -> None:
self.button_count = 0
if controller.is_ready:
if self.timer > 0:
self.timer -= 1
else:
controller.button_state = ButtonControlState.loading
if not controller.is_ready:
self.timer = INACTIVE_TIMER
elif self.timer > 0:
self.timer -= 1
else:
controller.button_state = ButtonControlState.loading
return None