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:
Jason Wen
2023-02-20 20:48:41 -05:00
committed by GitHub
parent 36152df5e4
commit e1efbfe6eb
10 changed files with 19 additions and 2 deletions
+1
View File
@@ -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 = []
+1
View File
@@ -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 = []
+1
View File
@@ -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 = []
+1
View File
@@ -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 = []
+10 -2
View File
@@ -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
+1
View File
@@ -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 = []
+1
View File
@@ -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()
+1
View File
@@ -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 = []
+1
View File
@@ -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 = []
+1
View File
@@ -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 = []