Skip to content
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

WIP: Adding 2025 Ioniq 5 PE #63

Draft
wants to merge 1 commit into
base: master-new
Choose a base branch
from
Draft

WIP: Adding 2025 Ioniq 5 PE #63

wants to merge 1 commit into from

Conversation

devtekve
Copy link

@devtekve devtekve commented Jan 29, 2025

WIP do not use, not safe yet

Summary by Sourcery

New Features:

  • Added support for the 2025 Hyundai Ioniq 5 PE, including angle-based steering control.

Related

Upstream PR

commaai#1676

sunnypilot PR

sunnypilot/sunnypilot#625

Copy link

sourcery-ai bot commented Jan 29, 2025

Reviewer's Guide by Sourcery

This pull request adds support for the 2025 Hyundai Ioniq 5 PE, including angle-based control. It also refactors the steering torque logic to better handle driver input and adds a new CAN message for angle control.

Sequence diagram for steering control logic

sequenceDiagram
    participant D as Driver
    participant C as CarController
    participant S as Steering System

    Note over C: Initialize torque control
    D->>C: Apply steering torque
    activate C
    C->>C: Calculate ego_weight based on speed
    C->>C: Update driver_applied_torque_reducer
    alt driver applying torque
        C->>C: Reduce max torque (down to 30)
    else no driver torque
        C->>C: Increase max torque (up to 150)
    end
    C->>S: Apply calculated steering angle and torque
    deactivate C
Loading

Class diagram for updated CarController and HyundaiFlags

classDiagram
    class CarController {
        +apply_angle_last: float
        +lkas_max_torque: int
        +driver_applied_torque_reducer: int
        +update(CC, CC_SP, CS, now_nanos)
    }

    class HyundaiFlags {
        +ANGLE_CONTROL
        +CANFD_HDA2
        +CANFD_HDA2_ALT_STEERING
        +EV
    }

    note for CarController "Added new fields for angle-based control"
    note for HyundaiFlags "Added ANGLE_CONTROL flag"
Loading

File-Level Changes

Change Details Files
Added support for the 2025 Hyundai Ioniq 5 PE.
  • Added the 2025 Hyundai Ioniq 5 PE to the fingerprints.
  • Added the 2025 Hyundai Ioniq 5 PE to the list of supported cars.
  • Added a test route for the 2025 Hyundai Ioniq 5 PE.
  • Added a torque data override for the 2025 Hyundai Ioniq 5 PE.
  • Added the ANGLE_CONTROL flag to the 2025 Hyundai Ioniq 5 PE.
opendbc/car/hyundai/fingerprints.py
opendbc/car/hyundai/values.py
docs/CARS.md
opendbc/car/tests/routes.py
opendbc/car/torque_data/override.toml
Refactored steering torque logic to better handle driver input.
  • Added a driver_applied_torque_reducer to reduce max torque when the driver is applying torque.
  • Added logic to interpolate torque based on vehicle speed.
  • Added logic to set lkas_max_torque based on driver input and vehicle speed.
  • Set apply_angle to the current steering angle when lateral control is not active.
  • Set lkas_max_torque to 0 when lateral control is not active.
opendbc/car/hyundai/carcontroller.py
Added angle-based control for supported cars.
  • Added logic to apply steering angle in car controller.
  • Added logic to send steering angle command in CAN message.
  • Added ANGLE_CONTROL flag to HyundaiFlags.
  • Added logic to set steerControlType to angle for cars with ANGLE_CONTROL flag.
  • Added logic to use the alternate blinker signals for cars with ANGLE_CONTROL flag.
  • Added logic to use the alternate blindspot signals for cars with ANGLE_CONTROL flag.
  • Added angle rate limits.
  • Added torque data override for angle control.
opendbc/car/hyundai/carcontroller.py
opendbc/car/hyundai/hyundaicanfd.py
opendbc/car/hyundai/values.py
opendbc/car/hyundai/interface.py
opendbc/car/hyundai/carstate.py
opendbc/car/torque_data/override.toml
Added a new CAN message for angle control.
  • Added LKAS_ANGLE_CMD, LKAS_ANGLE_ACTIVE, and UNKNOWN signals to the steering CAN message.
  • Added logic to send the steering angle command in the CAN message.
opendbc/car/hyundai/hyundaicanfd.py
Fixed a bug in the Toyota car controller.
  • Fixed a bug where the car would erroneously unset PERMIT_BRAKING when stopping on uphills.
opendbc/car/toyota/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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

@devtekve devtekve changed the base branch from master-new to ev9-new January 29, 2025 08:51
@devtekve devtekve changed the base branch from ev9-new to master-new January 29, 2025 08:51
This update adds angle control functionality specifically for the Hyundai Ioniq 5 PE model. Changes were made across several files and variables to accommodate this additional feature. This control type provides enhanced handling and steering performance depending on the driving conditions, given its ability to adjust steering angle precisely.

Angle control stems from the angle of the steering wheel rather than torque, providing a more sophisticated steering response. In the Hyundai Ioniq 5 PE, adjustments for the input angle and torque calculations have been added, ensuring a more dynamic and responsive driving experience.

Variable additions include '`apply_angle_last`', '`lkas_max_torque`' and '`driver_applied_torque_reducer`', and a new condition was created for if the driver is manually applying some torque.

All of these changes allow for the application of correct torque when the driver is not actively steering, emulating the behavior of a stock LKAS system when engaged.
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.

2 participants