mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-19 22:23:44 +08:00
car: Move all live param checks to ParamManger (#378)
car: Move all live param checks to ParamManger
This commit is contained in:
@@ -30,9 +30,6 @@ class CarController(CarControllerBase):
|
||||
|
||||
self.sm = messaging.SubMaster(['longitudinalPlanSP'])
|
||||
self.param_s = Params()
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.speed_limit_control_enabled = False
|
||||
self.last_speed_limit_sign_tap = False
|
||||
self.last_speed_limit_sign_tap_prev = False
|
||||
self.speed_limit = 0.
|
||||
self.speed_limit_offset = 0
|
||||
@@ -72,23 +69,19 @@ class CarController(CarControllerBase):
|
||||
self.v_tsc = self.sm['longitudinalPlanSP'].visionTurnSpeed
|
||||
self.m_tsc = self.sm['longitudinalPlanSP'].turnSpeed
|
||||
|
||||
if self.frame % 200 == 0:
|
||||
self.speed_limit_control_enabled = self.param_s.get_bool("EnableSlc")
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.last_speed_limit_sign_tap = self.param_s.get_bool("LastSpeedLimitSignTap")
|
||||
self.v_cruise_min = FCA_V_CRUISE_MIN[self.is_metric] * (CV.KPH_TO_MPH if not self.is_metric else 1)
|
||||
self.v_cruise_min = FCA_V_CRUISE_MIN[CS.params_list.is_metric] * (CV.KPH_TO_MPH if not CS.params_list.is_metric else 1)
|
||||
|
||||
can_sends = []
|
||||
|
||||
if not self.CP.pcmCruiseSpeed:
|
||||
if not self.last_speed_limit_sign_tap_prev and self.last_speed_limit_sign_tap:
|
||||
if not self.last_speed_limit_sign_tap_prev and CS.params_list.last_speed_limit_sign_tap:
|
||||
self.sl_force_active_timer = self.frame
|
||||
self.param_s.put_bool_nonblocking("LastSpeedLimitSignTap", False)
|
||||
self.last_speed_limit_sign_tap_prev = self.last_speed_limit_sign_tap
|
||||
self.last_speed_limit_sign_tap_prev = CS.params_list.last_speed_limit_sign_tap
|
||||
|
||||
sl_force_active = self.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not self.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (self.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
sl_force_active = CS.params_list.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not CS.params_list.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (CS.params_list.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
slc_active = not sl_inactive and not sl_temp_inactive
|
||||
|
||||
self.slc_active_stock = slc_active
|
||||
|
||||
@@ -132,9 +132,6 @@ class CarController(CarControllerBase):
|
||||
|
||||
self.sm = messaging.SubMaster(['longitudinalPlanSP'])
|
||||
self.param_s = Params()
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.speed_limit_control_enabled = False
|
||||
self.last_speed_limit_sign_tap = False
|
||||
self.last_speed_limit_sign_tap_prev = False
|
||||
self.speed_limit = 0.
|
||||
self.speed_limit_offset = 0
|
||||
@@ -173,11 +170,7 @@ class CarController(CarControllerBase):
|
||||
self.v_tsc = self.sm['longitudinalPlanSP'].visionTurnSpeed
|
||||
self.m_tsc = self.sm['longitudinalPlanSP'].turnSpeed
|
||||
|
||||
if self.frame % 200 == 0:
|
||||
self.speed_limit_control_enabled = self.param_s.get_bool("EnableSlc")
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.last_speed_limit_sign_tap = self.param_s.get_bool("LastSpeedLimitSignTap")
|
||||
self.v_cruise_min = HONDA_V_CRUISE_MIN[self.is_metric] * (CV.KPH_TO_MPH if not self.is_metric else 1)
|
||||
self.v_cruise_min = HONDA_V_CRUISE_MIN[CS.params_list.is_metric] * (CV.KPH_TO_MPH if not CS.params_list.is_metric else 1)
|
||||
|
||||
actuators = CC.actuators
|
||||
hud_control = CC.hudControl
|
||||
@@ -213,14 +206,14 @@ class CarController(CarControllerBase):
|
||||
self.params.STEER_LOOKUP_BP, self.params.STEER_LOOKUP_V))
|
||||
|
||||
if not self.CP.pcmCruiseSpeed:
|
||||
if not self.last_speed_limit_sign_tap_prev and self.last_speed_limit_sign_tap:
|
||||
if not self.last_speed_limit_sign_tap_prev and CS.params_list.last_speed_limit_sign_tap:
|
||||
self.sl_force_active_timer = self.frame
|
||||
self.param_s.put_bool_nonblocking("LastSpeedLimitSignTap", False)
|
||||
self.last_speed_limit_sign_tap_prev = self.last_speed_limit_sign_tap
|
||||
self.last_speed_limit_sign_tap_prev = CS.params_list.last_speed_limit_sign_tap
|
||||
|
||||
sl_force_active = self.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not self.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (self.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
sl_force_active = CS.params_list.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not CS.params_list.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (CS.params_list.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
slc_active = not sl_inactive and not sl_temp_inactive
|
||||
|
||||
self.slc_active_stock = slc_active
|
||||
@@ -432,8 +425,8 @@ class CarController(CarControllerBase):
|
||||
return min(target_speed_kph, curve_speed)
|
||||
|
||||
def get_button_control(self, CS, final_speed, v_cruise_kph_prev):
|
||||
self.init_speed = round(min(final_speed, v_cruise_kph_prev) * (CV.KPH_TO_MPH if not self.is_metric else 1))
|
||||
self.v_set_dis = round(CS.out.cruiseState.speed * (CV.MS_TO_MPH if not self.is_metric else CV.MS_TO_KPH))
|
||||
self.init_speed = round(min(final_speed, v_cruise_kph_prev) * (CV.KPH_TO_MPH if not CS.params_list.is_metric else 1))
|
||||
self.v_set_dis = round(CS.out.cruiseState.speed * (CV.MS_TO_MPH if not CS.params_list.is_metric else CV.MS_TO_KPH))
|
||||
cruise_button = self.get_button_type(self.button_type)
|
||||
return cruise_button
|
||||
|
||||
|
||||
@@ -72,9 +72,6 @@ class CarController(CarControllerBase):
|
||||
self.sm = messaging.SubMaster(sub_services)
|
||||
|
||||
self.param_s = Params()
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.speed_limit_control_enabled = False
|
||||
self.last_speed_limit_sign_tap = False
|
||||
self.last_speed_limit_sign_tap_prev = False
|
||||
self.speed_limit = 0.
|
||||
self.speed_limit_offset = 0
|
||||
@@ -127,11 +124,7 @@ class CarController(CarControllerBase):
|
||||
self.v_tsc = self.sm['longitudinalPlanSP'].visionTurnSpeed
|
||||
self.m_tsc = self.sm['longitudinalPlanSP'].turnSpeed
|
||||
|
||||
if self.frame % 200 == 0:
|
||||
self.speed_limit_control_enabled = self.param_s.get_bool("EnableSlc")
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.last_speed_limit_sign_tap = self.param_s.get_bool("LastSpeedLimitSignTap")
|
||||
self.v_cruise_min = HYUNDAI_V_CRUISE_MIN[self.is_metric] * (CV.KPH_TO_MPH if not self.is_metric else 1)
|
||||
self.v_cruise_min = HYUNDAI_V_CRUISE_MIN[CS.params_list.is_metric] * (CV.KPH_TO_MPH if not CS.params_list.is_metric else 1)
|
||||
|
||||
actuators = CC.actuators
|
||||
hud_control = CC.hudControl
|
||||
@@ -175,14 +168,14 @@ class CarController(CarControllerBase):
|
||||
blinking_icon = (self.frame - self.disengage_blink) * DT_CTRL < 1.0 if self.lat_disengage_init else False
|
||||
|
||||
if not self.CP.pcmCruiseSpeed:
|
||||
if not self.last_speed_limit_sign_tap_prev and self.last_speed_limit_sign_tap:
|
||||
if not self.last_speed_limit_sign_tap_prev and CS.params_list.last_speed_limit_sign_tap:
|
||||
self.sl_force_active_timer = self.frame
|
||||
self.param_s.put_bool_nonblocking("LastSpeedLimitSignTap", False)
|
||||
self.last_speed_limit_sign_tap_prev = self.last_speed_limit_sign_tap
|
||||
self.last_speed_limit_sign_tap_prev = CS.params_list.last_speed_limit_sign_tap
|
||||
|
||||
sl_force_active = self.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not self.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (self.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
sl_force_active = CS.params_list.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not CS.params_list.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (CS.params_list.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
slc_active = not sl_inactive and not sl_temp_inactive
|
||||
|
||||
self.slc_active_stock = slc_active
|
||||
@@ -433,8 +426,8 @@ class CarController(CarControllerBase):
|
||||
return min(target_speed_kph, curve_speed)
|
||||
|
||||
def get_button_control(self, CS, final_speed, v_cruise_kph_prev):
|
||||
self.init_speed = round(min(final_speed, v_cruise_kph_prev) * (CV.KPH_TO_MPH if not self.is_metric else 1))
|
||||
self.v_set_dis = round(CS.out.cruiseState.speed * (CV.MS_TO_MPH if not self.is_metric else CV.MS_TO_KPH))
|
||||
self.init_speed = round(min(final_speed, v_cruise_kph_prev) * (CV.KPH_TO_MPH if not CS.params_list.is_metric else 1))
|
||||
self.v_set_dis = round(CS.out.cruiseState.speed * (CV.MS_TO_MPH if not CS.params_list.is_metric else CV.MS_TO_KPH))
|
||||
cruise_button = self.get_button_type(self.button_type)
|
||||
return cruise_button
|
||||
|
||||
|
||||
@@ -240,13 +240,10 @@ class CarInterfaceBase(ABC):
|
||||
self.mads_ndlob = self.enable_mads and not self.mads_disengage_lateral_on_brake
|
||||
self.gear_warning = 0
|
||||
self.cruise_cancelled_btn = True
|
||||
self.acc_mads_combo = self.param_s.get_bool("AccMadsCombo")
|
||||
self.prev_acc_mads_combo = False
|
||||
self.mads_event_lock = True
|
||||
self.gap_button_counter = 0
|
||||
self.experimental_mode_hold = False
|
||||
self.mads_main_toggle = self.param_s.get_bool("MadsCruiseMain")
|
||||
self.lkas_toggle = self.param_s.get_bool("LkasToggle")
|
||||
self.last_mads_init = 0.
|
||||
self.madsEnabledInit = False
|
||||
self.madsEnabledInitPrev = False
|
||||
@@ -551,7 +548,7 @@ class CarInterfaceBase(ABC):
|
||||
return v_cruise != V_CRUISE_UNSET
|
||||
|
||||
def get_acc_mads(self, cruiseState_enabled, acc_enabled, mads_enabled):
|
||||
if self.acc_mads_combo:
|
||||
if self.CS.params_list.acc_mads_combo:
|
||||
if not self.prev_acc_mads_combo and (cruiseState_enabled or acc_enabled):
|
||||
mads_enabled = True
|
||||
self.prev_acc_mads_combo = (cruiseState_enabled or acc_enabled)
|
||||
@@ -591,7 +588,7 @@ class CarInterfaceBase(ABC):
|
||||
def get_sp_cruise_main_state(self, cs_out, CS):
|
||||
if not CS.control_initialized:
|
||||
mads_enabled = False
|
||||
elif not self.mads_main_toggle:
|
||||
elif not self.CS.params_list.mads_main_toggle:
|
||||
mads_enabled = False
|
||||
else:
|
||||
mads_enabled = cs_out.cruiseState.available
|
||||
@@ -603,7 +600,7 @@ class CarInterfaceBase(ABC):
|
||||
self.madsEnabledInit = False
|
||||
self.madsEnabledInitPrev = False
|
||||
return False
|
||||
if not self.mads_main_toggle or self.prev_acc_mads_combo:
|
||||
if not self.CS.params_list.mads_main_toggle or self.prev_acc_mads_combo:
|
||||
return CS.madsEnabled
|
||||
if not self.madsEnabledInit and CS.madsEnabled:
|
||||
self.madsEnabledInit = True
|
||||
@@ -762,7 +759,6 @@ class CarStateBase(ABC):
|
||||
self.cluster_speed_hyst_gap = 0.0
|
||||
self.cluster_min_speed = 0.0 # min speed before dropping to 0
|
||||
|
||||
self.param_s = Params()
|
||||
self.accEnabled = False
|
||||
self.madsEnabled = False
|
||||
self.disengageByBrake = False
|
||||
|
||||
@@ -24,9 +24,6 @@ class CarController(CarControllerBase):
|
||||
|
||||
self.sm = messaging.SubMaster(['longitudinalPlanSP'])
|
||||
self.param_s = Params()
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.speed_limit_control_enabled = False
|
||||
self.last_speed_limit_sign_tap = False
|
||||
self.last_speed_limit_sign_tap_prev = False
|
||||
self.speed_limit = 0.
|
||||
self.speed_limit_offset = 0
|
||||
@@ -65,23 +62,19 @@ class CarController(CarControllerBase):
|
||||
self.v_tsc = self.sm['longitudinalPlanSP'].visionTurnSpeed
|
||||
self.m_tsc = self.sm['longitudinalPlanSP'].turnSpeed
|
||||
|
||||
if self.frame % 200 == 0:
|
||||
self.speed_limit_control_enabled = self.param_s.get_bool("EnableSlc")
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.last_speed_limit_sign_tap = self.param_s.get_bool("LastSpeedLimitSignTap")
|
||||
self.v_cruise_min = MAZDA_V_CRUISE_MIN[self.is_metric] * (CV.KPH_TO_MPH if not self.is_metric else 1)
|
||||
self.v_cruise_min = MAZDA_V_CRUISE_MIN[CS.params_list.is_metric] * (CV.KPH_TO_MPH if not CS.params_list.is_metric else 1)
|
||||
|
||||
can_sends = []
|
||||
|
||||
if not self.CP.pcmCruiseSpeed:
|
||||
if not self.last_speed_limit_sign_tap_prev and self.last_speed_limit_sign_tap:
|
||||
if not self.last_speed_limit_sign_tap_prev and CS.params_list.last_speed_limit_sign_tap:
|
||||
self.sl_force_active_timer = self.frame
|
||||
self.param_s.put_bool_nonblocking("LastSpeedLimitSignTap", False)
|
||||
self.last_speed_limit_sign_tap_prev = self.last_speed_limit_sign_tap
|
||||
self.last_speed_limit_sign_tap_prev = CS.params_list.last_speed_limit_sign_tap
|
||||
|
||||
sl_force_active = self.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not self.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (self.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
sl_force_active = CS.params_list.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not CS.params_list.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (CS.params_list.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
slc_active = not sl_inactive and not sl_temp_inactive
|
||||
|
||||
self.slc_active_stock = slc_active
|
||||
@@ -229,8 +222,8 @@ class CarController(CarControllerBase):
|
||||
return min(target_speed_kph, curve_speed)
|
||||
|
||||
def get_button_control(self, CS, final_speed, v_cruise_kph_prev):
|
||||
self.init_speed = round(min(final_speed, v_cruise_kph_prev) * (CV.KPH_TO_MPH if not self.is_metric else 1))
|
||||
self.v_set_dis = round(CS.out.cruiseState.speed * (CV.MS_TO_MPH if not self.is_metric else CV.MS_TO_KPH))
|
||||
self.init_speed = round(min(final_speed, v_cruise_kph_prev) * (CV.KPH_TO_MPH if not CS.params_list.is_metric else 1))
|
||||
self.v_set_dis = round(CS.out.cruiseState.speed * (CV.MS_TO_MPH if not CS.params_list.is_metric else CV.MS_TO_KPH))
|
||||
cruise_button = self.get_button_type(self.button_type)
|
||||
return cruise_button
|
||||
|
||||
|
||||
@@ -6,11 +6,21 @@ from openpilot.common.params import Params
|
||||
class ParamManager:
|
||||
def __init__(self):
|
||||
self._params_list: SimpleNamespace = self._create_namespace({
|
||||
"acc_mads_combo": False,
|
||||
"below_speed_pause": False,
|
||||
"experimental_mode": False,
|
||||
"is_metric": False,
|
||||
"last_speed_limit_sign_tap": False,
|
||||
"mads_main_toggle": False,
|
||||
"pause_lateral_speed": 0,
|
||||
"reverse_acc_change": False,
|
||||
"reverse_dm_cam": False,
|
||||
"speed_limit_control_enabled": False,
|
||||
"subaru_manual_parking_brake": False,
|
||||
"toyota_auto_lock_by_speed": False,
|
||||
"toyota_auto_unlock_by_shifter": False,
|
||||
"toyota_lkas_toggle": False,
|
||||
"toyota_sng_hack": False,
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
@@ -22,9 +32,19 @@ class ParamManager:
|
||||
|
||||
def update(self, params: Params) -> None:
|
||||
self._params_list = self._create_namespace({
|
||||
"acc_mads_combo": params.get_bool("AccMadsCombo"),
|
||||
"below_speed_pause": params.get_bool("BelowSpeedPause"),
|
||||
"experimental_mode": params.get_bool("ExperimentalMode"),
|
||||
"is_metric": params.get_bool("IsMetric"),
|
||||
"last_speed_limit_sign_tap": params.get_bool("LastSpeedLimitSignTap"),
|
||||
"mads_main_toggle": params.get_bool("MadsCruiseMain"),
|
||||
"pause_lateral_speed": int(params.get("PauseLateralSpeed", encoding="utf8")),
|
||||
"reverse_acc_change": params.get_bool("ReverseAccChange"),
|
||||
"reverse_dm_cam": params.get_bool("ReverseDmCam"),
|
||||
"speed_limit_control_enabled": params.get_bool("EnableSlc"),
|
||||
"subaru_manual_parking_brake": params.get_bool("SubaruManualParkingBrakeSng"),
|
||||
"toyota_auto_lock_by_speed": params.get_bool("ToyotaAutoLockBySpeed"),
|
||||
"toyota_auto_unlock_by_shifter": params.get_bool("ToyotaAutoUnlockByShifter"),
|
||||
"toyota_lkas_toggle": params.get_bool("LkasToggle"),
|
||||
"toyota_sng_hack": params.get_bool("ToyotaSnG"),
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from cereal import car
|
||||
from openpilot.common.numpy_fast import clip, interp
|
||||
from openpilot.common.params import Params
|
||||
from opendbc.can.packer import CANPacker
|
||||
from openpilot.selfdrive.car import apply_driver_steer_torque_limits, common_fault_avoidance
|
||||
from openpilot.selfdrive.car.interfaces import CarControllerBase
|
||||
@@ -25,12 +24,9 @@ class CarController(CarControllerBase):
|
||||
self.cruise_button_prev = 0
|
||||
self.steer_rate_counter = 0
|
||||
|
||||
self.param_s = Params()
|
||||
|
||||
self.subaru_sng = False
|
||||
if CP.spFlags & SubaruFlagsSP.SP_SUBARU_SNG:
|
||||
self.subaru_sng = True
|
||||
self.manual_parking_brake = self.param_s.get_bool("SubaruManualParkingBrakeSng")
|
||||
self.prev_close_distance = 0
|
||||
self.prev_standstill = False
|
||||
self.standstill_start = 0
|
||||
@@ -47,9 +43,6 @@ class CarController(CarControllerBase):
|
||||
hud_control = CC.hudControl
|
||||
pcm_cancel_cmd = CC.cruiseControl.cancel
|
||||
|
||||
if self.frame % 250 == 0 and self.subaru_sng:
|
||||
self.manual_parking_brake = self.param_s.get_bool("SubaruManualParkingBrakeSng")
|
||||
|
||||
can_sends = []
|
||||
|
||||
# *** steering ***
|
||||
@@ -191,7 +184,7 @@ class CarController(CarControllerBase):
|
||||
and CS.close_distance > self.prev_close_distance): # distance with lead car is increasing
|
||||
self.sng_acc_resume = True
|
||||
elif not (self.CP.flags & (SubaruFlags.GLOBAL_GEN2 | SubaruFlags.HYBRID)):
|
||||
if self.manual_parking_brake:
|
||||
if CS.params_list.subaru_manual_parking_brake and self.subaru_sng:
|
||||
# Send brake message with non-zero speed in standstill to avoid non-EPB ACC disengage
|
||||
if (CC.enabled # ACC active
|
||||
and CS.car_follow == 1 # lead car
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from cereal import car
|
||||
from common.conversions import Conversions as CV
|
||||
from openpilot.common.numpy_fast import clip, interp
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.selfdrive.car import apply_meas_steer_torque_limits, apply_std_steer_angle_limits, common_fault_avoidance, \
|
||||
create_gas_interceptor_command, make_can_msg
|
||||
from openpilot.selfdrive.car.interfaces import CarControllerBase
|
||||
@@ -52,27 +51,16 @@ class CarController(CarControllerBase):
|
||||
self.gas = 0
|
||||
self.accel = 0
|
||||
|
||||
self.param_s = Params()
|
||||
self._is_metric = self.param_s.get_bool("IsMetric")
|
||||
self._reverse_acc_change = self.param_s.get_bool("ReverseAccChange")
|
||||
self._sng_hack = self.param_s.get_bool("ToyotaSnG")
|
||||
|
||||
self.left_blindspot_debug_enabled = False
|
||||
self.right_blindspot_debug_enabled = False
|
||||
self.last_blindspot_frame = 0
|
||||
|
||||
self._auto_lock_by_speed = self.param_s.get_bool("ToyotaAutoLockBySpeed")
|
||||
self._auto_unlock_by_shifter = self.param_s.get_bool("ToyotaAutoUnlockByShifter")
|
||||
self._auto_lock_speed = 10 * (CV.KPH_TO_MS if self._is_metric else CV.MPH_TO_MS)
|
||||
self._auto_lock_speed = 0.0
|
||||
self._auto_lock_once = False
|
||||
self._gear_prev = GearShifter.park
|
||||
|
||||
def update(self, CC, CS, now_nanos):
|
||||
if self.frame % 200 == 0:
|
||||
self._is_metric = self.param_s.get_bool("IsMetric")
|
||||
self._auto_lock_by_speed = self.param_s.get_bool("ToyotaAutoLockBySpeed")
|
||||
self._auto_unlock_by_shifter = self.param_s.get_bool("ToyotaAutoUnlockByShifter")
|
||||
self._auto_lock_speed = 10 * (CV.KPH_TO_MS if self._is_metric else CV.MPH_TO_MS)
|
||||
self._auto_lock_speed = 10 * (CV.KPH_TO_MS if CS.params_list.is_metric else CV.MPH_TO_MS)
|
||||
|
||||
actuators = CC.actuators
|
||||
hud_control = CC.hudControl
|
||||
@@ -88,11 +76,11 @@ class CarController(CarControllerBase):
|
||||
gear = CS.out.gearShifter
|
||||
if not CS.out.doorOpen:
|
||||
if gear == GearShifter.park and self._gear_prev != gear:
|
||||
if self._auto_unlock_by_shifter:
|
||||
if CS.params_list.toyota_auto_unlock_by_shifter:
|
||||
can_sends.append(make_can_msg(0x750, UNLOCK_CMD, 0))
|
||||
self._auto_lock_once = False
|
||||
elif gear == GearShifter.drive and not self._auto_lock_once and CS.out.vEgo >= self._auto_lock_speed:
|
||||
if self._auto_lock_by_speed:
|
||||
if CS.params_list.toyota_auto_lock_by_speed:
|
||||
can_sends.append(make_can_msg(0x750, LOCK_CMD, 0))
|
||||
self._auto_lock_once = True
|
||||
self._gear_prev = gear
|
||||
@@ -173,7 +161,7 @@ class CarController(CarControllerBase):
|
||||
|
||||
# on entering standstill, send standstill request
|
||||
if CS.out.standstill and not self.last_standstill and (self.CP.carFingerprint not in NO_STOP_TIMER_CAR or self.CP.enableGasInterceptorDEPRECATED) and \
|
||||
not self._sng_hack:
|
||||
not CS.params_list.toyota_sng_hack:
|
||||
self.standstill_req = True
|
||||
if CS.pcm_acc_status != 8:
|
||||
# pcm entered standstill or it's disabled
|
||||
@@ -188,7 +176,7 @@ class CarController(CarControllerBase):
|
||||
# we can spam can to cancel the system even if we are using lat only control
|
||||
if (self.frame % 3 == 0 and self.CP.openpilotLongitudinalControl) or pcm_cancel_cmd:
|
||||
lead = hud_control.leadVisible or CS.out.vEgo < 12. # at low speed we always assume the lead is present so ACC can be engaged
|
||||
reverse_acc = 2 if self._reverse_acc_change else 1
|
||||
reverse_acc = 2 if CS.params_list.reverse_acc_change else 1
|
||||
|
||||
# Press distance button until we are at the correct bar length. Only change while enabled to avoid skipping startup popup
|
||||
if self.frame % 6 == 0 and self.CP.openpilotLongitudinalControl:
|
||||
|
||||
@@ -220,7 +220,7 @@ class CarInterface(CarInterfaceBase):
|
||||
if self.enable_mads:
|
||||
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
|
||||
self.CS.madsEnabled = True
|
||||
if self.lkas_toggle:
|
||||
if self.CS.params_list.lkas_toggle:
|
||||
if self.CS.lta_status_active:
|
||||
if (self.CS.prev_lkas_enabled == 16 and self.CS.lkas_enabled == 0) or \
|
||||
(self.CS.prev_lkas_enabled == 0 and self.CS.lkas_enabled == 16):
|
||||
|
||||
@@ -34,9 +34,6 @@ class CarController(CarControllerBase):
|
||||
|
||||
self.sm = messaging.SubMaster(['longitudinalPlanSP'])
|
||||
self.param_s = Params()
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.speed_limit_control_enabled = False
|
||||
self.last_speed_limit_sign_tap = False
|
||||
self.last_speed_limit_sign_tap_prev = False
|
||||
self.speed_limit = 0.
|
||||
self.speed_limit_offset = 0
|
||||
@@ -79,24 +76,20 @@ class CarController(CarControllerBase):
|
||||
self.v_tsc = self.sm['longitudinalPlanSP'].visionTurnSpeed
|
||||
self.m_tsc = self.sm['longitudinalPlanSP'].turnSpeed
|
||||
|
||||
if self.frame % 200 == 0:
|
||||
self.speed_limit_control_enabled = self.param_s.get_bool("EnableSlc")
|
||||
self.is_metric = self.param_s.get_bool("IsMetric")
|
||||
self.last_speed_limit_sign_tap = self.param_s.get_bool("LastSpeedLimitSignTap")
|
||||
self.v_cruise_min = VOLKSWAGEN_V_CRUISE_MIN[self.is_metric] * (CV.KPH_TO_MPH if not self.is_metric else 1)
|
||||
self.v_cruise_min = VOLKSWAGEN_V_CRUISE_MIN[CS.params_list.is_metric] * (CV.KPH_TO_MPH if not CS.params_list.is_metric else 1)
|
||||
actuators = CC.actuators
|
||||
hud_control = CC.hudControl
|
||||
can_sends = []
|
||||
|
||||
if not self.CP.pcmCruiseSpeed:
|
||||
if not self.last_speed_limit_sign_tap_prev and self.last_speed_limit_sign_tap:
|
||||
if not self.last_speed_limit_sign_tap_prev and CS.params_list.last_speed_limit_sign_tap:
|
||||
self.sl_force_active_timer = self.frame
|
||||
self.param_s.put_bool_nonblocking("LastSpeedLimitSignTap", False)
|
||||
self.last_speed_limit_sign_tap_prev = self.last_speed_limit_sign_tap
|
||||
self.last_speed_limit_sign_tap_prev = CS.params_list.last_speed_limit_sign_tap
|
||||
|
||||
sl_force_active = self.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not self.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (self.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
sl_force_active = CS.params_list.speed_limit_control_enabled and (self.frame < (self.sl_force_active_timer * DT_CTRL + 2.0))
|
||||
sl_inactive = not sl_force_active and (not CS.params_list.speed_limit_control_enabled or (True if self.slc_state == 0 else False))
|
||||
sl_temp_inactive = not sl_force_active and (CS.params_list.speed_limit_control_enabled and (True if self.slc_state == 1 else False))
|
||||
slc_active = not sl_inactive and not sl_temp_inactive
|
||||
|
||||
self.slc_active_stock = slc_active
|
||||
|
||||
@@ -101,7 +101,7 @@ void MadsSettings::updateToggles() {
|
||||
const bool enable_mads = params.getBool("EnableMads");
|
||||
const bool enabled = is_offroad && enable_mads;
|
||||
|
||||
toggles["AccMadsCombo"]->setEnabled(enabled);
|
||||
toggles["MadsCruiseMain"]->setEnabled(enabled);
|
||||
toggles["AccMadsCombo"]->setEnabled(enable_mads);
|
||||
toggles["MadsCruiseMain"]->setEnabled(enable_mads);
|
||||
dlob_settings->setEnabled(enabled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user