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 Ioniq5 pe with sync #70

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

WIP Ioniq5 pe with sync #70

wants to merge 110 commits into from

Conversation

devtekve
Copy link

@devtekve devtekve commented Mar 1, 2025

Requires #68

Summary by Sourcery

Adds support for angle-based steering control for Hyundai CAN-FD vehicles, specifically the Ioniq 5 PE and Kia EV9. This includes new safety checks, parameter adjustments, and message creation logic to handle angle-based commands instead of torque-based commands. Also updates the car fingerprint to include the Ioniq 5 PE.

New Features:

  • Adds angle-based steering control for Hyundai CAN-FD vehicles.
  • Adds support for Ioniq 5 PE and Kia EV9.

Tests:

  • Adds tests for angle-based steering control.

Copy link

sourcery-ai bot commented Mar 1, 2025

Reviewer's Guide by Sourcery

This pull request introduces steering angle control support for Hyundai CAN-FD platform, specifically for vehicles like the Ioniq 5 PE and Kia EV9. It includes changes to safety limits, car controller logic, and car state estimation to accommodate angle-based control. Additionally, the Ioniq 5 PE is added to the list of supported cars, and wheel speed calculation is refactored for CAN-FD cars.

Sequence diagram for steering control with angle

sequenceDiagram
    participant CarController
    participant CarState
    participant hyundaicanfd

    CarController->>CarState: CS.out.steeringAngleDeg
    CarController->>CarController: apply_std_steer_angle_limits(actuators.steeringAngleDeg, ...)
    alt driver torque override
        CarController->>CarState: CS.out.steeringTorque
        CarController->>CarController: lkas_max_torque update
    end
    CarController->>hyundaicanfd: create_steering_messages(apply_angle, lkas_max_torque)
    hyundaicanfd-->>CarController: CAN messages
Loading

Updated class diagram for CarControllerParams

classDiagram
    class CarControllerParams {
        float ACCEL_MIN
        float ACCEL_MAX
        AngleRateLimit ANGLE_RATE_LIMIT_UP
        AngleRateLimit ANGLE_RATE_LIMIT_DOWN
        int ANGLE_MAX_TORQUE
        int ANGLE_DRIVER_TORQUE_ALLOWANCE
        int ANGLE_MIN_TORQUE
        int STEER_ANGLE_MAX
        int STEER_DELTA_UP
        int STEER_DELTA_DOWN
        float STEER_MAX
        float STEER_DRIVER_TORQUE_ALLOWANCE
        float STEER_DRIVER_TORQUE_OVERRIDE
        float STEER_DRIVER_TORQUE_FACTOR
    }
    class AngleRateLimit {
        float[] speed_bp
        float[] angle_v
    }
    CarControllerParams -- AngleRateLimit : has
Loading

Updated class diagram for HyundaiFlags

classDiagram
    class HyundaiFlags {
        CANFD_LKA_STEERING
        CANFD_LKA_STEERING_ALT
        FCEV_GAS
        ALT_LIMITS_2
        CANFD_ANGLE_STEERING
        FLAG_HYUNDAI_ESCC
        FLAG_HYUNDAI_LONG_MAIN_CRUISE_TOGGLEABLE
        CAMERA_SCC
        RADAR_SCC
        EV
        HYBRID
         gasoline
        DISABLE_CAN_CHECKS
        SEND_LFA_MESSAGES
        CANFD_CAMERA_SCC
    }
Loading

Updated class diagram for HyundaiSafetyFlags

classDiagram
    class HyundaiSafetyFlags {
        CANFD_LKA_STEERING
        CANFD_LKA_STEERING_ALT
        FCEV_GAS
        ALT_LIMITS_2
        CANFD_ANGLE_STEERING
        FLAG_HYUNDAI_ESCC
        FLAG_HYUNDAI_LONG_MAIN_CRUISE_TOGGLEABLE
        CAMERA_SCC
    }
Loading

File-Level Changes

Change Details Files
Added steering angle support for Hyundai CAN-FD platform, enabling angle-based control for vehicles like Ioniq 5 PE and Kia EV9.
  • Added CANFD_ANGLE_STEERING flag to HyundaiFlags and HyundaiSafetyFlags.
  • Modified safety_hyundai_canfd.h to include angle-based steering checks and limits.
  • Updated hyundaicanfd.py to create steering messages for angle-based control.
  • Modified carcontroller.py to handle angle-based steering control logic.
  • Added ANGLE_MAX_TORQUE, ANGLE_DRIVER_TORQUE_ALLOWANCE, and ANGLE_MIN_TORQUE parameters to CarControllerParams.
  • Updated carstate.py to handle new signals related to steering angle.
  • Added new tests in test_hyundai_canfd.py for angle-based steering safety.
  • Added torque data overrides for angle control cars.
  • Updated interface.py to set steerControlType to angle when CANFD_ANGLE_STEERING flag is enabled.
  • Updated safety_nissan.h and test_nissan.py to use a reasonable steering angle limit.
  • Updated safety_tesla.py to use a reasonable steering angle limit.
