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 15 commits into
base: master-new
Choose a base branch
from
Draft

WIP Ioniq5 pe with sync #70

wants to merge 15 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 4 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 from 9633eac to 8a32031 Compare March 9, 2025 20:47
devtekve added 11 commits March 10, 2025 17:10
This commit introduces angle-based steering control for the Hyundai Ioniq 5 PE (2025+ models) with Highway Driving Assist II (HDA2). It includes fingerprint updates, platform configuration, and control modifications to enable precise steering control and fault handling for CAN FD angle steering systems.
Updated MAX_LAT_ACCEL_MEASURED parameter for HYUNDAI_IONIQ_5_PE from 3.0 to 2.36 in the override file. This change aims to refine angle control calibration for improved vehicle behavior.
Refine angle limit parameters and rate curves for improved accuracy. Expanded and adjusted breakpoints for smoother transitions across speed ranges.
Introduced a smoothing mechanism for target torque calculations to enhance response consistency. This adjustment reduces abrupt changes while maintaining stability, using a configurable smooth factor. These changes aim to improve driving dynamics and enhance system behavior.

Update torque limit logic and adjust formatting

Refined ANGLE_TORQUE_LIMIT speed breakpoints and values for better control. Additionally, improved code readability by fixing spacing and formatting inconsistencies across multiple sections. These changes enhance maintainability and alignment with code standards.

"Adjust torque limit speed breakpoints and values"

Removed the lowest speed breakpoint and corresponding torque limit, starting the limits at a higher speed. This change simplifies the speed-torque mapping and enhances consistency at lower speeds.

Improve LKAS torque control with speed-based dynamic limits

Replaced steering angle-based torque calculation with speed-dependent limits for smoother and more adaptive LKAS behavior. Added clamping and rate adjustments to ensure torque stays within defined bounds to enhance stability and safety. Updated constants to reflect speed breakpoints and corresponding torque limits.

Adjust torque curve for Hyundai steering angle limits

Updated the ANGLE_TORQUE_Y values to modify the torque curve, reducing the first point from 40% to 20% of ANGLE_MAX_TORQUE. This adjustment improves steering responsiveness and control at lower torque levels.

Update torque calculation logic for Hyundai steering control

Adjusted the dynamic torque interpolation to use the actual steering angle instead of the last applied angle. Also corrected the torque ramp values for smoother transitions during steering. These changes aim to improve driving stability and user experience.

Fix indentation error in Hyundai values constructor

Corrected the indentation for the __init__ method in the Hyundai values file. This ensures proper method definition and avoids potential runtime errors due to misaligned code structure.

Adjust LKAS torque calculation for dynamic steering limits.

Introduced dynamic torque interpolation based on steering angle magnitude, replacing the static LKAS torque ramp-up. Updated max torque limit to 250 and added interpolation parameters for smoother torque adjustments. These changes enhance steering control precision and adaptability.
The ANGLE_MAX_TORQUE value was raised from 150 to 200 to allow higher torque limits. This adjustment aims to enhance handling capabilities and better align with system requirements.
Introduced a speed-based interpolation to smoothly scale the low-speed torque cap, replacing the fixed multiplier approach. This enhances steering responsiveness at varying speeds while maintaining stability and consistency.
Introduced an adaptive ramp-down rate based on the torque difference and defined a fixed number of override cycles. This ensures a smoother and more controlled reduction to minimum torque when overriding steering torque.
@devtekve devtekve force-pushed the ioniq5-pe-with-sync branch from 4135a69 to 288f954 Compare March 10, 2025 16:16
Introduced adaptive max torque scaling near center angles using linear interpolation for smoother transitions. Additionally, revised torque ramp-up and ramp-down rates for better responsiveness and user experience. These changes improve steering precision and control behavior.
Expanded and adjusted steering interpolation points and scaling factors in the Hyundai angle limits data. These changes aim to enhance steering responsiveness and better align with real-world behavior.
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