Merge remote-tracking branch 'origin/master-new' into HKG-long-tune

# Conflicts:
#	sunnypilot/selfdrive/car/interfaces.py
This commit is contained in:
discountchubbs
2025-03-29 20:10:19 -07:00
6 changed files with 20 additions and 15 deletions
+2 -2
View File
@@ -108,7 +108,7 @@ class Car:
fixed_fingerprint = json.loads(self.params.get("CarPlatformBundle", encoding='utf-8') or "{}").get("platform", None)
self.CI = get_car(*self.can_callbacks, obd_callback(self.params), experimental_long_allowed, num_pandas, cached_params, fixed_fingerprint)
sunnypilot_interfaces.setup_car_interface_sp(self.CI.CP, self.CI.CP_SP, self.params)
sunnypilot_interfaces.setup_interfaces(self.CI.CP, self.CI.CP_SP, self.params)
self.RI = interfaces[self.CI.CP.carFingerprint].RadarInterface(self.CI.CP, self.CI.CP_SP)
self.CP = self.CI.CP
self.CP_SP = self.CI.CP_SP
@@ -274,7 +274,7 @@ class Car:
# Initialize CarInterface, once controls are ready
# TODO: this can make us miss at least a few cycles when doing an ECU knockout
self.CI.init(self.CP, self.CP_SP, *self.can_callbacks)
sunnypilot_interfaces.initialize_car_interface_sp(self.CP, self.CP_SP, self.params, *self.can_callbacks)
sunnypilot_interfaces.init_interfaces(self.CP, self.CP_SP, self.params, *self.can_callbacks)
# signal pandad to switch to car safety mode
self.params.put_bool_nonblocking("ControlsReady", True)
+1 -1
View File
@@ -45,7 +45,7 @@ class TestCarInterfaces:
experimental_long=args['experimental_long'], docs=False)
car_params_sp = CarInterface.get_params_sp(car_params, car_name, args['fingerprints'], args['car_fw'],
experimental_long=args['experimental_long'], docs=False)
sunnypilot_interfaces.setup_car_interface_sp(car_params, car_params_sp)
sunnypilot_interfaces.setup_interfaces(car_params, car_params_sp)
car_params = car_params.as_reader()
car_interface = CarInterface(car_params, car_params_sp)
assert car_params
@@ -23,7 +23,7 @@ class TestLatControl:
CP = CarInterface.get_non_essential_params(car_name)
CP_SP = CarInterface.get_non_essential_params_sp(CP, car_name)
CI = CarInterface(CP, CP_SP)
sunnypilot_interfaces.setup_car_interface_sp(CP, CP_SP)
sunnypilot_interfaces.setup_interfaces(CP, CP_SP)
CP_SP = convert_to_capnp(CP_SP)
VM = VehicleModel(CP)
+14 -9
View File
@@ -24,7 +24,7 @@ def log_fingerprint(CP: structs.CarParams) -> None:
else:
sentry.capture_fingerprint(CP.carFingerprint, CP.brand)
def initialize_custom_longitudinal_tuning(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params = None) -> None:
def _initialize_custom_longitudinal_tuning(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params = None) -> None:
if params is None:
params = Params()
@@ -39,7 +39,7 @@ def initialize_custom_longitudinal_tuning(CP: structs.CarParams, CP_SP: structs.
CP_SP.flags |= HyundaiFlagsSP.LONGTUNING_BRAKING.value
def initialize_neural_network_lateral_control(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params = None,
def _initialize_neural_network_lateral_control(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params = None,
enabled: bool = False) -> None:
if params is None:
params = Params()
@@ -60,7 +60,7 @@ def initialize_neural_network_lateral_control(CP: structs.CarParams, CP_SP: stru
CP_SP.neuralNetworkLateralControl.fuzzyFingerprint = not exact_match
def initialize_radar_tracks(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params = None):
def _initialize_radar_tracks(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params = None) -> None:
if params is None:
params = Params()
@@ -74,14 +74,14 @@ def initialize_radar_tracks(CP: structs.CarParams, CP_SP: structs.CarParamsSP, p
CP.radarUnavailable = False
def setup_car_interface_sp(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params = None):
initialize_custom_longitudinal_tuning(CP, CP_SP, params)
initialize_neural_network_lateral_control(CP, CP_SP, params)
initialize_radar_tracks(CP, CP_SP, params)
def setup_interfaces(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params = None):
_initialize_custom_longitudinal_tuning(CP, CP_SP, params)
_initialize_neural_network_lateral_control(CP, CP_SP, params)
_initialize_radar_tracks(CP, CP_SP, params)
def initialize_car_interface_sp(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params, can_recv: CanRecvCallable,
can_send: CanSendCallable):
def _enable_radar_tracks(CP: structs.CarParams, CP_SP: structs.CarParamsSP, can_recv: CanRecvCallable,
params: Params) -> None:
if CP.brand == 'hyundai':
if CP_SP.flags & HyundaiFlagsSP.ENABLE_RADAR_TRACKS:
can_recv()
@@ -96,3 +96,8 @@ def initialize_car_interface_sp(CP: structs.CarParams, CP_SP: structs.CarParamsS
if not radar_tracks_persistent:
params.put_bool_nonblocking("HyundaiRadarTracks", not radar_unavailable)
params.put_bool_nonblocking("HyundaiRadarTracksPersistent", True)
def init_interfaces(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params: Params,
can_recv: CanRecvCallable, can_send: CanSendCallable):
_enable_radar_tracks(CP, CP_SP, can_recv, params)
@@ -24,7 +24,7 @@ class TestNNLCFingerprintBase:
CP_SP = CarInterface.get_non_essential_params_sp(CP, car_name)
CI = CarInterface(CP, CP_SP)
sunnypilot_interfaces.setup_car_interface_sp(CP, CP_SP, Params())
sunnypilot_interfaces.setup_interfaces(CP, CP_SP, Params())
return CI
@@ -22,7 +22,7 @@ class TestNNTorqueModel:
CP_SP = CarInterface.get_non_essential_params_sp(CP, car_name)
CI = CarInterface(CP, CP_SP)
sunnypilot_interfaces.setup_car_interface_sp(CP, CP_SP, params)
sunnypilot_interfaces.setup_interfaces(CP, CP_SP, params)
CP_SP = convert_to_capnp(CP_SP)