Experimental Mode via steering wheel / onroad UI

Added toggle to enable or disable Experimental Mode from the steering wheel for Toyota/Lexus vehicles and the onroad UI for other makes.
This commit is contained in:
FrogAi
2024-01-12 22:39:30 -07:00
parent e29204d23a
commit b72f5748c4
12 changed files with 141 additions and 5 deletions

View File

@@ -63,15 +63,22 @@ class ConditionalExperimentalMode:
self.slowing_down_gmac = GenericMovingAverageCalculator()
def update(self, carState, frogpilotNavigation, modelData, mpc, radarState, standstill, v_ego):
# Set the value of "overridden"
if self.experimental_mode_via_press:
overridden = self.params_memory.get_int("CEStatus")
else:
overridden = 0
# Update Experimental Mode based on the current driving conditions
condition_met = self.check_conditions(carState, frogpilotNavigation, modelData, standstill, v_ego)
if (not self.experimental_mode and condition_met):
if (not self.experimental_mode and condition_met and overridden not in (1, 3)) or overridden in (2, 4):
self.experimental_mode = True
elif (self.experimental_mode and not condition_met):
elif (self.experimental_mode and not condition_met and overridden not in (2, 4)) or overridden in (1, 3):
self.experimental_mode = False
self.status_value = 0
# Update the onroad status bar
self.status_value = overridden if overridden in (1, 2, 3, 4) else self.status_value
if self.status_value != self.previous_status_value:
self.previous_status_value = self.status_value
self.params_memory.put_int("CEStatus", self.status_value)
@@ -188,6 +195,7 @@ class ConditionalExperimentalMode:
def update_frogpilot_params(self, is_metric, params):
self.curves = params.get_bool("CECurves")
self.curves_lead = params.get_bool("CECurvesLead")
self.experimental_mode_via_press = params.get_bool("ExperimentalModeViaPress")
self.limit = params.get_int("CESpeed") * (CV.KPH_TO_MS if is_metric else CV.MPH_TO_MS)
self.limit_lead = params.get_int("CESpeedLead") * (CV.KPH_TO_MS if is_metric else CV.MPH_TO_MS)
self.navigation = params.get_bool("CENavigation")