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

MADS: Steering Mode on Brake Pedal Press #92

Merged
merged 4 commits into from
Mar 19, 2025

Conversation

sunnyhaibin
Copy link
Collaborator

@sunnyhaibin sunnyhaibin commented Mar 19, 2025

Reimplement #89

Summary by Sourcery

Adds the ability to pause lateral control when the brake pedal is pressed, instead of fully disengaging. This is controlled by a new parameter in the MADS settings.

Enhancements:

  • Adds a new parameter to MADS settings to control whether lateral control is paused or disengaged when the brake pedal is pressed.

Tests:

  • Adds tests for the new pause lateral on brake functionality.

Copy link

sourcery-ai bot commented Mar 19, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new feature that allows the system to pause lateral control upon brake pedal press instead of fully disengaging. It also renames a constant to better reflect its purpose within the MADS system.

Sequence diagram for lateral control on brake with pause

sequenceDiagram
  participant Driver
  participant MADS

  Driver->>MADS: Presses brake pedal
  activate MADS
  MADS->>MADS: m_update_control_state()
  alt m_mads_state.pause_lateral_on_brake is true
    MADS->>MADS: Pauses lateral control
  else
    MADS->>MADS: Disengages lateral control
  end
  deactivate MADS
Loading

Updated class diagram for MADSState

classDiagram
  class MADSState {
    bool system_enabled
    bool disengage_lateral_on_brake
    bool pause_lateral_on_brake
    bool controls_requested_lat
    bool controls_allowed_lat
  }
Loading

File-Level Changes

Change Details Files
Introduce a new pause_lateral_on_brake feature to temporarily pause lateral control when the brake pedal is pressed, instead of fully disengaging.
  • Added pause_lateral_on_brake boolean to MADSState struct.
  • Added ALT_EXP_MADS_PAUSE_LATERAL_ON_BRAKE constant.
  • Modified mads_set_system_state to accept pause_lateral_on_brake parameter.
  • Updated m_update_control_state to handle the pause/resume logic based on brake input and the new pause_lateral_on_brake flag.
  • Added get_pause_lateral_on_brake helper function.
  • Updated set_mads_params to include the new parameter.
  • Adjusted tests to reflect the new functionality and ensure correct behavior.
opendbc/safety/tests/mads_common.py
opendbc/safety/sunnypilot/safety_mads.h
opendbc/safety/tests/libsafety/safety_helpers.h
opendbc/safety/tests/hyundai_common.py
opendbc/safety/sunnypilot/safety_mads_declarations.h
opendbc/safety/tests/libsafety/safety_helpers.py
opendbc/safety/tests/safety_replay/replay_drive.py
opendbc/safety/__init__.py
opendbc/safety/tests/test_ford.py
opendbc/safety/tests/test_honda.py
opendbc/safety/tests/test_hyundai.py
opendbc/safety/tests/test_subaru.py
Rename ALT_EXP_DISENGAGE_LATERAL_ON_BRAKE to ALT_EXP_MADS_DISENGAGE_LATERAL_ON_BRAKE.
  • Renamed ALT_EXP_DISENGAGE_LATERAL_ON_BRAKE to ALT_EXP_MADS_DISENGAGE_LATERAL_ON_BRAKE.
opendbc/safety/sunnypilot/safety_mads_declarations.h
opendbc/safety/__init__.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

@sunnyhaibin sunnyhaibin self-assigned this Mar 19, 2025
@sunnyhaibin sunnyhaibin merged commit a26ea1e into master-new Mar 19, 2025
7 checks passed
@sunnyhaibin sunnyhaibin deleted the mads-steering-mode-on-brake-new branch March 19, 2025 21:48
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