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: Safety migration fixes #77

Merged
merged 3 commits into from
Mar 13, 2025
Merged

Conversation

sunnyhaibin
Copy link
Collaborator

@sunnyhaibin sunnyhaibin commented Mar 13, 2025

Introduced in #67, some changes for MADS were not migrated over correctly.

Summary by Sourcery

Fixes issues introduced in a previous pull request related to MADS safety by ensuring correct migration of changes. This includes changes to steering angle command checks and updates to the base classes for MADS safety tests.

Enhancements:

  • Updates steering angle command checks to use is_lat_active() instead of controls_allowed to determine lateral control availability.
  • Refactors MADS safety tests to use a new base class MadsSafetyTestBase and introduces abstract methods for LKAS button and ACC state messages.
  • Updates PandaCarSafetyTest to inherit from MadsSafetyTestBase instead of MadsCommonBase

Tests:

  • Adds a TODO comment for steering safety tests to check controls_allowed and controls_allowed_lat.

@sunnyhaibin sunnyhaibin added the bug Something isn't working label Mar 13, 2025
Copy link

sourcery-ai bot commented Mar 13, 2025

Reviewer's Guide by Sourcery

This pull request refactors the MADS safety tests and updates the steering angle command checks. The base class for MADS safety tests was refactored to use an abstract base class and include a safety attribute. PandaCarSafetyTest was updated to inherit from the new MadsSafetyTestBase. The steering angle command checks were modified to use is_lat_active() instead of controls_allowed.

Updated class diagram for MADS safety tests

Loading
classDiagram
    class MadsSafetyTestBase {
        <<abstract>>
        +safety
    }
    class PandaCarSafetyTest {
    }

    MadsSafetyTestBase <|-- PandaCarSafetyTest
    note for MadsSafetyTestBase "Base class for MADS safety tests, using an abstract base class and including a safety attribute."

File-Level Changes

Change Details Files
Refactored the base class for MADS safety tests to use an abstract base class and include a safety attribute.
  • Replaced MadsCommonBase with MadsSafetyTestBase which inherits from abc.ABC.
  • Added a safety attribute of type libsafety_py.Panda to MadsSafetyTestBase.
  • Imported the abc module.
opendbc/safety/tests/mads_common.py
Updated PandaCarSafetyTest to inherit from the new MadsSafetyTestBase.
  • Inherited from MadsSafetyTestBase instead of MadsCommonBase.
opendbc/safety/tests/common.py
Modified the steering angle command checks to use is_lat_active() instead of controls_allowed.
  • Replaced !controls_allowed with !is_lat_active() in the steer_angle_cmd_checks function.
opendbc/safety/safety.h

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 484a9b0 into master-new Mar 13, 2025
7 checks passed
@sunnyhaibin sunnyhaibin deleted the mads-safety-migration-fix branch March 13, 2025 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant