Skip to content

feat(hyundai): add ADAS_DRV_INTERCEPT message integration #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: master-new
Choose a base branch
from

Conversation

devtekve
Copy link

@devtekve devtekve commented Jul 14, 2025

Route with interceptor worked long for a bit but lat was controlled by Adas ecu, the set speed was updated on comma but not on cluster, the cluster was being updated by the Adas because I could see the speed set there
e1107f9d04dfb1e2/00000331--7c6dfa955d


  • Introduced a new _hyundai_canfd_sunnypilot.dbc file for ADAS_DRV_INTERCEPT.
  • Added support for toggling ADAS drive intercept functionality.
  • Adjusted carcontroller to handle ADAS_DRV_INTERCEPT toggling for testing.

Summary by Sourcery

Add support for the ADAS_DRV_INTERCEPT message by introducing a new DBC file, a message creation function, and integrating the toggling of ADAS driving ECU intercept in the carcontroller.

New Features:

  • Add ADAS_DRV_INTERCEPT CAN message creation function for toggling driving ECU intercept
  • Include a new _hyundai_canfd_sunnypilot.dbc file defining the ADAS_DRV_INTERCEPT message

Enhancements:

  • Integrate ADAS_DRV_INTERCEPT toggling into carcontroller for testing via CC.latActive

- Introduced a new `_hyundai_canfd_sunnypilot.dbc` file for `ADAS_DRV_INTERCEPT`.
- Added support for toggling ADAS drive intercept functionality.
- Adjusted carcontroller to handle ADAS_DRV_INTERCEPT toggling for testing.
Copy link

sourcery-ai bot commented Jul 14, 2025

Reviewer's Guide

This PR integrates the ADAS_DRV_INTERCEPT message end-to-end by adding a new DBC file, a helper to pack the message, and toggling logic in the carcontroller for testing purposes.

ER diagram for new _hyundai_canfd_sunnypilot.dbc integration

erDiagram
    HYUNDAI_CANFD {
      int id
      string message
    }
    ADAS_DRV_INTERCEPT {
      int status
    }
    HYUNDAI_CANFD ||--o{ ADAS_DRV_INTERCEPT : contains
Loading

Class diagram for ADAS_DRV_INTERCEPT message integration

classDiagram
    class CarController {
      +create_canfd_msgs(apply_steer_req, apply_torque, set_speed_in_units, ...)
    }
    class hyundaicanfd {
      +create_adas_drv_intercept_msg(packer, CAN, enabled)
    }
    CarController --> hyundaicanfd : uses
Loading

File-Level Changes

Change Details Files
Introduce new DBC definitions for ADAS_DRV_INTERCEPT
  • Add a new _hyundai_canfd_sunnypilot.dbc file
  • Define ADAS_DRV_INTERCEPT message and its signals
opendbc/dbc/generator/hyundai/_hyundai_canfd_sunnypilot.dbc
Implement helper to pack ADAS_DRV_INTERCEPT CAN message
  • Add create_adas_drv_intercept_msg function in hyundaicanfd
  • Construct CAN message with 'status' field based on enable flag
opendbc/car/hyundai/hyundaicanfd.py
Enable ADAS intercept toggling in carcontroller
  • Inject ADAS_DRV_INTERCEPT message in create_canfd_msgs
  • Use CC.latActive flag to toggle intercept functionality
opendbc/car/hyundai/carcontroller.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

- Introduced `AdasDrvEcuInterceptor` to enable ADAS ECU interception.
- Updated car controller, radar interface, and CAN parsers for integration.
- Added new flags and parameters to manage feature toggling.
devtekve added 8 commits July 14, 2025 23:20
- Added abstract base classes for ECU interceptors, car state, car controller, and radar interface.
- Introduced `AdasDrvEcuInterceptor` implementation for specific Hyundai ADAS ECU needs.
- Added `__init__` methods to initialize parent class with CarParams.
- Improves consistency and readiness for extended functionality.
- Sets `alphaLongitudinalAvailable` to `True` for improved ADAS capabilities.
- Supports future enhancements around ADAS ECU interceptor toggling.
- Reorganized class hierarchy to adjust initialization and behavior.
- Ensures better compatibility with existing controllers and ADAS features.
- Added `HYUNDAI_CANFD_ADAS_INTERCEPTOR_MESSAGES` definition for improved ADAS feature support.
- Integrated interceptor message into various Hyundai CAN FD message sets.
- Added ADAS_ECU_INTERCEPTOR flag handling to enhance SCC compatibility.
- Improved radar and interceptor logic for better feature integration.
@@ -242,6 +246,7 @@ static safety_config hyundai_canfd_init(uint16_t param) {
HYUNDAI_CANFD_LKA_STEERING_COMMON_TX_MSGS(0, 1)
HYUNDAI_CANFD_LFA_STEERING_COMMON_TX_MSGS(1)
HYUNDAI_CANFD_SCC_CONTROL_COMMON_TX_MSGS(1, true)
HYUNDAI_CANFD_ADAS_INTERCEPTOR_MESSAGES(0)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding it here was the only thing that made it unblocked from panda side on my setup. I need to revisit really the others because I was just testing to see what would work without much thinking


@property
def enabled(self):
return self.CP_SP.flags & HyundaiFlagsSP.ADAS_ECU_INTERCEPTOR
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a prior commit I had this mistakenly set to self.CP_SP.flags & HyundaiFlagsSP.ENHANCED_SCC and it was reporting on the intercept message a status of 1. That does not make sense to me. I did not dive deeper because in the end I wanted it to be 1 for my test, I just updated it to the right flag. But why did the ESCC show up ? shouldn't have been the case, my car does not have ESCC per se. So it's confusing. Must revisit this

@@ -165,11 +165,20 @@ def _get_params_sp(stock_cp: structs.CarParams, ret: structs.CarParamsSP, candid
# TODO-SP: add route with ESCC message for process replay
if ESCC_MSG in fingerprint[0]:
ret.flags |= HyundaiFlagsSP.ENHANCED_SCC.value
else:
IS_ADAS_DRV_ECU_INTERCEPTOR_ENABLED = True # Faking it like this for now, I haven't built a way to detect it yet.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will setup a heartbeat from the interceptor to send back at a given cadence it's own status for 2 reasons:

  1. signal it's present on the system
  2. understand what it knew at any time from the logs since they'd be on can bus

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devtekve added 3 commits July 16, 2025 09:50
- Updated `_hyundai_canfd_sunnypilot.dbc` with new ADAS message definitions.
- Introduced `ADAS_DRV_INTERCEPT_OPT` and `INTERCEPTOR_HEARTBEAT` for improved safety mode handling.
- Enhanced interceptor detection with `ADAS_INTERCEPTOR_HEARTBEAT_MSG` integration.
- Refined ADAS interceptor handling for better parameter and capability management.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant