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

Modular Assistive Driving System (MADS) #40

Merged
merged 109 commits into from
Dec 6, 2024
Merged

Modular Assistive Driving System (MADS) #40

merged 109 commits into from
Dec 6, 2024

Conversation

devtekve
Copy link

@devtekve devtekve commented Nov 15, 2024

Refactor MADS safety with improved state management

Supported makes

  • Hyundai (+ LKAS button)
  • Toyota (No LKAS button)
  • Honda
  • Ford
  • Chrysler
  • GM
  • Mazda
  • Nissan
  • Subaru
  • Volkswagen
    - [ ] Tesla

Tested real world

  • Hyundai (+ LKAS button)
  • Toyota (No LKAS button)
  • Honda
  • Ford
  • Chrysler
  • GM
  • Mazda
  • Nissan
  • Subaru
  • Volkswagen
    - [ ] Tesla

Note: Real world tests will be deferred to the SP PR

Changes

Core Changes:

  • Introduced a MADSState struct to centralize state management
  • Removed global state variables in favor of structured state
  • Implemented button transition handling with explicit state tracking (PRESSED/RELEASED/NO_CHANGE)
  • Added state flags for button availability detection
  • Simplified lateral control permission logic

Button Handling:

  • Separated main button and LKAS button state tracking
  • Added independent engagement states for each button
  • Improved button press detection across multiple platforms
  • Added support for main and LKAS buttons on Hyundai platforms
  • Modified ACC main state handling

Testing:

  • Added comprehensive test coverage for MADS state transitions
  • Added new MADS-specific test base class for consistent testing across platforms
  • Added mutation testing for state management
  • Extended timeout for mutation tests from 5 to 8 minutes
  • Added extensive button press validation tests
  • Enhanced debugging output in replay drive tests

The refactored code provides a more organized implementation of MADS safety features while maintaining compatibility with existing safety checks.

Relates to:

@sunnyhaibin sunnyhaibin changed the title Feature: Modular Assistive Driving System (MADS) Modular Assistive Driving System (MADS) Nov 21, 2024
Updated the MADS safety tests to utilize the _speed_msg(0) function call in place of _user_brake_msg(False).
@devtekve devtekve marked this pull request as ready for review December 5, 2024 20:03
board/safety/safety_subaru.h Outdated Show resolved Hide resolved
board/safety/safety_toyota.h Outdated Show resolved Hide resolved
tests/libpanda/safety_helpers.h Outdated Show resolved Hide resolved
tests/libpanda/safety_helpers.h Outdated Show resolved Hide resolved
tests/safety/test_hyundai.py Outdated Show resolved Hide resolved
board/safety/safety_chrysler.h Outdated Show resolved Hide resolved
board/safety/safety_mazda.h Outdated Show resolved Hide resolved
board/safety/safety_subaru.h Outdated Show resolved Hide resolved
board/safety/safety_subaru_preglobal.h Outdated Show resolved Hide resolved
tests/safety_replay/replay_drive.py Outdated Show resolved Hide resolved
@sunnyhaibin sunnyhaibin merged commit 4c2ccd7 into master-new Dec 6, 2024
10 checks passed
@sunnyhaibin sunnyhaibin deleted the mads-new branch December 6, 2024 00:39
sunnyhaibin added a commit that referenced this pull request Dec 9, 2024
sunnyhaibin added a commit that referenced this pull request Dec 9, 2024
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.

2 participants