Hyundai CAN Longitudinal: Enable for Camera SCC cars (#1282)
* Hyundai CAN: Longitudinal support for Camera SCC cars * fix OP long checking fcw/aeb * can error * cleanup --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
parent
e57375f1e2
commit
6c68673cfd
|
@ -90,7 +90,7 @@ class CarController(CarControllerBase):
|
||||||
# *** common hyundai stuff ***
|
# *** common hyundai stuff ***
|
||||||
|
|
||||||
# tester present - w/ no response (keeps relevant ECU disabled)
|
# tester present - w/ no response (keeps relevant ECU disabled)
|
||||||
if self.frame % 100 == 0 and not (self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value) and self.CP.openpilotLongitudinalControl:
|
if self.frame % 100 == 0 and not (self.CP.flags & (HyundaiFlags.CANFD_CAMERA_SCC | HyundaiFlags.CAMERA_SCC)) and self.CP.openpilotLongitudinalControl:
|
||||||
# for longitudinal control, either radar or ADAS driving ECU
|
# for longitudinal control, either radar or ADAS driving ECU
|
||||||
addr, bus = 0x7d0, 0
|
addr, bus = 0x7d0, 0
|
||||||
if self.CP.flags & HyundaiFlags.CANFD_HDA2.value:
|
if self.CP.flags & HyundaiFlags.CANFD_HDA2.value:
|
||||||
|
@ -147,7 +147,7 @@ class CarController(CarControllerBase):
|
||||||
use_fca = self.CP.flags & HyundaiFlags.USE_FCA.value
|
use_fca = self.CP.flags & HyundaiFlags.USE_FCA.value
|
||||||
can_sends.extend(hyundaican.create_acc_commands(self.packer, CC.enabled, accel, jerk, int(self.frame / 2),
|
can_sends.extend(hyundaican.create_acc_commands(self.packer, CC.enabled, accel, jerk, int(self.frame / 2),
|
||||||
hud_control, set_speed_in_units, stopping,
|
hud_control, set_speed_in_units, stopping,
|
||||||
CC.cruiseControl.override, use_fca))
|
CC.cruiseControl.override, use_fca, self.CP))
|
||||||
|
|
||||||
# 20 Hz LFA MFA message
|
# 20 Hz LFA MFA message
|
||||||
if self.frame % 5 == 0 and self.CP.flags & HyundaiFlags.SEND_LFA.value:
|
if self.frame % 5 == 0 and self.CP.flags & HyundaiFlags.SEND_LFA.value:
|
||||||
|
@ -155,7 +155,7 @@ class CarController(CarControllerBase):
|
||||||
|
|
||||||
# 5 Hz ACC options
|
# 5 Hz ACC options
|
||||||
if self.frame % 20 == 0 and self.CP.openpilotLongitudinalControl:
|
if self.frame % 20 == 0 and self.CP.openpilotLongitudinalControl:
|
||||||
can_sends.extend(hyundaican.create_acc_opt(self.packer))
|
can_sends.extend(hyundaican.create_acc_opt(self.packer, self.CP))
|
||||||
|
|
||||||
# 2 Hz front radar options
|
# 2 Hz front radar options
|
||||||
if self.frame % 50 == 0 and self.CP.openpilotLongitudinalControl:
|
if self.frame % 50 == 0 and self.CP.openpilotLongitudinalControl:
|
||||||
|
|
|
@ -153,7 +153,7 @@ class CarState(CarStateBase):
|
||||||
|
|
||||||
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear))
|
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear))
|
||||||
|
|
||||||
if not self.CP.openpilotLongitudinalControl:
|
if not self.CP.openpilotLongitudinalControl or self.CP.flags & HyundaiFlags.CAMERA_SCC:
|
||||||
aeb_src = "FCA11" if self.CP.flags & HyundaiFlags.USE_FCA.value else "SCC12"
|
aeb_src = "FCA11" if self.CP.flags & HyundaiFlags.USE_FCA.value else "SCC12"
|
||||||
aeb_sig = "FCA_CmdAct" if self.CP.flags & HyundaiFlags.USE_FCA.value else "AEB_CmdAct"
|
aeb_sig = "FCA_CmdAct" if self.CP.flags & HyundaiFlags.USE_FCA.value else "AEB_CmdAct"
|
||||||
aeb_warning = cp_cruise.vl[aeb_src]["CF_VSM_Warn"] != 0
|
aeb_warning = cp_cruise.vl[aeb_src]["CF_VSM_Warn"] != 0
|
||||||
|
@ -372,7 +372,7 @@ class CarState(CarStateBase):
|
||||||
("LKAS11", 100)
|
("LKAS11", 100)
|
||||||
]
|
]
|
||||||
|
|
||||||
if not CP.openpilotLongitudinalControl and CP.flags & HyundaiFlags.CAMERA_SCC:
|
if not CP.openpilotLongitudinalControl or CP.flags & HyundaiFlags.CAMERA_SCC:
|
||||||
cam_messages += [
|
cam_messages += [
|
||||||
("SCC11", 50),
|
("SCC11", 50),
|
||||||
("SCC12", 50),
|
("SCC12", 50),
|
||||||
|
|
|
@ -123,7 +123,7 @@ def create_lfahda_mfc(packer, enabled):
|
||||||
}
|
}
|
||||||
return packer.make_can_msg("LFAHDA_MFC", 0, values)
|
return packer.make_can_msg("LFAHDA_MFC", 0, values)
|
||||||
|
|
||||||
def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, set_speed, stopping, long_override, use_fca):
|
def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, set_speed, stopping, long_override, use_fca, CP):
|
||||||
commands = []
|
commands = []
|
||||||
|
|
||||||
scc11_values = {
|
scc11_values = {
|
||||||
|
@ -169,7 +169,8 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, se
|
||||||
commands.append(packer.make_can_msg("SCC14", 0, scc14_values))
|
commands.append(packer.make_can_msg("SCC14", 0, scc14_values))
|
||||||
|
|
||||||
# Only send FCA11 on cars where it exists on the bus
|
# Only send FCA11 on cars where it exists on the bus
|
||||||
if use_fca:
|
# On Camera SCC cars, FCA11 is not disabled, so we forward stock FCA11 back to the car forward hooks
|
||||||
|
if use_fca and not (CP.flags & HyundaiFlags.CAMERA_SCC):
|
||||||
# note that some vehicles most likely have an alternate checksum/counter definition
|
# note that some vehicles most likely have an alternate checksum/counter definition
|
||||||
# https://github.com/commaai/opendbc/commit/9ddcdb22c4929baf310295e832668e6e7fcfa602
|
# https://github.com/commaai/opendbc/commit/9ddcdb22c4929baf310295e832668e6e7fcfa602
|
||||||
fca11_values = {
|
fca11_values = {
|
||||||
|
@ -184,7 +185,7 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, se
|
||||||
|
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def create_acc_opt(packer):
|
def create_acc_opt(packer, CP):
|
||||||
commands = []
|
commands = []
|
||||||
|
|
||||||
scc13_values = {
|
scc13_values = {
|
||||||
|
@ -195,6 +196,8 @@ def create_acc_opt(packer):
|
||||||
commands.append(packer.make_can_msg("SCC13", 0, scc13_values))
|
commands.append(packer.make_can_msg("SCC13", 0, scc13_values))
|
||||||
|
|
||||||
# TODO: this needs to be detected and conditionally sent on unsupported long cars
|
# TODO: this needs to be detected and conditionally sent on unsupported long cars
|
||||||
|
# On Camera SCC cars, FCA12 is not disabled, so we forward stock FCA12 back to the car forward hooks
|
||||||
|
if not (CP.flags & HyundaiFlags.CAMERA_SCC):
|
||||||
fca12_values = {
|
fca12_values = {
|
||||||
"FCA_DrvSetState": 2,
|
"FCA_DrvSetState": 2,
|
||||||
"FCA_USM": 1, # AEB disabled
|
"FCA_USM": 1, # AEB disabled
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from panda import Panda
|
from panda import Panda
|
||||||
from opendbc.car import Bus, get_safety_config, structs
|
from opendbc.car import Bus, get_safety_config, structs
|
||||||
from opendbc.car.hyundai.hyundaicanfd import CanBus
|
from opendbc.car.hyundai.hyundaicanfd import CanBus
|
||||||
from opendbc.car.hyundai.values import HyundaiFlags, CAR, DBC, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, \
|
from opendbc.car.hyundai.values import HyundaiFlags, CAR, DBC, CANFD_RADAR_SCC_CAR, \
|
||||||
CANFD_UNSUPPORTED_LONGITUDINAL_CAR, \
|
CANFD_UNSUPPORTED_LONGITUDINAL_CAR, \
|
||||||
UNSUPPORTED_LONGITUDINAL_CAR
|
UNSUPPORTED_LONGITUDINAL_CAR
|
||||||
from opendbc.car.hyundai.radar_interface import RADAR_START_ADDR
|
from opendbc.car.hyundai.radar_interface import RADAR_START_ADDR
|
||||||
|
@ -68,7 +68,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Shared configuration for non CAN-FD cars
|
# Shared configuration for non CAN-FD cars
|
||||||
ret.experimentalLongitudinalAvailable = candidate not in (UNSUPPORTED_LONGITUDINAL_CAR | CAMERA_SCC_CAR)
|
ret.experimentalLongitudinalAvailable = candidate not in UNSUPPORTED_LONGITUDINAL_CAR
|
||||||
ret.enableBsm = 0x58b in fingerprint[0]
|
ret.enableBsm = 0x58b in fingerprint[0]
|
||||||
|
|
||||||
# Send LFA message on cars with HDA
|
# Send LFA message on cars with HDA
|
||||||
|
@ -128,7 +128,7 @@ class CarInterface(CarInterfaceBase):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def init(CP, can_recv, can_send):
|
def init(CP, can_recv, can_send):
|
||||||
if CP.openpilotLongitudinalControl and not (CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value):
|
if CP.openpilotLongitudinalControl and not (CP.flags & (HyundaiFlags.CANFD_CAMERA_SCC | HyundaiFlags.CAMERA_SCC)):
|
||||||
addr, bus = 0x7d0, 0
|
addr, bus = 0x7d0, 0
|
||||||
if CP.flags & HyundaiFlags.CANFD_HDA2.value:
|
if CP.flags & HyundaiFlags.CANFD_HDA2.value:
|
||||||
addr, bus = 0x730, CanBus(CP).ECAN
|
addr, bus = 0x730, CanBus(CP).ECAN
|
||||||
|
|
Loading…
Reference in New Issue