Merge pull request #50 from FLYINORION123/honda-speedlimit-dev

Honda Dashboard Speed Limit Controller (SLC) Support
This commit is contained in:
Dom
2026-04-05 18:00:27 -05:00
committed by firestar5683
parent 523c12257b
commit 701080a672
4 changed files with 33 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.honda.hondacan import CanBus
from opendbc.car.honda.values import CAR, DBC, STEER_THRESHOLD, HONDA_BOSCH, HONDA_BOSCH_ALT_RADAR, HONDA_BOSCH_CANFD, \
HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_RADARLESS, \
HondaFlags, CruiseButtons, CruiseSettings, GearShifter, CarControllerParams
HondaFlags, CruiseButtons, CruiseSettings, GearShifter, CarControllerParams, HondaStarPilotFlags
from opendbc.car.interfaces import CarStateBase
TransmissionType = structs.CarParams.TransmissionType
@@ -19,6 +19,18 @@ BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.D
SETTINGS_BUTTONS_DICT = {CruiseSettings.DISTANCE: ButtonType.gapAdjustCruise, CruiseSettings.LKAS: ButtonType.lkas}
# Dashboard Speed Limit / Traffic Sign Recognition (TSR) for Speed Limit Controller (SLC)
def calculate_speed_limit(CP, FPCP, cp, cp_cam):
if not (FPCP.flags & HondaStarPilotFlags.HAS_CAMERA_MESSAGES):
return 0.0
speed_bus = cp if (CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS - HONDA_BOSCH_CANFD)) else cp_cam
try:
speed_limit_raw = speed_bus.vl["CAMERA_MESSAGES"]["SPEED_LIMIT_SIGN"] % 32
return speed_limit_raw * 5.0 * CV.MPH_TO_MS if 1 <= speed_limit_raw <= 17 else 0.0
except (KeyError, ValueError):
return 0.0
class CarState(CarStateBase):
def __init__(self, CP, FPCP):
super().__init__(CP, FPCP)
@@ -222,6 +234,8 @@ class CarState(CarStateBase):
fp_ret = custom.StarPilotCarState.new_message()
fp_ret.dashboardSpeedLimit = calculate_speed_limit(self.CP, self.FPCP, cp, cp_cam)
return ret, fp_ret
def get_can_parsers(self, CP):

View File

@@ -94,6 +94,10 @@ class CruiseSettings:
LKAS = 1
class HondaStarPilotFlags(IntFlag):
HAS_CAMERA_MESSAGES = 8
@dataclass
class HondaCarDocs(CarDocs):
package: str = "Honda Sensing"
@@ -360,6 +364,15 @@ HONDA_BOSCH_RADARLESS = CAR.with_flags(HondaFlags.BOSCH_RADARLESS)
HONDA_BOSCH_CANFD = CAR.with_flags(HondaFlags.BOSCH_CANFD)
HONDA_BOSCH_ALT_RADAR = CAR.with_flags(HondaFlags.BOSCH_ALT_RADAR)
HONDA_BOSCH_TJA_CONTROL = CAR.with_flags(HondaFlags.BOSCH_TJA_CONTROL)
HONDA_CAMERA_MESSAGE_CARS = {
CAR.HONDA_ACCORD,
CAR.HONDA_CIVIC_BOSCH,
CAR.HONDA_CIVIC_2022,
CAR.HONDA_CRV_5G,
CAR.HONDA_CRV_HYBRID,
CAR.HONDA_HRV_3G,
CAR.HONDA_INSIGHT,
}
DBC = CAR.create_dbc_map()

View File

@@ -18,7 +18,7 @@ from opendbc.car.common.basedir import BASEDIR
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.common.simple_kalman import KF1D, get_kalman_gain
from opendbc.car.gm.values import CAR as GM
from opendbc.car.honda.values import CAR as HONDA, HONDA_BOSCH, HondaSafetyFlags
from opendbc.car.honda.values import CAR as HONDA, HONDA_BOSCH, HONDA_CAMERA_MESSAGE_CARS, HondaSafetyFlags, HondaStarPilotFlags
from opendbc.car.hyundai.hyundaicanfd import CanBus
from opendbc.car.hyundai.values import CAR as HYUNDAI, CANFD_CAR, HyundaiFlags, HyundaiStarPilotSafetyFlags
from opendbc.car.mock.values import CAR as MOCK
@@ -205,6 +205,9 @@ class CarInterfaceBase(ABC):
elif platform in HONDA:
fp_ret.canUsePedal = candidate not in HONDA_BOSCH
# Only enable TSR parsing on Hondas confirmed to publish CAMERA_MESSAGES.
if candidate in HONDA_CAMERA_MESSAGE_CARS:
fp_ret.flags |= int(HondaStarPilotFlags.HAS_CAMERA_MESSAGES)
elif platform in HYUNDAI:
if candidate in CANFD_CAR:

View File

@@ -362,7 +362,7 @@ void StarPilotSettingsWindow::updateVariables() {
friction = CP.getLateralTuning().getTorque().getFriction();
hasAlphaLongitudinal = CP.getAlphaLongitudinalAvailable();
hasBSM = CP.getEnableBsm();
hasDashSpeedLimits = carMake == "ford" || carMake == "hyundai" || carMake == "toyota";
hasDashSpeedLimits = carMake == "ford" || carMake == "hyundai" || carMake == "toyota" || carMake == "honda";
hasNNFFLog = nnffLogFileExists(QString::fromStdString(carFingerprint));
hasOpenpilotLongitudinal = hasLongitudinalControl(CP);
hasPCMCruise = CP.getPcmCruise();