mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-11 05:12:06 +08:00
CarInterface: update params (#45)
* CarInterface: update params * check exp mode every frame * Revert "check exp mode every frame" This reverts commit a7d174a1a0cb367487e1b7fc9d1e6b651233860c. * only immediately check exp mode when allowed
This commit is contained in:
@@ -93,6 +93,7 @@ class CarInterface(CarInterfaceBase):
|
||||
|
||||
def _update(self, c):
|
||||
ret = self.CS.update(self.cp, self.cp_cam)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
|
||||
|
||||
@@ -251,6 +251,7 @@ class CarInterface(CarInterfaceBase):
|
||||
# returns a car.CarState
|
||||
def _update(self, c):
|
||||
ret = self.CS.update(self.cp, self.cp_cam, self.cp_loopback)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
|
||||
|
||||
@@ -311,6 +311,7 @@ class CarInterface(CarInterfaceBase):
|
||||
# returns a car.CarState
|
||||
def _update(self, c):
|
||||
ret = self.CS.update(self.cp, self.cp_cam, self.cp_body)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ class CarInterface(CarInterfaceBase):
|
||||
|
||||
def _update(self, c):
|
||||
ret = self.CS.update(self.cp, self.cp_cam)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ class CarInterfaceBase(ABC):
|
||||
self.mads_event_lock = True
|
||||
self.gap_button_counter = 0
|
||||
self.experimental_mode_hold = False
|
||||
self.experimental_mode = self.param_s.get_bool("ExperimentalMode")
|
||||
self._frame = 0
|
||||
|
||||
@staticmethod
|
||||
def get_pid_accel_limits(CP, current_speed, cruise_speed):
|
||||
@@ -419,14 +421,14 @@ class CarInterfaceBase(ABC):
|
||||
def toggle_exp_mode(self, gap_pressed):
|
||||
if not self.CP.openpilotLongitudinalControl:
|
||||
return None
|
||||
experimental_mode = self.param_s.get_bool("ExperimentalMode")
|
||||
if gap_pressed:
|
||||
if not self.experimental_mode_hold:
|
||||
self.gap_button_counter += 1
|
||||
if self.gap_button_counter > 50:
|
||||
self.gap_button_counter = 0
|
||||
self.experimental_mode_hold = True
|
||||
self.param_s.put_bool("ExperimentalMode", not experimental_mode)
|
||||
self.experimental_mode = self.param_s.get_bool("ExperimentalMode")
|
||||
self.param_s.put_bool("ExperimentalMode", not self.experimental_mode)
|
||||
else:
|
||||
self.gap_button_counter = 0
|
||||
self.experimental_mode_hold = False
|
||||
@@ -494,6 +496,12 @@ class CarInterfaceBase(ABC):
|
||||
|
||||
return events, cs_out
|
||||
|
||||
def sp_update_params(self):
|
||||
self._frame += 1
|
||||
if self._frame % 300 == 0:
|
||||
self._frame = 0
|
||||
self.experimental_mode = self.param_s.get_bool("ExperimentalMode")
|
||||
|
||||
class RadarInterfaceBase(ABC):
|
||||
def __init__(self, CP):
|
||||
self.rcp = None
|
||||
|
||||
@@ -57,6 +57,7 @@ class CarInterface(CarInterfaceBase):
|
||||
# returns a car.CarState
|
||||
def _update(self, c):
|
||||
ret = self.CS.update(self.cp, self.cp_cam)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ class CarInterface(CarInterfaceBase):
|
||||
# returns a car.CarState
|
||||
def _update(self, c):
|
||||
ret = self.CS.update(self.cp, self.cp_adas, self.cp_cam)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
#be = car.CarState.ButtonEvent.new_message()
|
||||
|
||||
@@ -111,6 +111,7 @@ class CarInterface(CarInterfaceBase):
|
||||
def _update(self, c):
|
||||
|
||||
ret = self.CS.update(self.cp, self.cp_cam, self.cp_body)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
|
||||
|
||||
@@ -244,6 +244,7 @@ class CarInterface(CarInterfaceBase):
|
||||
# returns a car.CarState
|
||||
def _update(self, c):
|
||||
ret = self.CS.update(self.cp, self.cp_cam)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
|
||||
|
||||
@@ -223,6 +223,7 @@ class CarInterface(CarInterfaceBase):
|
||||
# returns a car.CarState
|
||||
def _update(self, c):
|
||||
ret = self.CS.update(self.cp, self.cp_cam, self.cp_ext, self.CP.transmissionType)
|
||||
self.sp_update_params()
|
||||
|
||||
buttonEvents = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user