Fix blended ACC

This commit is contained in:
MoreTore
2024-09-25 08:48:20 -05:00
parent f8398dc438
commit 1dd317bd9f
2 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -28,6 +28,8 @@ class CarController(CarControllerBase):
self.acc_filter = FirstOrderFilter(0.0, .1, DT_CTRL, initialized=False)
self.filtered_acc_last = 0
self.params = Params()
self.params_memory = Params("/dev/shm/params")
def update(self, CC, CS, now_nanos, frogpilot_toggles):
can_sends = []
@@ -86,7 +88,7 @@ class CarController(CarControllerBase):
raw_acc_output = max(-1000, min(raw_acc_output, 1000))
if self.params.get_bool("BlendedACC"):
if self.params.get_int("CEStatus"):
if self.params_memory.get_int("CEStatus"):
self.acc_filter.update_alpha(abs(raw_acc_output-self.filtered_acc_last)/1000)
filtered_acc_output = int(self.acc_filter.update(raw_acc_output))
else:
@@ -105,7 +107,7 @@ class CarController(CarControllerBase):
else:
raw_acc_output = (CC.actuators.accel * 240) + 2000
if self.params.get_bool("BlendedACC"):
if self.params.get_int("CEStatus"):
if self.params_memory.get_int("CEStatus"):
self.acc_filter.update_alpha(abs(raw_acc_output-self.filtered_acc_last)/1000)
filtered_acc_output = int(self.acc_filter.update(raw_acc_output))
else:
+2 -1
View File
@@ -97,6 +97,7 @@ class LongControl:
self.last_output_accel = 0.0
self.gain_step = 0.0001 # Step size for increasing/decreasing gain
self.params = Params()
self.params_memory = Params("/dev/shm/params")
gain = self.params.get_float("LongOutputGain")
self.auto_tune = self.params.get_bool("ExperimentalLongTune")
self.output_gain = gain if gain != 0.0 and self.auto_tune else 1.0 # Initial output gain
@@ -114,7 +115,7 @@ class LongControl:
should_stop, CS.brakePressed,
CS.cruiseState.standstill)
if self.params.get_bool("BlendedACC"):
experimental_mode = self.params.get_int("CEStatus") # 0 means expereimental mode is off
experimental_mode = self.params_memory.get_int("CEStatus") # 0 means expereimental mode is off
if experimental_mode and not self.experimental_mode_last:
self.reset()
self.experimental_mode_last = experimental_mode