Conditional Experimental Mode

Added toggles for "Conditional Experimental Mode".

Conditions based on road curvature, turn signals, speed, lead speed, navigation instructions, and stop signs/stop lights are all individually toggleable.
This commit is contained in:
FrogAi
2024-01-12 22:39:30 -07:00
parent c844593f66
commit ccf674762e
17 changed files with 378 additions and 12 deletions

View File

@@ -571,7 +571,7 @@ class Controls:
else:
self.state = State.enabled
self.current_alert_types.append(ET.ENABLE)
self.v_cruise_helper.initialize_v_cruise(CS, self.experimental_mode)
self.v_cruise_helper.initialize_v_cruise(CS, self.experimental_mode, self.conditional_experimental_mode)
# Check if openpilot is engaged and actuators are enabled
self.enabled = self.state in ENABLED_STATES
@@ -602,6 +602,10 @@ class Controls:
CC = car.CarControl.new_message()
CC.enabled = self.enabled
# Update Experimental Mode
if self.conditional_experimental_mode:
self.experimental_mode = self.sm['frogpilotLongitudinalPlan'].conditionalExperimental
# Gear Check
gear = car.CarState.GearShifter
driving_gear = CS.gearShifter not in (gear.neutral, gear.park, gear.reverse, gear.unknown)
@@ -918,7 +922,8 @@ class Controls:
def params_thread(self, evt):
while not evt.is_set():
self.is_metric = self.params.get_bool("IsMetric")
self.experimental_mode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl
if self.CP.openpilotLongitudinalControl and not self.conditional_experimental_mode:
self.experimental_mode = self.params.get_bool("ExperimentalMode")
if self.CP.notCar:
self.joystick_mode = self.params.get_bool("JoystickDebugMode")
time.sleep(0.1)
@@ -946,6 +951,7 @@ class Controls:
obj.update_frogpilot_params(self.params)
self.average_desired_curvature = self.params.get_bool("AverageCurvature")
self.conditional_experimental_mode = self.params.get_bool("ConditionalExperimental")
longitudinal_tune = self.params.get_bool("LongitudinalTune")
self.sport_plus = self.params.get_int("AccelerationProfile") == 3 and longitudinal_tune

View File

@@ -128,12 +128,12 @@ class VCruiseHelper:
self.button_timers[b.type.raw] = 1 if b.pressed else 0
self.button_change_states[b.type.raw] = {"standstill": CS.cruiseState.standstill, "enabled": enabled}
def initialize_v_cruise(self, CS, experimental_mode: bool) -> None:
def initialize_v_cruise(self, CS, experimental_mode: bool, conditional_experimental_mode) -> None:
# initializing is handled by the PCM
if self.CP.pcmCruise:
return
initial = V_CRUISE_INITIAL_EXPERIMENTAL_MODE if experimental_mode else V_CRUISE_INITIAL
initial = V_CRUISE_INITIAL_EXPERIMENTAL_MODE if experimental_mode and not conditional_experimental_mode else V_CRUISE_INITIAL
# 250kph or above probably means we never had a set speed
if any(b.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for b in CS.buttonEvents) and self.v_cruise_kph_last < 250:

View File

@@ -333,6 +333,7 @@ class LongitudinalMpc:
def update(self, radarstate, v_cruise, x, v, a, j, aggressive_acceleration, personality=log.LongitudinalPersonality.standard):
t_follow = get_T_FOLLOW(personality)
self.t_follow = t_follow
v_ego = self.x0[1]
self.status = radarstate.leadOne.status or radarstate.leadTwo.status