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 #89

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

sunnyhaibin
Copy link
Collaborator

@sunnyhaibin sunnyhaibin commented Mar 19, 2025

Summary by Sourcery

Adds a new parameter to set_mads_params to control whether lateral control is paused when the brake pedal is pressed.

Enhancements:

  • Adds a new parameter to set_mads_params to control whether lateral control is paused when the brake pedal is pressed.
  • Renames disengage_lateral_on_brake to pause_lateral_on_brake to better reflect the functionality.

Copy link

sourcery-ai bot commented Mar 19, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new feature that allows lateral control to be paused, rather than fully disengaged, when the brake pedal is pressed. This is implemented by adding a new pause_lateral_on_brake parameter to the MADS system state and updating the control logic to handle this new state. Additionally, the pull request includes new tests to verify the correct behavior of the pause on brake functionality.

Sequence diagram for lateral control with pause on brake

sequenceDiagram
  participant Driver
  participant MADS

  Driver->>MADS: Engages brake pedal
  activate MADS
  MADS->>MADS: Checks pause_lateral_on_brake
  alt pause_lateral_on_brake is true
    MADS->>MADS: Pauses lateral control
  else pause_lateral_on_brake is false
    MADS->>MADS: Disengages lateral control
  end
  deactivate MADS
Loading

Sequence diagram for lateral control re-engaging after brake release with pause on brake

sequenceDiagram
  participant Driver
  participant MADS

  Driver->>MADS: Releases brake pedal
  activate MADS
  MADS->>MADS: Checks pause_lateral_on_brake
  alt pause_lateral_on_brake is true and brake was the only disengage reason
    MADS->>MADS: Requests lateral control
  else
    MADS->>MADS: Does not request 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
  }
  note for MADSState "Added pause_lateral_on_brake field"
Loading

File-Level Changes

Change Details Files
Added a new parameter to mads_set_system_state and set_mads_params to control whether lateral control is paused on brake pedal press, instead of fully disengaging.
  • Added pause_lateral_on_brake to MADSState struct.
  • Updated m_update_control_state to handle the new pause_lateral_on_brake parameter.
  • Updated mads_set_alternative_experience and mads_set_system_state to accept the new parameter.
  • Updated set_mads_params to include the new parameter.
  • Added new tests for the pause on brake functionality.
  • Renamed tests to reflect the pause functionality instead of disengage.
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/tests/libsafety/safety_helpers.py
opendbc/safety/sunnypilot/safety_mads_declarations.h
opendbc/safety/__init__.py
opendbc/safety/tests/safety_replay/replay_drive.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

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 merged commit e670860 into master-new Mar 19, 2025
7 checks passed
@sunnyhaibin sunnyhaibin deleted the mads-steering-mode-on-brake branch March 19, 2025 12:52
sunnyhaibin added a commit that referenced this pull request Mar 19, 2025
sunnyhaibin added a commit that referenced this pull request Mar 19, 2025
@sunnyhaibin sunnyhaibin restored the mads-steering-mode-on-brake branch March 19, 2025 20:03
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