Commit Graph

2806 Commits

Author SHA1 Message Date
DevTekVE
4c2ccd7fe5 Modular Assistive Driving System (MADS) (#40)
* alternative experience

* safety init

* fix

* more update

* not really

* misra

* Add Custom MIT License (#38)

* brake check was not handled

* revert

* alt -> lkas

* explicit checks

* support toyota and ford

* rename

* hyundai can-fd support

* only allow lkas if enabled

* hyundai: main button handling

* revert

* hyundai: main button heartbeat

* add logging for controls allowed lateral

* fix panda safety

* ford btn

* toyota btn

* fca btn

* honda btn

* mads safety tests

* more tests

* safety misra

* safety mutation

* misra

* mutation experiment

* fix

* ford test main button

* ford test lkas button

* more ford test

* hyundai lkas and main

* more ford

* hyundai canfd

* rename

* rename

* cleaner

* more fixes

* more hyundai tests

* no longer needed

* thanks for tests!

* more tests for lat

* more explicit

* make sure to reset

* try this out

* probably needed

* move

* misra

* not needed

* move to safety_mads

* not really needed

* remove

* MADS: Refactor MADS safety with improved state management (pull request #46)

Refactor MADS safety with improved state management

This commit introduces a major refactoring of the MADS safety module, improving state management and control flow. Key changes include:

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.

* adding note

* adding ford (WIP)

* adding honda (WIP)

* adding toyota (WIP)

* adding chrysler (WIP)

* Standardize Button State Handling Across Platforms

Refactor button state handling by replacing integer constants with an enumerated `ButtonState` type and updating logic to improve readability and maintainability. This change affects button press detection in Ford, Honda, Hyundai, and Toyota safety modules and aligns them with a unified MADS button state approach. Enums provide a clearer understanding of button states and transitions, facilitating easier maintenance and future enhancements.

* Disable LKAS button press logic in Honda and Toyota safety.

The code for processing LKAS button presses has been commented out in both Honda and Toyota safety implementations. This change aims to investigate or temporarily halt the button press effects without removing the logic altogether. It will be important to test for any impacts this may have on vehicle control functionality.

* Remove commented out code in toyota_rx_hook function

This commit cleans up the toyota_rx_hook function by removing unnecessary commented-out code that checks for LKAS button presses on bus 2. This helps improve code readability and maintainability without altering the existing functionality.

* GM, mazda, nissan, subaru (global & preglobal)

* Honda LKAS

* Revert "Remove commented out code in toyota_rx_hook function"

This reverts commit d6b012c01a08118d91fad56c9f6ac2f92b671968.

* Toyota, Subaru Global LKAS

* nissan fix

* gm fix

* use speed msg to force rx

* im bored

* misra

* subaru/toyota/honda

* nope

* attempt

* go through all buttons

* try nissan

* more nissan

* nissan tests passed!

* subaru lkas test (not sure why it's not passing 2 and 3 values)

* Improved code organization in safety_subaru.h and test_subaru.py

This commit includes a minor restructuring in safety_subaru.h and test_subaru.py for better readability and flow. The condition check in safety_subaru.h for lkas_hud now has explicit parentheses. With regard to test_subaru.py, an unnecessary import was removed, and the sequence of steps in the test was reordered - now enabling mads and cleaning up mads_states happens before each subtest.

* Refactor tests to use _speed_msg instead of _user_brake_msg.

Updated the MADS safety tests to utilize the _speed_msg(0) function call in place of _user_brake_msg(False).

* Reworking the tests a little for clarity

* disabling lkas again on toyota temporarily

* fix mads condition to engage

* hyundai and honda good with new tests

* Redoing more tests

* update for safety tick ensuring mads control is exited while lagging

* Updating tests for toyota

* cleaning up tests on hkg

* commenting out temp_debug for future use

* revert

* constants

* cleanup

* format!

* match yota

* Apply suggestions from code review

* force

* explicit checks

* revert

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
2024-12-05 19:39:36 -05:00
Jason Wen
67b4fa2430 Sync: commaai/panda:master into sunnypilot/panda:master-new 2024-12-05 14:12:43 -05:00
Jason Wen
0399659922 Merge branch 'upstream/master' into sync-20241205 2024-12-05 13:48:19 -05:00
Robbe Derks
c7cc2deaf0 Cuatro: no ir (#2093)
no ir
2024-11-29 17:41:03 +01:00
Robbe Derks
4dc203376a more open drains (#2091)
also open drain

Co-authored-by: Comma Device <device@comma.ai>
2024-11-29 17:37:33 +01:00
Jason Wen
dc94921af8 Sync: commaai/panda:master into sunnypilot/panda:master-new 2024-11-23 10:15:11 -05:00
Adeeb Shihadeh
5761ab58ea what was that doing there? 2024-11-22 19:33:04 -08:00
Willem Melching
cfbc3ff835 Ensure auto switching FD is off in Python (#2087) 2024-11-22 10:29:11 -08:00
Jason Wen
226e9322bf Merge branch 'upstream/master' into sync-20241122 2024-11-22 09:19:44 -05:00
DevTekVE
97311d5057 Hyundai: Enhanced Smart Cruise Control (ESCC) (#39)
* Integrate Enhanced SCC (ESCC) support for Hyundai vehicles

Add support for ESCC in Hyundai vehicles by introducing the ESCC class and modifying the CarController, safety hooks, and radar interface. This enhancement allows better longitudinal control by leveraging ESCC data, ensuring more reliable Advanced Emergency Braking (AEB) and Forward Collision Avoidance (FCA) alerts. Additional configurations and safety parameters have been incorporated to support this functionality.

* common escc

* misra

* escc unit test

* 100%

* we don't check if using escc

* bump submodules

* unit test!

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
2024-11-22 09:03:06 -05:00
Maxime Desroches
b770745342 ci: split MISRA linter and MISRA mutation (#2086)
* sep

* this
2024-11-21 11:48:02 -08:00
Adeeb Shihadeh
2fbf0c5ff8 fix indendation 2024-11-21 11:07:57 -08:00
Willem Melching
4a11d52e07 Control over FD flag of CAN messages (#2085)
* Control over FD flag of CAN messages

* misra
2024-11-21 11:04:09 -08:00
Maxime Desroches
998a639360 python: catch exceptions in DFU (#2084)
* try

* also this
2024-11-20 19:22:14 -08:00
DevTekVE
623a7fad90 Merge pull request #41 from sunnypilot/activating-actions
ci: activate for sunnypilot and add additional branch
2024-11-19 20:34:26 +01:00
DevTekVE
36c5e06ec9 initial attempt at adjusting tests 2024-11-19 20:25:10 +01:00
Adeeb Shihadeh
422e3e0c0f H7 sound: fix noise with empty stream (#2083)
fix noise

Co-authored-by: Comma Device <device@comma.ai>
2024-11-18 14:50:17 -08:00
Robbe Derks
acc15afaa0 Fix sound playback artifacts (#2082)
this stays in sync

Co-authored-by: Comma Device <device@comma.ai>
2024-11-15 15:35:30 +01:00
Jason Wen
fdd7f946dc Add Custom MIT License (#38) 2024-11-15 08:14:24 +01:00
Adeeb Shihadeh
742d961b07 Lower siren duration to 3s (#2080) 2024-11-14 17:05:44 -08:00
Robbe Derks
a67f3650c8 Increase MISRA to 2min max (#2079)
increase to 2min max
2024-11-14 11:28:28 +01:00
Adeeb Shihadeh
39c966fb27 sound: little cleaner idle handling (#2078)
Co-authored-by: Comma Device <device@comma.ai>
2024-11-14 10:04:59 +01:00
Robbe Derks
dec9223f97 cuatro sound (#1861)
* fake siren works

* this receives something

* microphone in SAI1 POC

* this receives audio again

* double buffer DMA?

* RX DMA works

* wip

* needs cleanup, but this plays

* cleanup of playback

* print mic

* deal with stereo in

* the DMA from SAI1 -> SAI4 doesn't work yet

* this puts mic data in a buf

* this gets sound to the 845

* wip: still garbage from the mic

* inefficient, but it does record the mic

* sine isn't used

* comment out mic for now

* fix misra

* remove mic

* more cleanup

* add amp enable/disable

* no more debug

* newline

---------

Co-authored-by: Comma Device <device@comma.ai>
2024-11-13 16:09:13 +01:00
Adeeb Shihadeh
ae4f753582 spi: add helper for getting bootloader ID (#2074)
* spi: add helper for getting bootloader ID

* fix mypy

---------

Co-authored-by: Comma Device <device@comma.ai>
2024-11-07 16:55:30 -08:00
Radek
aab03bc4b6 Make can_print.py work on a all busses (#2070)
* Enable CAN3 printer (#1991) again

(cherry picked from commit 2b94e4fef7)

* print messages with same address but on different bus
2024-11-06 17:09:42 +01:00
Greg Hogan
991c844731 SocketPanda python library (#2073)
* SocketPanda python library

* fix spelling

* can0 should be the default

* CAN-FD support
2024-11-05 00:16:25 +00:00
Adeeb Shihadeh
0b364ece1e tres: fix I2C hang on fake siren init (#2069)
* fix i2c hang

* misra fix

---------

Co-authored-by: Comma Device <device@comma.ai>
2024-10-30 16:53:17 -07:00
Robbe Derks
352e7ff138 cuatro beeper (#2068)
beeper works

Co-authored-by: Comma Device <device@comma.ai>
2024-10-30 16:18:01 +01:00
Shane Smiskol
3066f93d8a Ford: higher curvature rate limits at low speed (#2065)
* use closer to EPS limits

* raise to upper bound of spread from injection plot

* we've seen ~0.009 at 7 m/s, so allow that

* fix test

* rounding errors cause the 2 to round to the same value

* adjust for latest opendbc change

* we should actually match what safety is doing! fix lack of test coverage near first brake point

fix

* and fix test
2024-10-25 23:27:33 -07:00
Shane Smiskol
2bd2f2a702 Ford: check longitudinal actuation bits (#2067)
ford long: check brake actuation bits
2024-10-25 14:11:53 -07:00
Adeeb Shihadeh
8422a7437f python: open SPI device once (#2066)
Co-authored-by: Comma Device <device@comma.ai>
2024-10-24 13:27:49 -07:00
Maxime Desroches
9aec4294cc ci: test building in release mode (#2062)
* build

* space

* better
2024-10-18 14:10:54 -07:00
Maxime Desroches
2b9458e8a6 ci: run build_socketcan only on push to master and pull_request (#2063)
push on master
2024-10-18 13:08:14 -07:00
Lukas
e2c076cab8 Remove retry can_send_many loop (#2060)
* remove retry loop from can_send_many

* while condition
2024-10-14 21:24:22 -07:00
Jason Young
abdc41856b Toyota: 2021+ RAV4 Prime (#2042)
* from @pd0wm commaai/panda#1841

* diff reduction: won't need the flag rename

* run tests with new DBC and new gas/brake messages

* toyota_secoc_car to global

* consolidate alt_brake_101

* consolidate alt_pcm_cruise_176

* consolidate alt_gas_pedal_116

* don't allow transmit/forward for 0x131 unless SecOC

* cleanup and todo

* diff reduction

* reorder by usage frequency

* test for no LTA actuation

* bump opendbc commit ref in Dockerfile

* gate SecOC variant on ALLOW_DEBUG

* tweak gating for MISRA

* mutation test hates lta_angle surviving various changes

* common rx checks styling

* don't allow short version of 0x2E5 for SecOC mode

* whitespace diff reduction

* secoc_car -> secoc

* fix comment typo

* retry CI

* missed a couple secoc_car -> secoc

* one big secoc/not-secoc block

* genuinely useful MISRA warning

* test both STEERING_LTA and STEERING_LTA_2

* comment labeling for STEERING_LTA_2 signals

* Update board/safety/safety_toyota.h

Co-authored-by: Shane Smiskol <shane@smiskol.com>

* STEERING_LTA and STEERING_LTA_2 consistency

* update gas/brake/cruise signal annotations

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
2024-10-04 11:22:18 -07:00
dzid26
c77d3832ba use logger info instead of warning 2024-10-03 21:53:09 +01:00
Maxime Desroches
2fa1cf5eff mutation tests: remove buggy mutation op 2024-10-02 21:27:40 -07:00
Maxime Desroches
47f8416942 mutation test: add more ops (#2059)
* log

* more
2024-10-02 21:19:17 -07:00
Radek
fab8d0bb4a CAN print improvement (#2052)
* Jungle spam can.

* Print all busses by default.  Prettier print.

* can_health printer

* colors on can error
2024-10-02 12:53:32 -07:00
Maxime Desroches
f5e1900537 mutation tests: remove cxx_assign_const op (#2053)
* no 42

* last one
2024-10-01 19:05:39 -07:00
commaci-public
b69d31cd29 pre-commit: autoupdate hooks (#2051)
Update pre-commit hook versions

Co-authored-by: adeebshihadeh <adeebshihadeh@users.noreply.github.com>
2024-10-01 10:14:12 -07:00
Maxime Desroches
08c95bf47b mutation tests: activate all mutation ops (#2047)
* all

* clean

* cleaner

* WORKING

* test

* cleanup
2024-09-26 19:37:59 -07:00
Maxime Desroches
b6644f7a35 revert libpanda with clang (#2044)
* revert

* adapt this
2024-09-26 12:35:45 -07:00
Maxime Desroches
78b49ab155 safety mutation tests (#2040)
* mutation

* clone

* origin

* get diff

* better example

* better

* fix docker

* work on push

* make test fail

* real change

* test all modes

* ignore

* better

* reco

* fix

* no libpanda on device

* curl

* nl

* nl again

* delete

* clean

* clean

* this

* add this back

* cleanup
2024-09-25 21:56:09 -07:00
Maxime Desroches
fb67bda00e compile libpanda with clang (#2041)
* clang

* report

* safety.h

* fix lines

* cleaner

* better

* remove this

* revert this

* fix

* tici build

* revert

* revert

* fix
2024-09-25 20:14:12 -07:00
Radek
38cab7d501 Add multiple pandas selector (#2015)
* multiple Panda cli helper

* Don't flash all pandas by default. Use --all arg to flash all.
2024-09-24 16:37:23 -07:00
Maxime Desroches
2037a2ead7 Fix openpilot build (#2039)
* static

* test

* revert
2024-09-24 11:59:17 -07:00
Maxime Desroches
afafb0ba46 test misra 8.7 and 8.4 (#2035)
check
2024-09-20 19:38:45 -07:00
Maxime Desroches
209f7ab09f misra8.4: safety.h + safety_declarations.h (#2022)
* safety

* static!

* ALLOW_DEBUG

* fix

* fix 12.3

* remove comment

* no debug

* move stuff to debug

* only usage

* cleanup

* canfd hyundai

* no include for now

* indent

* comment for ford suppression

* also gm

* remove suppression

* only safety headers

* cleanup
2024-09-20 19:25:37 -07:00
Maxime Desroches
ac9c1b3b3f misra8.7 (#2033)
* 8_7

* fix test
2024-09-20 15:51:27 -07:00