opendbc/safety/safety/safety_hyundai_canfd.h
opendbc/safety/tests/test_hyundai_canfd.py
opendbc/car/hyundai/carcontroller.py
opendbc/car/hyundai/hyundaicanfd.py
opendbc/car/hyundai/values.py
opendbc/car/hyundai/carstate.py
opendbc/car/hyundai/fingerprints.py
opendbc/car/interface.py
opendbc/car/torque_data/override.toml
docs/CARS.md
opendbc/car/nissan/values.py
opendbc/safety/safety/safety_nissan.h
opendbc/car/tests/routes.py
opendbc/safety/tests/test_nissan.py
opendbc/safety/tests/test_tesla.py
Added Ioniq 5 PE to the list of supported cars.
  • Added HYUNDAI_IONIQ_5_PE to CAR enum in values.py.
  • Added fingerprint data for HYUNDAI_IONIQ_5_PE in fingerprints.py.
  • Updated CARS.md to include HYUNDAI_IONIQ_5_PE.
opendbc/car/hyundai/values.py
opendbc/car/hyundai/fingerprints.py
docs/CARS.md
Refactored wheel speed calculation in carstate.py for CAN-FD cars.
  • Updated update_canfd function to use WHL_Spd{pos}Val signals for wheel speed calculation.
  • Corrected scaling factor for wheel speed values.
  • Updated standstill check to use all four wheel speeds.
opendbc/car/hyundai/carstate.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 force-pushed the sync-20250228-bring-panda-safety branch from 624b2de to d8808f9 Compare March 1, 2025 17:41
@devtekve devtekve force-pushed the ioniq5-pe-with-sync branch from 9606b59 to 63366f6 Compare March 1, 2025 19:46
Base automatically changed from sync-20250228-bring-panda-safety to sync-20250228 March 6, 2025 15:17
@sunnyhaibin sunnyhaibin force-pushed the sync-20250228 branch 2 times, most recently from 7017688 to 72918ec Compare March 7, 2025 04:40
@sunnyhaibin sunnyhaibin force-pushed the sync-20250228 branch 2 times, most recently from 26084df to f0c006f Compare March 9, 2025 03:47
Base automatically changed from sync-20250228 to master-new March 9, 2025 03:51
@devtekve devtekve force-pushed the ioniq5-pe-with-sync branch from 744568f to ddfbf8e Compare March 9, 2025 10:37
@devtekve devtekve changed the base branch from master-new to sync-20250309 March 9, 2025 10:37
Base automatically changed from sync-20250309 to master-new March 9, 2025 19:46
@devtekve devtekve force-pushed the ioniq5-pe-with-sync branch 2 times, most recently from 4135a69 to 288f954 Compare March 10, 2025 16:16
sunnyhaibin and others added 10 commits March 16, 2025 19:54
# Conflicts:
#	opendbc/car/hyundai/carcontroller.py
#	opendbc/safety/safety/safety_hyundai_canfd.h
* Update fingerprints.py

Added EUR and KOR fwdcamera

* Update opendbc/car/hyundai/fingerprints.py

---------

Co-authored-by: Jason Wen <[email protected]>
…c-2-redo

# Conflicts:
#	opendbc/car/hyundai/carcontroller.py
#	opendbc/car/hyundai/hyundaicanfd.py
This update introduces compatibility for the 2025+ Hyundai Ioniq 5 PE with HDA II, including fingerprints, platform configuration, and blinkers handling. Additionally, steering torque logic has been refined with adaptive adjustments for user intervention, improving control. Obsolete Kia EV9 configurations were removed for better maintainability.
Replaced KIA_EV9 entry with HYUNDAI_IONIQ_5_PE in the torque override configuration. Adjusted the values to align with the updated specifications for this model.
Revised the angle_rate_up_lookup and angle_rate_down_lookup tables to include more detailed points. This enhances the granularity and accuracy of angle rate calculations for safer and smoother operation.
Reduced the number of lookup table points for steering angle rate up and down in Hyundai CAN FD safety. This change simplifies the implementation while preserving the intended functionality and behavior."
Added a new test route for the Hyundai Ioniq 5 PE with LKA steering, HDA2, and LFA2. Also removed the test route for the Kia EV9 as it is no longer needed. These changes ensure the test routes remain relevant and up-to-date.
@devtekve devtekve force-pushed the ioniq5-pe-with-sync branch from a940844 to 14c662e Compare March 23, 2025 09:54
Simplified the lookup tables for angle rates and adjusted values for smoother steering transitions. These changes aim to optimize control behavior and improve system performance.
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.

4 participants