Commit Graph

272 Commits

Author SHA1 Message Date
Jason Wen
9adc1717dc Revert "Modular Assistive Driving System (MADS) (#40)" (#54)
This reverts commit 4c2ccd7fe5.
2024-12-09 18:35:11 -05:00
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
0399659922 Merge branch 'upstream/master' into sync-20241205 2024-12-05 13:48:19 -05: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
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
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
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
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
Radek
8545c68e4d Fix USB errors (#2011)
Fix LIBUSB_ERROR_PIPE [-9] when resetting over USB hubs or jungle V2
2024-09-13 15:12:35 -07:00
dzid26
2b94e4fef7 Enable CAN3 printer (#1991)
* panda has 3 can peripherals

* enable printing CAN3
2024-08-26 17:15:29 -07:00
Shane Smiskol
1cbcc13c35 use and configure custom logger (#1994)
* prepare to log logs

* utils

* discoverability

* forgot
2024-08-05 14:51:56 -07:00
Shane Smiskol
8c3bb0151e deprecate busTime (#1989)
* deprecate busTime

* fix test_comms.py

* update opendbc

* way more than i thought

* and here

* oops
2024-07-30 21:20:48 -07:00
Adeeb Shihadeh
2b70e283c1 tres: lower SOM reset timeout (#1945)
* tres: lower SOM reset timeout

* update test
2024-05-03 14:03:54 -07:00
Adeeb Shihadeh
6f9e2c5159 show USB list + connector errors 2024-04-23 20:39:40 -07:00
Adeeb Shihadeh
a727cecdb8 remove unused deepsleep stuff (#1914) 2024-03-22 14:48:49 -07:00
Adeeb Shihadeh
dd82382d5f instant boot (#1910)
no more boot time :P
2024-03-22 14:01:44 -07:00
Adeeb Shihadeh
8a845b973e boot time test (#1909)
* test

* usb serial

* just test for now

* time

* close

* close after
2024-03-21 20:28:44 -07:00
Adeeb Shihadeh
de061e4f73 remove rest of gmlan (#1908)
* remove rest of gmlan

* fix

* update struct

* update
2024-03-21 13:56:36 -07:00
Adeeb Shihadeh
567dbfe6d8 remove comma pedal (#1902) 2024-03-17 22:22:46 -07:00
Adeeb Shihadeh
6dfd4db4ab remove rtc (#1897)
* remove rtc

* fix build

* rm taht

* revert that
2024-03-11 16:08:43 -07:00
Robbe Derks
41e9610ff8 Tesla Raven (#1886)
* raven uses a different steering angle sensor

* add raven flag

* raven test

* bump opendbc ref
2024-03-06 21:13:13 +01:00
Cameron Clough
0c7d5f11d7 use pyupgrade to update syntax (#1889) 2024-02-24 13:56:28 -08:00
Adeeb Shihadeh
c076a9f2f6 remove pedal fw (#1872)
* remove pedal fw

* little more

* one more

* and tests

* rest of it

* little more

* fix linter

* more fix
2024-02-16 22:58:01 -08:00
Willem Melching
eb9b0df727 Reset baudrate when connecting from Python (#1837)
* Reset baudrate when connecting from Python

* unused
2024-01-25 13:17:19 -08:00
Adeeb Shihadeh
a0ac220b0c it's cuatro 2024-01-24 13:07:47 -08:00
Adeeb Shihadeh
a2d5d8ad07 stm32h723 (#1832)
* booting

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai>
2024-01-23 23:15:59 -08:00
Adeeb Shihadeh
41b008274b pre-commit: autoupdate hooks (#1789)
* Update pre-commit hook versions

* fix

---------

Co-authored-by: adeebshihadeh <adeebshihadeh@users.noreply.github.com>
2024-01-17 11:35:20 -08:00
Adeeb Shihadeh
08ca10e91c add AEB enable flag (#1791) 2024-01-11 15:37:43 -08:00
Shane Smiskol
bb75afc84e safety: add safety param for gas interceptor (#1735)
* some refactoring still needing to be done here

* 50hz

* set rx checks

* tx msgs

* test

* fix

* forgot to check this since it's static now

* enable_gas_interceptor

* more

* remove int funcs since are common

* generic!

* not generic

* need to set counter now

* set_enable_gas_interceptor not needed

* already reset in safety init

* fix test

* remove gas_interceptor_detected (partly)

* oof need for hjonda too

* edit structs

* more honda (still broken)

* fix typo

* shift these down

* can also make this extensible

* stash

* defining classes is much simpler, maybe in future we will have some sort of wrapper after some more thought

* remove create_interceptor_test now

* add lta interceptor

* clean up print

* clean up

* once

* type hint

* rm

* no interceptor with stock long + good test

* add interceptor counter to honda

* need alt interceptor + set rx checks for honda

* we were never testing button enable with nidec + interceptor!

honda almost all passing

* these fixes make sense

* clean up

* better

* clean up test cov

* clean up

* not needed

* fix tx msgs

* clean up

* cppcheck

* fix

* unnecessary
2023-12-14 15:22:17 -08:00
Adeeb Shihadeh
6eb89cefdf board: remove set_phone_power (#1747) 2023-11-25 13:17:08 -08:00
Adeeb Shihadeh
4c0d2505b7 remove k-line driver (#1743) 2023-11-23 17:09:10 -08:00
Adeeb Shihadeh
a1d699b87d SOM boot recovery (#1712)
* reset

* simpler

* only once per panda boot

* cleanup

* also check serial
2023-11-09 18:01:46 -08:00
Jason Wen
3f25ccabd6 Subaru Pre-Global: Reverse driver torque signal for certain platforms (#1648)
* Subaru Pre-Global: Reverse driver torque signal for certain platforms

* added flag

* fix tests

* use dbc instead

* duplicate

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
Co-authored-by: Justin Newberry <jnewberry0502@gmail.com>
Co-authored-by: Justin Newberry <justin@comma.ai>
2023-11-08 15:27:20 -08:00
Adeeb Shihadeh
aaa1172fa2 HITL bootkick tests (#1685)
* HITL bootkick tests

* both bootkick cases

* more

* som use gpio

* cleanup

* pretty reliable now
2023-10-06 13:38:35 -07:00
Adeeb Shihadeh
f42b65ca32 skip flash if up to date (#1686)
* skip flash if up to date

* fix
2023-10-05 13:13:40 -07:00
Adeeb Shihadeh
b6e37f25b6 Remove flash logging (#1674)
* Revert "Disable flash logging (#1667)"

This reverts commit 62db60595b.

* Revert "Faster log retrieval (#1484)"

This reverts commit 694aae9c26.

* Revert "Flash bounds checking outside of bootstub (#1459)"

This reverts commit 054344de6b.

* Revert "Logging (#1445)"

This reverts commit 0cc91a7f7b.

* cleanup

* cleanup
2023-09-30 12:49:46 -07:00
Adeeb Shihadeh
d87d33cb51 pre-commit: autoupdate hooks (#1639)
* Update pre-commit hook versions

* fix

---------

Co-authored-by: adeebshihadeh <adeebshihadeh@users.noreply.github.com>
2023-09-07 19:10:30 -07:00
Jason Wen
39bc5a4886 Nissan Altima: add a param for alternate EPS bus (#1649)
* Nissan Altima: Specify panda flag for alt bus safety config

* test this safety mode

* test this safety mode

* rm

* nl

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
2023-09-06 00:46:33 -07:00
Adeeb Shihadeh
a4fa40a713 python: show lib and fw versions in error (#1622)
* python: show lib and fw versions in error

* fix

* cleanup
2023-08-30 10:56:30 -07:00
Adeeb Shihadeh
bc2f10da57 Revert "pre-commit: autoupdate hooks (#1618)"
This reverts commit 526588b3e9.
2023-08-30 10:38:12 -07:00
Adeeb Shihadeh
526588b3e9 pre-commit: autoupdate hooks (#1618)
* Update pre-commit hook versions

* fix ranges

---------

Co-authored-by: adeebshihadeh <adeebshihadeh@users.noreply.github.com>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
2023-08-30 01:27:07 -07:00
Jason Wen
e6c1648835 Hyundai CAN-FD: Alternate LKAS steering message (#1504)
* new steering message!

* fix

* check tx

* fix var

* allow all tx to test LFA suppression

* Attempt to block laneline information to suppress LFA

* Try 0x364

* Block all bus 2/6 messages

* Final test to block LFA

* Fix tx

* in another PR

* cleanup

* lint

* Add new tx to unit test

* linter

* Apply suggestions

* Revert to this

* Unnecessary

* clean up

* rename to hda2

* prototype

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
2023-08-29 23:40:14 -07:00
Adeeb Shihadeh
09cd81752d python lib: close USB context properly (#1606)
* python lib: close USB context properly

* fix jungle

* rm that

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-08-24 19:15:37 -07:00
Justin Newberry
3d91d78018 Revert "Subaru: infrastructure to support the new angle based control… (#1601)
Revert "Subaru: infrastructure to support the new angle based controllers (#1590)"

This reverts commit ea16a54166.
2023-08-22 17:30:11 -07:00
Justin Newberry
ea16a54166 Subaru: infrastructure to support the new angle based controllers (#1590) 2023-08-22 00:21:19 -07:00
Justin Newberry
8bd3e93813 Subaru: Global gen1 longitudinal safety (#1500)
* Add subaru long TX and RX messages

* misra c2012 fix

* fix tests

* Reorder signals

* increase max steering torque

* merge fix

* merge fix, remove cnt from test

* Move subaru logitudinal behind flag, add safety test

* update subaru_longitudinal checks

* cleanup

* Add subaru longitudinal checks

* misra fix

* Add subaru rpm and throttle rate limit checks

* temporary disable cruise throttle and cruise rpm checks

* update subaru long test

* update longitudinal safety and add tests

* fix tests

* fix misra

* subaru long signals limits checks

* Add controls_allowed to long tests

* remove unused variables

* Add AEB passthru and tests

* Add bus

* Update AEB logic

* Add GEN2 AEB support

* syntax fix

* Update AEB tests

* Add comment for subaru_aeb

* Do not check cruise_throttle and cruise_rpm limits when gas pressed

* use long limits struct

* Subaru: longitudinal checks only when controls_allowed, use ES_LKAS_State LKAS_Alert for AEB

* fix misra, set controls_allowed for es_brake test

* fix misra

* Fix es_brake violation check

* Add 0x323 to longitudinal test

* Remove stock fcw from aeb signals

* Use GET_BYTES

* Revert "export FW_PATH"

This reverts commit 2a5058d858.

* Revert "cleanup fw filename conventions (#1434)"

This reverts commit 4dd2735e38.

* Revert "Revert "export FW_PATH""

This reverts commit 86e8d321d055c5f89cde7ee26a0014df1bcd5b39.

* Revert "Revert "cleanup fw filename conventions (#1434)""

This reverts commit 5aae6716fa5506aac49dadd287229a45f0a3b94e.

* cleaned up safety

* cleanup subaru long safety

* subaru_aeb -> stock_aeb for other platforms

* fix unittests

* pretty

* need to upload this route

* remove AEB stuff for now

* remove unrequired rpm checks

* add comment

* added comment about acceleration and use throttle limit for rpm too

* inactive_throttle_fix

* Update board/safety/safety_subaru.h

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

* added comments about long limits

* increase max brake

* revert that

* cleanup

* rename throttle to gas

* add safety replay

* remove todo

* rename throttle to gas

* move subaru stuff out of common test

* PR cleanup

* added min gas

* reduce initial complexity by not intercepting cruisecontrol or brake_status

* create common gas brake safety test

* remove unrelated subaru reference

* also test below min_value

* fix fwd hook test

* better name and hardcoded

* use same as acceleration limits

* revert gm

* remove callable

* also limit rpm

* remove safety replay for now

* revert unrelated changes

* pr cleanup

* remove unused gasbrake safety test

* fix ruff linter

* PR cleanup

* pr cleanup?

* added common brake test and moved generic test to base safety class

* remove duplicate test

* wip

* wip

* rename longitudinalaccelsafety

* revert limits correct test

* fix controls allowed test

* move gm over to long gas brake test

* assert that limits are reasonable

* fix typing

* fix linter again

* fix linter again

* fix linter again

* like to make it clear

* typo

* fix from merge

* clearer names

* dont need thesemore

* subaru: use common test

* fix merge issue

* inactive gas from long limits

* fix tests

* linter

* fix gen2

* fix linter

* also test torque when doing long control

* renamre transmision rpm

* consistent whitespace

* rename declarations too

* rename transmission rpm

* same line

* actually is transmission rpm

---------

Co-authored-by: Martin Lillepuu <martin@mlp.ee>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
2023-08-15 18:51:13 -07:00