Compare commits

...

216 Commits

Author SHA1 Message Date
DevTekVE a77d1f7eb0 Add ButtonHoldTracker for button hold logic and tests
Introduce a new `ButtonHoldTracker` class to manage button hold durations, replacing manual timer handling in `ExperimentalSwitcher`. Updated `ExperimentalSwitcher` to leverage this implementation for cleaner and more modular code. Added comprehensive unit tests for both `ButtonHoldTracker` and `ExperimentalSwitcher` to ensure functionality and edge case coverage.
2025-01-19 12:58:29 +01:00
Jason Wen 6eb6af5785 Merge branch 'dec-redo' into master-dev-c3-new 2025-01-19 03:39:30 -05:00
Jason Wen 7471bd4029 init 2025-01-19 03:18:05 -05:00
Jason Wen 767f057112 Merge branch 'master-new' into dec-redo 2025-01-19 02:55:46 -05:00
Jason Wen 6ef47dafcf ui: display DEC status via mode button (#592) 2025-01-19 02:54:58 -05:00
Jason Wen 3f6ac7e77a Merge branch 'ui-model-selector-rich' into master-dev-c3-new
# Conflicts:
#	opendbc_repo
#	panda
2025-01-19 02:51:06 -05:00
Jason Wen d8040eea3f Merge branch 'master-new' into ui-model-selector-rich 2025-01-19 02:50:22 -05:00
Jason Wen 155f9ee3b9 bump submodules 2025-01-19 02:50:02 -05:00
Jason Wen d223135ee3 Merge branch 'master-new' into ui-model-selector-rich 2025-01-19 02:49:13 -05:00
Jason Wen 073887221d MADS: Honda: controls, events, and cluster updates (#589)
* MADS: Honda: Cluster icons and events updates

* bump opendbc

* nuke them all to test

* try this

* bring them back

* fix icons

* MADS: Honda: Allow steering

* rename

* match stock

* bump submodules
2025-01-19 02:48:53 -05:00
Jason Wen 8f29ddba45 ui: Model Selector: display prompt with rich text widget 2025-01-19 02:48:32 -05:00
Jason Wen b7c3072a4c Merge branch 'mads-honda-states' into master-dev-c3-new 2025-01-18 23:57:32 -05:00
Jason Wen 3cba24f93a MADS: Honda: Allow steering 2025-01-18 23:57:05 -05:00
Jason Wen f2edd589ba fix 2025-01-18 22:04:30 -05:00
Jason Wen bf0a7b4494 migrate to sp only 2025-01-18 22:02:40 -05:00
Jason Wen 19b96003dc use another method for drawing 2025-01-18 21:51:49 -05:00
Kumar 10ee25d199 Update constants.py 2025-01-18 19:48:02 -07:00
Kumar cd6fb642bd Update dec.py 2025-01-18 19:46:19 -07:00
Jason Wen 3d35164287 even dimmer 2025-01-18 21:43:14 -05:00
Jason Wen a9ca9bbdf8 should be active and dimmer 2025-01-18 21:35:27 -05:00
Jason Wen 0737f311b8 add opacity 2025-01-18 21:31:01 -05:00
Jason Wen dc45d3043c try this 2025-01-18 21:22:55 -05:00
Jason Wen 2eefd0aaf5 visuals for DEC 2025-01-18 21:12:19 -05:00
Jason Wen cb9d92dc3c Merge branch 'master-new' into dec-redo 2025-01-18 20:55:35 -05:00
Jason Wen 2525fdc350 Merge branch 'mads-honda-states' into master-dev-c3-new 2025-01-18 20:41:18 -05:00
Jason Wen 9eb36a0b7e fix icons 2025-01-18 20:41:01 -05:00
Jason Wen b5a5d94a2c bring them back 2025-01-18 20:39:05 -05:00
Jason Wen 36453f2014 Sync: commaai/openpilot:master into sunnypilot/sunnypilot:master-new (#590) 2025-01-18 19:19:51 -05:00
Jason Wen 2792ce472a Merge branch 'upstream/openpilot/master' into sync-20240118
# Conflicts:
#	cereal/custom.capnp
#	cereal/log.capnp
2025-01-18 18:54:56 -05:00
Jason Wen a93dc0047d Merge branch 'mads-honda-states' into master-dev-c3-new 2025-01-18 16:35:34 -05:00
Jason Wen 25d195df72 try this 2025-01-18 16:35:27 -05:00
Jason Wen 3fc2f70eb8 nuke them all to test 2025-01-18 16:34:32 -05:00
Adeeb Shihadeh ae58be87bc cereal fork compatibility (#34414)
* more custom

* cleanup

* lil more
2025-01-18 13:29:02 -08:00
Adeeb Shihadeh f0257a847d Update README.md 2025-01-18 13:27:11 -08:00
Jason Wen 64058c4b7c Merge branch 'mads-honda-states' into master-dev-c3-new 2025-01-18 15:48:12 -05:00
Jason Wen 3044aa6133 bump opendbc 2025-01-18 15:48:01 -05:00
Jason Wen f39f76182a Merge branch 'mads-honda-states' into master-dev-c3-new 2025-01-18 15:45:07 -05:00
Jason Wen 15567bf605 Merge branch 'master-new' into master-dev-c3-new 2025-01-18 15:45:02 -05:00
Jason Wen 3b090e0b01 Merge branch 'master-new' into mads-honda-states 2025-01-18 15:44:51 -05:00
Jason Wen df3e848965 MADS: Honda: Cluster icons and events updates 2025-01-18 15:43:46 -05:00
Jason Wen 4e6cc1f3bc ui: Hide regulatory button on non-comma devices (#585)
Co-authored-by: DevTekVE <devtekve@gmail.com>
2025-01-18 20:22:15 +00:00
DevTekVE b3e3d1b384 Fix lead detection fallback for weighted average check.
Add a fallback value of -1 when computing the weighted average to prevent errors caused by invalid or None values. This ensures robust lead detection and avoids potential crashes or undefined behavior.
2025-01-18 20:48:06 +01:00
DevTekVE b13356d267 Merge branch 'master-new' into dec-redo 2025-01-18 20:41:04 +01:00
Calvin Park 5509850986 Install user SecOCKey to params (#34401)
* Install user SecOCKey to params

* Move it to launch_chffrplus.sh/launch

* Move it to card.py

* Basic error check

* Catch Exception to suppress the linter

* Make it local to secOC section
2025-01-18 11:25:07 -08:00
Dean Lee 7a1bf26aa5 ui: prevent device pairing if no internet or system time is invalid (#34403)
* gate pairing device if system time is invalid

* update translations

* Check for internet connectivity

* Update selfdrive/ui/qt/widgets/prime.cc

* Update selfdrive/ui/qt/widgets/prime.cc

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2025-01-18 11:18:45 -08:00
rav4kumar 0089096d12 Update slow-down logic and constants for improved behavior
Adjust the slowdown scaling factor and anomaly handling to refine behavior without abrupt resets. Modify constants to increase window size and adjust probabilities and distances for smoother adaptation. Update version to reflect the new changes.
2025-01-18 11:26:02 -07:00
rav4kumar 3d135f9831 Revert "dec: how good is FirstOrderFilter?"
This reverts commit 01e06df542.
2025-01-18 11:12:10 -07:00
rav4kumar a219046981 Revert "Update dec.py"
This reverts commit 3f29ccbd99.
2025-01-18 11:12:03 -07:00
rav4kumar 2c9ffdbf03 Revert "dec: faster ?"
This reverts commit 40259cd22a.
2025-01-18 11:11:57 -07:00
DevTekVE f5764c2edf ci: release drafter sort by default (time)
Using sort by title made things look out of order. If we want to organize them a bit furter, we can do that manually before moving forward with a release.
2025-01-18 15:16:43 +01:00
DevTekVE 027023a7ff CI: Update release drafter config (#588)
* Remove contributors section from release drafter template

The contributors section has been removed to simplify the release notes format. This change ensures a cleaner and more focused release draft template.

* Update release-drafter config with new labels and options

Added 'exclude-labels' to filter out 'no-changelog' items and improved category settings with 'collapse-after'. Introduced 'sort-by' for title-based sorting to enhance organization.
2025-01-18 15:10:13 +01:00
DevTekVE da980312d9 Add Release Drafter configuration and workflow (#586)
* Add configuration files for Release Drafter

This commit introduces two configuration files for the Release Drafter. These include release-drafter.yml which will help categorize changes into features, bug fixes, and maintenance, and workflows/release-drafter.yml which defines a GitHub actions workflow to update release drafts.

* Work on both master branches

* Meh static and i dont need this tbh
2025-01-18 14:29:20 +01:00
Shane Smiskol 895c78b09a Revert "bump msgq (#34410)"
This reverts commit 4dc95f6064.
2025-01-17 21:17:05 -08:00
Shane Smiskol 4dc95f6064 bump msgq (#34410)
* bump msgq

* bump
2025-01-17 20:39:14 -08:00
Jason Wen 5014b42650 Merge branch 'ui-regulatory-hide' into master-dev-c3-new 2025-01-17 21:48:20 -05:00
Jason Wen c1f897168a ui: Hide regulatory button on non-comma devices 2025-01-17 21:45:51 -05:00
Jason Wen 1a3f86a542 ui: Transition offroad state for Device panel buttons (#584) 2025-01-18 02:38:29 +00:00
Jason Wen 301174b19a Merge branch 'ui-device-offroad' into master-dev-c3-new 2025-01-17 21:29:58 -05:00
Jason Wen 1b139c4ca1 ui: Transition offroad state for Device panel buttons 2025-01-17 21:29:46 -05:00
Jason Wen 745e7b0b28 Merge branch 'master-new' into master-dev-c3-new 2025-01-17 21:23:34 -05:00
Jason Wen ac255742b6 MADS: Toyota: remove LKAS button support (#583)
* MADS: Toyota: remove LKAS button support

* remove mads button test

* bump submodules

* bump submodules

* test_processes: update ref logs to 4b12690
2025-01-17 19:22:50 -07:00
Jason Wen 1f328c9fda Revert "ui: driver view window should use uiStateSP"
This reverts commit c08b18936d.
2025-01-17 15:02:49 -05:00
Jason Wen eab69c0f3d Revert "try this"
This reverts commit bd8a93af8b.
2025-01-17 15:02:47 -05:00
Jason Wen 97fda2f918 Revert "more"
This reverts commit 2f5f708c2b.
2025-01-17 15:02:44 -05:00
Jason Wen 03e10db82e Merge branch 'ui-dm-cam-freeze' into master-dev-c3-new 2025-01-17 14:59:14 -05:00
Jason Wen 2f5f708c2b more 2025-01-17 14:59:06 -05:00
Jason Wen 413fc15cf8 Merge branch 'ui-dm-cam-freeze' into master-dev-c3-new 2025-01-17 14:52:54 -05:00
Jason Wen bd8a93af8b try this 2025-01-17 14:52:42 -05:00
Jason Wen 928bec2acc Merge branch 'ui-dm-cam-freeze' into master-dev-c3-new 2025-01-17 14:37:39 -05:00
Jason Wen c08b18936d ui: driver view window should use uiStateSP 2025-01-17 14:37:23 -05:00
Jason Wen d15d56b161 sentry: log fingerprints and save exceptions (#581)
* sentry: log fingerprints and save exceptions

* no point

* remove unused imports

* use deprecated

* have to do this

* remove

* cap

* no duplicate

* typo

* don't use deprecated method

* wrap them around

* do this instead

* new endpoint

* no need
2025-01-17 17:22:45 +00:00
Jason Wen 5f94110b7a no need 2025-01-17 12:12:51 -05:00
Jason Wen bca0e7862f Merge branch 'sentry-sp' into master-dev-c3-new 2025-01-17 12:03:17 -05:00
Jason Wen 45c47d0c48 new endpoint 2025-01-17 12:01:11 -05:00
Jason Wen ab8dd45cda do this instead 2025-01-17 10:57:06 -05:00
Jason Wen 66eb3a2532 wrap them around 2025-01-17 10:47:25 -05:00
Jason Wen 59b68e42f6 don't use deprecated method 2025-01-17 10:29:17 -05:00
Jason Wen 976c9ac9bf typo 2025-01-17 02:40:27 -05:00
Jason Wen c65c8a535c no duplicate 2025-01-17 02:39:51 -05:00
Jason Wen 5e79eb774b Merge branch 'sentry-sp' into master-dev-c3-new 2025-01-17 02:06:22 -05:00
Jason Wen 0735fd5553 Merge branch 'dec-redo' into master-dev-c3-new 2025-01-17 02:06:17 -05:00
Jason Wen 5ad8b46158 cap 2025-01-17 02:04:59 -05:00
Jason Wen 3f4e372c34 remove 2025-01-17 01:55:15 -05:00
Jason Wen 7fde68ecf9 have to do this 2025-01-17 01:48:43 -05:00
Jason Wen df1ef23280 use deprecated 2025-01-17 01:41:54 -05:00
Jason Wen 378eb8a4d2 remove unused imports 2025-01-17 01:39:15 -05:00
rav4kumar 40259cd22a dec: faster ? 2025-01-16 23:25:55 -07:00
Kumar 3f29ccbd99 Update dec.py 2025-01-16 23:25:45 -07:00
Jason Wen 189e883116 no point 2025-01-17 01:23:04 -05:00
rav4kumar 01e06df542 dec: how good is FirstOrderFilter? 2025-01-16 23:16:54 -07:00
rav4kumar b1e8824187 revert smooht lead for now 2025-01-16 23:16:00 -07:00
Jason Wen cb1240846b sentry: log fingerprints and save exceptions 2025-01-17 01:15:22 -05:00
Shane Smiskol c515021576 joystick: fix long control state 2025-01-16 16:07:56 -08:00
Shane Smiskol 733206fdd9 fix joystick 2025-01-16 16:06:11 -08:00
Jason Wen fa6ee806f5 Merge branch 'long-distance-btn-exp-mode' into master-dev-c3-new 2025-01-16 18:04:09 -05:00
Jason Wen fefb6a3a25 Merge branch 'dec-redo' into master-dev-c3-new 2025-01-16 18:04:03 -05:00
Jason Wen 13cb725652 Merge branch 'master-new' into long-distance-btn-exp-mode 2025-01-16 18:03:35 -05:00
Jason Wen b219e07ac1 Merge branch 'master-new' into dec-redo
# Conflicts:
#	selfdrive/car/card.py
2025-01-16 18:03:13 -05:00
Jason Wen 429b461eae Sync: commaai/openpilot:master into sunnypilot/sunnypilot:master-new (#580) 2025-01-16 18:00:26 -05:00
Shane Smiskol 1d919221e4 Update build.py 2025-01-16 14:52:26 -08:00
Shane Smiskol 37b4e61b00 Allow brake hold (#34384)
* allow brake hold

* rev
2025-01-16 14:22:02 -08:00
Jason Wen ce3c55c691 test_processes: update ref logs to afde277 2025-01-16 17:13:53 -05:00
Jason Wen afde2771f8 Merge branch 'upstream/openpilot/master' into sync-20250116
# Conflicts:
#    .github/workflows/ui_preview.yaml
#    opendbc_repo
#    panda
#    release/release_files.py
#    selfdrive/test/process_replay/ref_commit
#    selfdrive/ui/tests/test_ui/run.py
2025-01-16 17:12:53 -05:00
Jason Wen 90d38a7968 fix tests 2025-01-16 14:24:27 -05:00
Jason Wen bb83e1fe8f Merge branch 'dec-redo' into master-dev-c3-new 2025-01-16 12:09:28 -05:00
Jason Wen baf0506033 use walrus (needs cleanup) 2025-01-16 12:08:15 -05:00
Jason Wen a3db53044e fix wrong typing and variable name 2025-01-16 12:00:20 -05:00
Jason Wen 8673c31e46 Revert "use walrus for None"
This reverts commit 5f2396d490.
2025-01-16 11:59:13 -05:00
Jason Wen 5f2396d490 use walrus for None 2025-01-16 11:56:07 -05:00
Shane Smiskol 0539df7685 bring back ui.py (#34396)
* bring back uipy

* fix it

* fix
2025-01-15 18:50:44 -08:00
Adeeb Shihadeh a2ced8c8eb Log satellite count in GpsLocationData (#34395)
* Log satellite count in GpsLocationData

* update refs

* forgot to build
2025-01-15 16:53:39 -08:00
Shane Smiskol 69d33ac11d Toyota: allow brake hold (#34394)
toyota okay
2025-01-15 15:03:22 -08:00
Maxime Desroches 707a845218 fix uv (#34393)
uv fix
2025-01-15 14:23:58 -08:00
Adeeb Shihadeh db61cfb2c1 Update RELEASES.md 2025-01-15 14:20:54 -08:00
Adeeb Shihadeh 3f629e97eb release this month 2025-01-15 13:54:58 -08:00
Jason Wen e2ff34417f Merge branch 'dec-redo' into master-dev-c3-new 2025-01-15 15:12:39 -05:00
Jason Wen 4ac4fc855f don't set to exp mode initial if DEC is active 2025-01-15 15:12:13 -05:00
Jason Wen cea20d1945 Merge branch 'long-distance-btn-exp-mode' into master-dev-c3-new 2025-01-15 13:41:45 -05:00
Jason Wen 353aa611e7 Merge branch 'dec-redo' into master-dev-c3-new
# Conflicts:
#	sunnypilot/selfdrive/controls/lib/longitudinal_planner.py
2025-01-15 13:41:22 -05:00
Jason Wen 391a3160a0 no need 2025-01-15 11:00:08 -05:00
Jason Wen 6b4ef00ae6 fix 2025-01-15 10:57:51 -05:00
Jason Wen d937062724 more 2025-01-15 01:51:22 -05:00
Jason Wen f94eeb9780 Revert "explicit type hints"
This reverts commit c205497b
2025-01-15 01:46:31 -05:00
Jason Wen c6474fc3ad move to constants py 2025-01-15 01:45:29 -05:00
Jason Wen d7f0e8dd04 unused 2025-01-15 01:28:15 -05:00
Jason Wen f3d94fc291 Longitudinal: Distance button hold to toggle Chill/Experimental Mode 2025-01-15 01:26:23 -05:00
Shane Smiskol 2258ea310d Hyundai: match cancel button panda safety logic (#34390)
* rising edge

* should work

* TODO

* fix
2025-01-14 21:37:55 -08:00
Jason Wen c205497b15 explicit type hints 2025-01-15 00:18:47 -05:00
Shane Smiskol 38fad751cb card: fix cruise speed initialization w/ buttons (#34386)
* fix initialize w/ buttons

* what

* comment
2025-01-14 19:58:22 -08:00
Shane Smiskol b3fc407538 VW: switch to common pcmCruise check (#34389)
Update car_specific.py
2025-01-14 19:54:28 -08:00
Shane Smiskol 3d38b139bc card: vcruise all in one place (#34387)
* no reason to not be here

* oh this was off by a frame!

* ref
2025-01-14 19:37:44 -08:00
Jason Wen 45f3c70596 move around 2025-01-14 21:55:56 -05:00
Shane Smiskol a1d81e63e1 Fix missing visual car dash alerts (#34385)
* fix missing visual dash alerts

* update refs
2025-01-14 18:52:40 -08:00
Jason Wen 21793721cc rename 2025-01-14 21:29:42 -05:00
Jason Wen d01b02b185 more 2025-01-14 20:50:57 -05:00
Kacper Rączy 2054495e79 process_replay: add cast in migrate_longitudinalPlan (#34383)
* Cast

* Something

* Remove newline
2025-01-15 01:37:28 +00:00
Kacper Rączy ea4a127ab8 process_replay: ignore unknown members in the migration code (#34382)
* Fix the migration for the events

* clean up

clean up

clean up

* no continue

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
2025-01-15 00:12:48 +00:00
Sammohana 8eebce75ac Getting rid of openpilot.common.numpy_fast (#34368)
* Got rid openpilot.common.numpy_fast

* fixed some data type erros

* importing numpy instead of importing specific functions

* fixing some numpy importing mistakes

* Update selfdrive/car/cruise.py

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2025-01-14 14:52:56 -08:00
Jason Wen f4af0aa422 update name 2025-01-14 16:42:41 -05:00
commaci-public c54cd4569a Toyota: remove longitudinal derivative (#34378)
* Update Python packages

* update refs

---------

Co-authored-by: Vehicle Researcher <user@comma.ai>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
2025-01-14 13:32:09 -08:00
Jason Young f771ddac88 PlotJuggler: Layout for debugging locationdTemporaryError (#34381)
* PlotJuggler: layout for debugging locationd

* not needed, and codespell doesn't like it
2025-01-14 11:12:05 -08:00
Jason Wen d3ecdbb850 fix dec engagement 2025-01-14 00:23:46 -05:00
Jason Wen 1f39c4ccfb remove to fail test 2025-01-14 00:04:48 -05:00
Jason Wen a56e1e6e69 slight cleanup 2025-01-14 00:01:31 -05:00
Jason Wen e630546250 more logs 2025-01-13 23:57:21 -05:00
Jason Wen 85faddc7af this is why it was never using DEC 2025-01-13 23:46:38 -05:00
Jason Wen 223abdc536 never used 2025-01-13 23:26:07 -05:00
Jason Wen dd12f86804 Merge branch 'master-new' into dec-redo
# Conflicts:
#	common/params.cc
2025-01-13 23:11:06 -05:00
Dean Lee 0e7c697bad raylib: revert auto fit screen size (#34380)
revert auto fit screen size
2025-01-13 19:45:13 -08:00
Adeeb Shihadeh 57abd8b0c2 Remove release files (conceptually) (#34379)
* Remove release files (conceptually)

* fix
2025-01-13 19:31:21 -08:00
Dean Lee 1ab98e38e5 raylib: refactor to implement new App class (#34375)
refactor to implement new App class
2025-01-13 14:52:03 -08:00
commaci-public 4d714113d1 [bot] Update Python packages (#34376)
* Update Python packages

* time -> time_helpers

---------

Co-authored-by: Vehicle Researcher <user@comma.ai>
Co-authored-by: Maxime Desroches <desroches.maxime@gmail.com>
2025-01-13 09:38:17 -08:00
ugtthis 7b09d08764 CI: Add missing uppercase_keyboard UI view (#34347)
* add-uppercase-preview

* testing-UI-on-fork

* change back

* add-my-branch

* needs to see sha from fork for test

* fix missing sha

* change back

* get correct named artifact

* try this

* experimenting coordinates

* try these coordinates

* try these coordinates

* draws circles to see touches - changes coordinates

* try these changes

* better coordinates

* click is more centered

* try again

* revert back

* revert these too

* last revert...
2025-01-13 09:05:22 -08:00
Jason Wen dff2a5796d update name 2025-01-13 11:41:11 -05:00
Jason Wen 70918ccff3 Merge branch 'master-new' into dec-redo 2025-01-13 10:23:12 -05:00
ugtthis 71951566c5 Keyboard: add missing control btns to uppercase (#34344)
* add-slash-to uppercase

* Trigger UI preview workflow
2025-01-13 01:22:04 -08:00
Shane Smiskol db2032c398 Move uds.py (#34374)
* rm uds pt. 1

* rm uds pt. 2

* imports
2025-01-13 00:54:10 -08:00
Jason Wen f6ef036158 use internal frame 2025-01-12 18:57:22 -05:00
Jason Wen 67692babdc Revert "pass sm.frame from plannerd"
This reverts commit a8deaa69b8.
2025-01-12 18:55:38 -05:00
Jason Wen ea6cd3429b Revert "fix test"
This reverts commit 635b15f2bc.
2025-01-12 18:55:33 -05:00
Jason Wen 635b15f2bc fix test 2025-01-12 18:54:17 -05:00
Jason Wen b42c060b2e more explicit 2025-01-12 18:37:47 -05:00
Jason Wen 1c1ef06489 more 2025-01-12 18:28:20 -05:00
Jason Wen 1b2586914f more fixes 2025-01-12 18:24:58 -05:00
Jason Wen a8deaa69b8 pass sm.frame from plannerd 2025-01-12 18:20:06 -05:00
Jason Wen c34a21980e fix type hint 2025-01-12 18:13:52 -05:00
Adeeb Shihadeh 74ed6c5657 oops need raw 2025-01-12 15:07:18 -08:00
rav4kumar 6e86d242cd window time 2025-01-12 16:03:17 -07:00
Adeeb Shihadeh 99bb7da850 third_party: add raygui (#34369) 2025-01-12 15:02:30 -08:00
rav4kumar 7113d4a76a smoother trans 2025-01-12 15:54:50 -07:00
Jason Wen 5074881d6d unused 2025-01-12 17:40:21 -05:00
Jason Wen bf3350b7f2 type hint 2025-01-12 17:38:49 -05:00
Jason Wen c64b679704 sync with stock 2025-01-12 17:16:34 -05:00
Jason Wen f645e2cdb0 check live param 2025-01-12 17:12:31 -05:00
Jason Wen 426d41a0a7 rename 2025-01-12 16:56:57 -05:00
Jason Wen de305a81d5 into their own 2025-01-12 16:52:40 -05:00
Jason Wen e4c29a2c58 stuff 2025-01-12 16:50:16 -05:00
Jason Wen c3fde45000 more cleanup 2025-01-12 16:48:44 -05:00
Jason Wen e7d27f0bb9 move around 2025-01-12 16:46:43 -05:00
Jason Wen 12981e02f7 static method 2025-01-12 16:46:15 -05:00
Jason Wen e1cf216c89 some more 2025-01-12 16:44:54 -05:00
Jason Wen cc507a5cd9 cleanup 2025-01-12 16:40:07 -05:00
rav4kumar 87ca1513f4 had moved to car_state 2025-01-12 14:29:22 -07:00
rav4kumar 1d422ce5cf static 2025-01-12 14:06:50 -07:00
rav4kumar cb04017945 Merge branch 'dec-new-refactored-rebased-no-ui' of https://github.com/sunnypilot/sunnypilot into dec-new-refactored-rebased-no-ui 2025-01-12 13:49:17 -07:00
rav4kumar 7d6c9d1a8c static test 2025-01-12 13:48:08 -07:00
Jason Wen ba6559d32a Merge branch 'master-new' into dec-new-refactored-rebased-no-ui 2025-01-12 15:40:47 -05:00
DevTekVE c0c74e3761 **Refactor DEC module structure for better organization**
Moved DEC-related files from `dec` to `lib` for improved clarity and consistency within the project structure. Updated all relevant import paths to reflect the new locations. Ensured functionality remains unaffected with these changes.
2025-01-12 21:03:38 +01:00
Adeeb Shihadeh d35ef3b3d5 swaglog: fix locale dependence (#34367) 2025-01-12 11:57:26 -08:00
DevTekVE 898f5b89ed Refactor DEC into a dedicated longitudinal planner class
Move Dynamic Experimental Control (DEC) logic to a new `DecLongitudinalPlanner` class for better modularity and maintainability. This simplifies the `LongitudinalPlanner` by delegating DEC-specific behavior and consolidates related methods into a single file. Additionally, redundant code was removed to improve readability and reduce complexity.
2025-01-12 20:51:35 +01:00
Dean Lee 47b13f54f6 encoderd: refactor VideoEncoder::publisher_publish to standardize member variable access (#34342)
remove redundant pointer parameter
2025-01-12 11:38:20 -08:00
Dean Lee 1068779294 modeld: properly release OpenCL context in __dealloc__ method (#34353)
release OpenCL context in __dealloc__
2025-01-12 10:15:26 -08:00
Adeeb Shihadeh 55cdf5ad7c release soon 2025-01-12 08:58:53 -08:00
DevTekVE f861e8d678 Format 2025-01-12 16:40:43 +01:00
DevTekVE fd6ec85e20 Refactor MpcSource definition and update references.
Moved MpcSource enum into LongitudinalPlanSP for better encapsulation. Updated references in helpers.py to use the new path. This change improves code organization and maintains functionality.
2025-01-12 16:40:20 +01:00
DevTekVE 4a46bccc20 rebase fix 2025-01-12 16:33:23 +01:00
DevTekVE 73e658bf8c Formatting 2025-01-12 16:33:23 +01:00
DevTekVE ec25ca070a Format 2025-01-12 16:33:23 +01:00
DevTekVE 84b6af094f Add missing import for messaging in helpers.py
The `messaging` module was added to resolve potential issues with undefined references. This change ensures all required imports are present, improving the reliability and maintainability of the code.
2025-01-12 16:33:23 +01:00
DevTekVE 55b6eae92e Refactor and modularize DynamicExperimentalController logic
Moved DynamicExperimentalController logic and helper functions to a dedicated module for better readability and maintainability. Simplified longitudinal planner logic by introducing reusable methods to manage MPC mode and longitudinal plan publishing. Adjusted file structure for dynamic controller-related components and updated relevant imports.
2025-01-12 16:33:22 +01:00
DevTekVE 760e7e847a new line... 2025-01-12 16:33:22 +01:00
DevTekVE 4b64f85f85 Replace unittest with pytest for dynamic controller tests
Migrated dynamic controller tests from unittest to pytest for improved readability and maintainability. Refactored mock setup using pytest fixtures and monkeypatching while preserving test coverage.
2025-01-12 16:33:22 +01:00
DevTekVE 8dd750fd83 Disabling unittest file to allow checks on the pipeline to succeed.
Pending to remove this, but leaving it to validate the move to pytest is okay before merging
2025-01-12 16:33:21 +01:00
DevTekVE 5e62ccad12 Integrate radar parameter into dynamic controller's pytest tests
Added a `has_radar` parameter to the test functions in the dynamic controller's pytest file. This allows each function to run both with and without radar inputs, thus enhancing the coverage of our test cases.
2025-01-12 16:33:21 +01:00
DevTekVE 2fb0545344 Migrated to pytest using claude 2025-01-12 16:33:21 +01:00
DevTekVE 684431e3f6 Refactor test indentation for dynamic controller tests
Adjust indentation and formatting in test_dynamic_controller.py to ensure consistency and readability. This change does not alter functionality but improves the maintainability of the test code.
2025-01-12 16:33:21 +01:00
DevTekVE ba9fbd52d7 Refactor test_dynamic_controller and fix formatting issues
Added a new import for STOP_AND_GO_FRAME and corrected a float initialization for v_ego in MockCarState. Also fixed indentation in the test_standstill_detection method for consistency.
2025-01-12 16:33:20 +01:00
rav4kumar 1dfaf347f8 unitee testt 2025-01-12 16:33:20 +01:00
rav4kumar 91922fb9b6 fix static test 2025-01-12 16:33:20 +01:00
rav4kumar c4ed5a4617 ff 2025-01-12 16:33:20 +01:00
rav4kumar 90435f0a92 fix static test 2025-01-12 16:33:19 +01:00
Kumar 3c434e78e2 Update sunnypilot/selfdrive/controls/lib/dynamic_experimental_controller.py
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
2025-01-12 16:33:19 +01:00
Kumar 75f6f73798 Update sunnypilot/selfdrive/controls/lib/dynamic_experimental_controller.py
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
2025-01-12 16:33:19 +01:00
rav4kumar c5524c6d42 init dec 2025-01-12 16:33:19 +01:00
Cameron Clough 08779941e5 loggerd: typing and remove unused default arg (#34349) 2025-01-09 22:12:10 +00:00
Cameron Clough f761f53205 deleter cleanups (#34345) 2025-01-09 20:00:45 +00:00
219 changed files with 9088 additions and 1390 deletions
+43
View File
@@ -0,0 +1,43 @@
exclude-labels:
- 'no-changelog'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
collapse-after: 5
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
collapse-after: 5
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&'
replacers:
- search: '/[Ss][Uu][Nn][Nn][Yy][Pp][Ii][Ll][Oo][Tt]/g'
replace: 'sunnypilot'
- search: '/\b[Ss][Pp]\b/g'
replace: 'SP'
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
name-template: 'v$RESOLVED_VERSION 🚀'
tag-template: 'v$RESOLVED_VERSION'
version-template: "0.$MAJOR.$MINOR.$PATCH" # The day OP becomes v1, we need to bump this
tag-prefix: "v0." # The day OP becomes v1, we need to bump this
prerelease-identifier: "staging"
template: |
## Changes
$CHANGES
+29
View File
@@ -0,0 +1,29 @@
name: Release Drafter
on:
push:
branches:
- master-new
- master
tags:
- 'v*'
pull_request_target:
types: [opened, reopened, synchronize]
workflow_dispatch:
permissions:
contents: read
jobs:
update_release_draft:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter.yml
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+1 -9
View File
@@ -67,15 +67,7 @@ jobs:
timeout-minutes: 1
run: |
cd $STRIPPED_DIR
${{ env.RUN }} "release/check-dirty.sh && \
MAX_EXAMPLES=5 $PYTEST -m 'not slow' selfdrive/car system/manager"
- name: Static analysis
timeout-minutes: 1
run: |
cd $GITHUB_WORKSPACE
cp pyproject.toml $STRIPPED_DIR
cd $STRIPPED_DIR
${{ env.RUN }} "scripts/lint/lint.sh --skip check_added_large_files"
${{ env.RUN }} "release/check-dirty.sh"
build:
runs-on:
+1 -1
View File
@@ -86,7 +86,7 @@ jobs:
run: >-
sudo apt-get install -y imagemagick
scenes="homescreen settings_device settings_software settings_sunnylink settings_toggles settings_sunnypilot settings_sunnypilot_mads settings_trips settings_developer offroad_alert update_available prime onroad onroad_disengaged onroad_override onroad_sidebar onroad_wide onroad_wide_sidebar onroad_alert_small onroad_alert_mid onroad_alert_full driver_camera body keyboard"
scenes="homescreen settings_device settings_software settings_sunnylink settings_toggles settings_sunnypilot settings_sunnypilot_mads settings_trips settings_developer offroad_alert update_available prime onroad onroad_disengaged onroad_override onroad_sidebar onroad_wide onroad_wide_sidebar onroad_alert_small onroad_alert_mid onroad_alert_full driver_camera body keyboard keyboard_uppercase"
A=($scenes)
DIFF=""
+12 -5
View File
@@ -1,16 +1,23 @@
Version 0.9.8 (2024-XX-XX)
Version 0.9.9 (2025-03-30)
========================
* Coming soon
* Rivian support
* F-150 & Mach-E support
* Tesla Model 3 support
Version 0.9.8 (2025-01-30)
========================
* New driving model
* Trained in brand new ML simulator
* Model now gates applying positive accel in Chill mode
* New driving monitoring model
* Reduced false positives related to passengers
* Image processing pipeline moved to the ISP
* More GPU time for driving models
* Power draw reduced 0.5W, which means your device runs cooler
* Power draw reduced 0.5W, which means your device runs cooler
* Added toggle to enable driver monitoring even when openpilot is not engaged
* Enable openpilot longitudinal control for Ford Q3 vehicles
* New Toyota TSS2 longitudinal tune
* Coming soon
* New driving model with gas gating
* Training data upload mode
Version 0.9.7 (2024-06-13)
========================
+44
View File
@@ -29,6 +29,50 @@ then means breaking backwards-compatibility with all old logs of your fork. So w
[custom.capnp](custom.capnp) that we will leave empty in mainline cereal/openpilot. **If you only modify those, you can ensure your
fork will remain backwards-compatible with all versions of mainline openpilot and your fork.**
An example of compatible changes:
```diff
diff --git a/cereal/custom.capnp b/cereal/custom.capnp
index 3348e859e..3365c7b98 100644
--- a/cereal/custom.capnp
+++ b/cereal/custom.capnp
@@ -10,7 +10,11 @@ $Cxx.namespace("cereal");
# DO rename the structs
# DON'T change the identifier (e.g. @0x81c2f05a394cf4af)
-struct CustomReserved0 @0x81c2f05a394cf4af {
+struct SteeringInfo @0x81c2f05a394cf4af {
+ active @0 :Bool;
+ steeringAngleDeg @1 :Float32;
+ steeringRateDeg @2 :Float32;
+ steeringAccelDeg @3 :Float32;
}
struct CustomReserved1 @0xaedffd8f31e7b55d {
diff --git a/cereal/log.capnp b/cereal/log.capnp
index 1209f3fd9..b189f58b6 100644
--- a/cereal/log.capnp
+++ b/cereal/log.capnp
@@ -2558,14 +2558,14 @@ struct Event {
# DO change the name of the field
# DON'T change anything after the "@"
- customReservedRawData0 @124 :Data;
+ rawCanData @124 :Data;
customReservedRawData1 @125 :Data;
customReservedRawData2 @126 :Data;
# DO change the name of the field and struct
# DON'T change the ID (e.g. @107)
# DON'T change which struct it points to
- customReserved0 @107 :Custom.CustomReserved0;
+ steeringInfo @107 :Custom.SteeringInfo;
customReserved1 @108 :Custom.CustomReserved1;
customReserved2 @109 :Custom.CustomReserved2;
customReserved3 @110 :Custom.CustomReserved3;
```
---
Example
---
```python
+47 -3
View File
@@ -7,7 +7,9 @@ $Cxx.namespace("cereal");
# These structs are guaranteed to remain reserved and empty in mainline
# cereal, so use these if you want custom events in your fork.
# you can rename the struct, but don't change the identifier
# DO rename the structs
# DON'T change the identifier (e.g. @0x81c2f05a394cf4af)
struct SelfdriveStateSP @0x81c2f05a394cf4af {
mads @0 :ModularAssistiveDrivingSystem;
@@ -64,7 +66,7 @@ struct ModelManagerSP @0xaedffd8f31e7b55d {
progress @1 :Float32;
eta @2 :UInt32;
}
enum Runner {
snpe @0;
tinygrad @1;
@@ -82,7 +84,19 @@ struct ModelManagerSP @0xaedffd8f31e7b55d {
}
}
struct CustomReserved2 @0xf35cc4560bbf6ec2 {
struct LongitudinalPlanSP @0xf35cc4560bbf6ec2 {
dec @0 :DynamicExperimentalControl;
struct DynamicExperimentalControl {
state @0 :DynamicExperimentalControlState;
enabled @1 :Bool;
active @2 :Bool;
enum DynamicExperimentalControlState {
acc @0;
blended @1;
}
}
}
struct CustomReserved3 @0xda96579883444c35 {
@@ -105,3 +119,33 @@ struct CustomReserved8 @0xf416ec09499d9d19 {
struct CustomReserved9 @0xa1680744031fdb2d {
}
struct CustomReserved10 @0xcb9fd56c7057593a {
}
struct CustomReserved11 @0xc2243c65e0340384 {
}
struct CustomReserved12 @0x9ccdc8676701b412 {
}
struct CustomReserved13 @0xcd96dafb67a082d0 {
}
struct CustomReserved14 @0xb057204d7deadf3f {
}
struct CustomReserved15 @0xbd443b539493bc68 {
}
struct CustomReserved16 @0xfc6241ed8877b611 {
}
struct CustomReserved17 @0xa30662f84033036c {
}
struct CustomReserved18 @0xc86a3d38d13eb3ef {
}
struct CustomReserved19 @0xa4f1eb3323f5f582 {
}
+20 -2
View File
@@ -199,6 +199,7 @@ struct OnroadEvent @0xc4fa6047f024e718 {
silentParkBrake @162;
controlsMismatchLateral @163;
hyundaiRadarTracksConfirmed @164;
experimentalModeSwitched @165;
soundsUnavailableDEPRECATED @47;
}
@@ -483,6 +484,7 @@ struct GpsLocationData {
speedAccuracy @12 :Float32;
hasFix @13 :Bool;
satelliteCount @14 :Int8;
enum SensorSource {
android @0;
@@ -2627,14 +2629,20 @@ struct Event {
livestreamWideRoadEncodeData @121 :EncodeData;
livestreamDriverEncodeData @122 :EncodeData;
# *********** Custom: reserved for forks ***********
# DO change the name of the field
# DON'T change anything after the "@"
customReservedRawData0 @124 :Data;
customReservedRawData1 @125 :Data;
customReservedRawData2 @126 :Data;
# *********** Custom: reserved for forks ***********
# DO change the name of the field and struct
# DON'T change the ID (e.g. @107)
# DON'T change which struct it points to
selfdriveStateSP @107 :Custom.SelfdriveStateSP;
modelManagerSP @108 :Custom.ModelManagerSP;
customReserved2 @109 :Custom.CustomReserved2;
longitudinalPlanSP @109 :Custom.LongitudinalPlanSP;
customReserved3 @110 :Custom.CustomReserved3;
customReserved4 @111 :Custom.CustomReserved4;
customReserved5 @112 :Custom.CustomReserved5;
@@ -2642,6 +2650,16 @@ struct Event {
customReserved7 @114 :Custom.CustomReserved7;
customReserved8 @115 :Custom.CustomReserved8;
customReserved9 @116 :Custom.CustomReserved9;
customReserved10 @136 :Custom.CustomReserved10;
customReserved11 @137 :Custom.CustomReserved11;
customReserved12 @138 :Custom.CustomReserved12;
customReserved13 @139 :Custom.CustomReserved13;
customReserved14 @140 :Custom.CustomReserved14;
customReserved15 @141 :Custom.CustomReserved15;
customReserved16 @142 :Custom.CustomReserved16;
customReserved17 @143 :Custom.CustomReserved17;
customReserved18 @144 :Custom.CustomReserved18;
customReserved19 @145 :Custom.CustomReserved19;
# *********** legacy + deprecated ***********
model @9 :Legacy.ModelData; # TODO: rename modelV2 and mark this as deprecated
+1
View File
@@ -77,6 +77,7 @@ _services: dict[str, tuple] = {
# sunnypilot
"modelManagerSP": (False, 1., 1),
"selfdriveStateSP": (True, 100., 10),
"longitudinalPlanSP": (True, 20., 10),
# debug
"uiDebug": (True, 0., 1),
+4
View File
@@ -79,6 +79,10 @@ cl_context cl_create_context(cl_device_id device_id) {
return CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err));
}
void cl_release_context(cl_context context) {
clReleaseContext(context);
}
cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args) {
return cl_program_from_source(ctx, device_id, util::read_file(path), args);
}
+1
View File
@@ -23,6 +23,7 @@
cl_device_id cl_get_device_id(cl_device_type device_type);
cl_context cl_create_context(cl_device_id device_id);
void cl_release_context(cl_context context);
cl_program cl_program_from_source(cl_context ctx, cl_device_id device_id, const std::string& src, const char* args = nullptr);
cl_program cl_program_from_binary(cl_context ctx, cl_device_id device_id, const uint8_t* binary, size_t length, const char* args = nullptr);
cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args);
+2
View File
@@ -229,6 +229,8 @@ std::unordered_map<std::string, uint32_t> keys = {
{"HyundaiRadarTracksConfirmed", PERSISTENT},
{"HyundaiRadarTracksPersistent", PERSISTENT},
{"HyundaiRadarTracksToggle", PERSISTENT},
{"DynamicExperimentalControl", PERSISTENT},
};
} // namespace
+6 -9
View File
@@ -1,9 +1,6 @@
import numpy as np
from numbers import Number
from openpilot.common.numpy_fast import clip, interp
class PIDController:
def __init__(self, k_p, k_i, k_f=0., k_d=0., pos_limit=1e308, neg_limit=-1e308, rate=100):
self._k_p = k_p
@@ -28,15 +25,15 @@ class PIDController:
@property
def k_p(self):
return interp(self.speed, self._k_p[0], self._k_p[1])
return np.interp(self.speed, self._k_p[0], self._k_p[1])
@property
def k_i(self):
return interp(self.speed, self._k_i[0], self._k_i[1])
return np.interp(self.speed, self._k_i[0], self._k_i[1])
@property
def k_d(self):
return interp(self.speed, self._k_d[0], self._k_d[1])
return np.interp(self.speed, self._k_d[0], self._k_d[1])
@property
def error_integral(self):
@@ -64,10 +61,10 @@ class PIDController:
# Clip i to prevent exceeding control limits
control_no_i = self.p + self.d + self.f
control_no_i = clip(control_no_i, self.neg_limit, self.pos_limit)
self.i = clip(self.i, self.neg_limit - control_no_i, self.pos_limit - control_no_i)
control_no_i = np.clip(control_no_i, self.neg_limit, self.pos_limit)
self.i = np.clip(self.i, self.neg_limit - control_no_i, self.pos_limit - control_no_i)
control = self.p + self.i + self.d + self.f
self.control = clip(control, self.neg_limit, self.pos_limit)
self.control = np.clip(control, self.neg_limit, self.pos_limit)
return self.control
+3
View File
@@ -26,6 +26,9 @@ public:
zmq_setsockopt(sock, ZMQ_LINGER, &timeout, sizeof(timeout));
zmq_connect(sock, Path::swaglog_ipc().c_str());
// workaround for https://github.com/dropbox/json11/issues/38
setlocale(LC_NUMERIC, "C");
print_level = CLOUDLOG_WARNING;
if (const char* print_lvl = getenv("LOGPRINT")) {
if (strcmp(print_lvl, "debug") == 0) {
-21
View File
@@ -1,21 +0,0 @@
import numpy as np
from openpilot.common.numpy_fast import interp
class TestInterp:
def test_correctness_controls(self):
_A_CRUISE_MIN_BP = np.asarray([0., 5., 10., 20., 40.])
_A_CRUISE_MIN_V = np.asarray([-1.0, -.8, -.67, -.5, -.30])
v_ego_arr = [-1, -1e-12, 0, 4, 5, 6, 7, 10, 11, 15.2, 20, 21, 39,
39.999999, 40, 41]
expected = np.interp(v_ego_arr, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V)
actual = interp(v_ego_arr, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V)
np.testing.assert_equal(actual, expected)
for v_ego in v_ego_arr:
expected = np.interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V)
actual = interp(v_ego, _A_CRUISE_MIN_BP, _A_CRUISE_MIN_V)
np.testing.assert_equal(actual, expected)
+13
View File
@@ -294,4 +294,17 @@ std::string check_output(const std::string& command) {
return result;
}
bool system_time_valid() {
// Default to August 26, 2024
tm min_tm = {.tm_year = 2024 - 1900, .tm_mon = 7, .tm_mday = 26};
time_t min_date = mktime(&min_tm);
struct stat st;
if (stat("/lib/systemd/systemd", &st) == 0) {
min_date = std::max(min_date, st.st_mtime + 86400); // Add 1 day (86400 seconds)
}
return time(nullptr) > min_date;
}
} // namespace util
+2
View File
@@ -96,6 +96,8 @@ bool create_directories(const std::string &dir, mode_t mode);
std::string check_output(const std::string& command);
bool system_time_valid();
inline void sleep_for(const int milliseconds) {
if (milliseconds > 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
+1 -1
View File
@@ -88,7 +88,7 @@ A supported vehicle is one that just works when you install a comma device. All
|Hyundai|Elantra 2017-18|Smart Cruise Control (SCC)|Stock|19 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai B connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Elantra 2017-18">Buy Here</a></sub></details>||
|Hyundai|Elantra 2019|Smart Cruise Control (SCC)|Stock|19 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai G connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Elantra 2019">Buy Here</a></sub></details>||
|Hyundai|Elantra 2021-23|Smart Cruise Control (SCC)|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai K connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Elantra 2021-23">Buy Here</a></sub></details>|<a href="https://youtu.be/_EdYQtV52-c" target="_blank"><img height="18px" src="assets/icon-youtube.svg"></img></a>|
|Hyundai|Elantra GT 2017-19|Smart Cruise Control (SCC)|Stock|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai E connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Elantra GT 2017-19">Buy Here</a></sub></details>||
|Hyundai|Elantra GT 2017-20|Smart Cruise Control (SCC)|Stock|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai E connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Elantra GT 2017-20">Buy Here</a></sub></details>||
|Hyundai|Elantra Hybrid 2021-23|Smart Cruise Control (SCC)|openpilot available[<sup>1</sup>](#footnotes)|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai K connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Elantra Hybrid 2021-23">Buy Here</a></sub></details>|<a href="https://youtu.be/_EdYQtV52-c" target="_blank"><img height="18px" src="assets/icon-youtube.svg"></img></a>|
|Hyundai|Genesis 2015-16|Smart Cruise Control (SCC)|Stock|19 mph|37 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai J connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=Genesis 2015-16">Buy Here</a></sub></details>||
|Hyundai|i30 2017-19|Smart Cruise Control (SCC)|Stock|0 mph|32 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-full.svg)](##)|<details><summary>Parts</summary><sub>- 1 Hyundai E connector<br>- 1 RJ45 cable (7 ft)<br>- 1 comma 3X<br>- 1 comma power v2<br>- 1 harness box<br>- 1 mount<br>- 1 right angle OBD-C cable (1.5 ft)<br><a href="https://comma.ai/shop/comma-3x.html?make=Hyundai&model=i30 2017-19">Buy Here</a></sub></details>||
+1 -1
Submodule panda updated: 781af8b4f1...d3252abcc4
+2 -175
View File
@@ -6,41 +6,11 @@ from pathlib import Path
HERE = os.path.abspath(os.path.dirname(__file__))
ROOT = HERE + "/.."
# blacklisting is for two purposes:
# - minimizing release download size
# - keeping the diff readable
blacklist = [
"panda/drivers/",
"panda/examples/",
"panda/tests/safety/",
"opendbc_repo/dbc/.*.dbc$",
"opendbc_repo/dbc/generator/",
"cereal/.*test.*",
"^common/tests/",
# particularly large text files
"uv.lock",
"third_party/catch2",
"selfdrive/car/tests/test_models.*",
"^tools/",
"^tinygrad_repo/",
".git/",
"matlab.*.md",
".git/",
".github/",
".devcontainer/",
"Darwin/",
".vscode",
# common things
"LICENSE",
"Dockerfile",
".pre-commit",
# no LFS or submodules in release
".lfsconfig",
".gitattributes",
@@ -48,153 +18,10 @@ blacklist = [
".gitmodules",
]
# Sunnypilot blacklist
sunnypilot_blacklist = [
"system/loggerd/sunnylink_uploader.py", # Temporarily, until we are ready to roll it out widely
".idea/",
".run/",
".*__pycache__/.*",
".*\\.pyc",
"teleoprtc/*",
"third_party/snpe/x86_64/*",
"body/board/canloader.py",
"body/board/flash_base.sh",
"body/board/flash_knee.sh",
"body/board/recover.sh",
".*/test/",
".*/tests/",
".*tinygrad_repo/tinygrad/renderer/",
"README.md",
".*internal/",
"docs/.*",
".sconsign.dblite",
"release/ci/scons_cache/",
".gitlab-ci.yml",
".clang-tidy",
".dockerignore",
".editorconfig",
".python-version",
"SECURITY.md",
"codecov.yml",
"conftest.py",
"poetry.lock",
".venv/",
]
# Merge the blacklists
blacklist += sunnypilot_blacklist
# gets you through the blacklist
whitelist = [
"tools/lib/",
"tools/bodyteleop/",
"tools/joystick/",
"tools/longitudinal_maneuvers/",
"tinygrad_repo/examples/openpilot/compile3.py",
"tinygrad_repo/extra/onnx.py",
"tinygrad_repo/extra/onnx_ops.py",
"tinygrad_repo/extra/thneed.py",
"tinygrad_repo/extra/utils.py",
"tinygrad_repo/tinygrad/codegen/kernel.py",
"tinygrad_repo/tinygrad/codegen/linearizer.py",
"tinygrad_repo/tinygrad/features/image.py",
"tinygrad_repo/tinygrad/features/search.py",
"tinygrad_repo/tinygrad/nn/*",
"tinygrad_repo/tinygrad/renderer/cstyle.py",
"tinygrad_repo/tinygrad/renderer/opencl.py",
"tinygrad_repo/tinygrad/runtime/lib.py",
"tinygrad_repo/tinygrad/runtime/ops_cpu.py",
"tinygrad_repo/tinygrad/runtime/ops_disk.py",
"tinygrad_repo/tinygrad/runtime/ops_gpu.py",
"tinygrad_repo/tinygrad/shape/*",
"tinygrad_repo/tinygrad/.*.py",
# TODO: do this automatically
"opendbc_repo/dbc/comma_body.dbc",
"opendbc_repo/dbc/chrysler_ram_hd_generated.dbc",
"opendbc_repo/dbc/chrysler_ram_dt_generated.dbc",
"opendbc_repo/dbc/chrysler_pacifica_2017_hybrid_generated.dbc",
"opendbc_repo/dbc/chrysler_pacifica_2017_hybrid_private_fusion.dbc",
"opendbc_repo/dbc/gm_global_a_powertrain_generated.dbc",
"opendbc_repo/dbc/gm_global_a_object.dbc",
"opendbc_repo/dbc/gm_global_a_chassis.dbc",
"opendbc_repo/dbc/FORD_CADS.dbc",
"opendbc_repo/dbc/ford_fusion_2018_adas.dbc",
"opendbc_repo/dbc/ford_lincoln_base_pt.dbc",
"opendbc_repo/dbc/honda_accord_2018_can_generated.dbc",
"opendbc_repo/dbc/acura_ilx_2016_can_generated.dbc",
"opendbc_repo/dbc/acura_rdx_2018_can_generated.dbc",
"opendbc_repo/dbc/acura_rdx_2020_can_generated.dbc",
"opendbc_repo/dbc/honda_civic_touring_2016_can_generated.dbc",
"opendbc_repo/dbc/honda_civic_hatchback_ex_2017_can_generated.dbc",
"opendbc_repo/dbc/honda_crv_touring_2016_can_generated.dbc",
"opendbc_repo/dbc/honda_crv_ex_2017_can_generated.dbc",
"opendbc_repo/dbc/honda_crv_ex_2017_body_generated.dbc",
"opendbc_repo/dbc/honda_crv_executive_2016_can_generated.dbc",
"opendbc_repo/dbc/honda_fit_ex_2018_can_generated.dbc",
"opendbc_repo/dbc/honda_odyssey_exl_2018_generated.dbc",
"opendbc_repo/dbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc",
"opendbc_repo/dbc/honda_insight_ex_2019_can_generated.dbc",
"opendbc_repo/dbc/acura_ilx_2016_nidec.dbc",
"opendbc_repo/dbc/honda_civic_ex_2022_can_generated.dbc",
"opendbc_repo/dbc/hyundai_canfd.dbc",
"opendbc_repo/dbc/hyundai_kia_generic.dbc",
"opendbc_repo/dbc/hyundai_kia_mando_front_radar_generated.dbc",
"opendbc_repo/dbc/mazda_2017.dbc",
"opendbc_repo/dbc/nissan_x_trail_2017_generated.dbc",
"opendbc_repo/dbc/nissan_leaf_2018_generated.dbc",
"opendbc_repo/dbc/subaru_global_2017_generated.dbc",
"opendbc_repo/dbc/subaru_global_2020_hybrid_generated.dbc",
"opendbc_repo/dbc/subaru_outback_2015_generated.dbc",
"opendbc_repo/dbc/subaru_outback_2019_generated.dbc",
"opendbc_repo/dbc/subaru_forester_2017_generated.dbc",
"opendbc_repo/dbc/toyota_tnga_k_pt_generated.dbc",
"opendbc_repo/dbc/toyota_new_mc_pt_generated.dbc",
"opendbc_repo/dbc/toyota_nodsu_pt_generated.dbc",
"opendbc_repo/dbc/toyota_adas.dbc",
"opendbc_repo/dbc/toyota_tss2_adas.dbc",
"opendbc_repo/dbc/vw_golf_mk4.dbc",
"opendbc_repo/dbc/vw_mqb_2010.dbc",
"opendbc_repo/dbc/tesla_can.dbc",
"opendbc_repo/dbc/tesla_radar_bosch_generated.dbc",
"opendbc_repo/dbc/tesla_radar_continental_generated.dbc",
"opendbc_repo/dbc/tesla_powertrain.dbc",
whitelist: list[str] = [
]
# Sunnypilot whitelist
sunnypilot_whitelist = [
"^README.md",
".*selfdrive/test/fuzzy_generation.py",
".*selfdrive/test/helpers.py",
".*selfdrive/test/__init__.py",
".*selfdrive/test/setup_device_ci.sh",
".*selfdrive/test/test_time_to_onroad.py",
".*selfdrive/test/test_onroad.py",
".*system/manager/test/test_manager.py",
".*system/manager/test/__init__.py",
".*system/qcomgpsd/tests/test_qcomgpsd.py",
".*system/updated/casync/tests/test_casync.py",
".*system/updated/tests/test_git.py",
".*system/updated/tests/test_base.py",
".*selfdrive/ui/tests/test_translations.py",
".*selfdrive/car/tests/__init__.py",
".*selfdrive/car/tests/test_car_interfaces.py",
".*selfdrive/navd/tests/test_navd.py",
".*selfdrive/navd/tests/test_map_renderer.py",
".*selfdrive/boardd/tests/test_boardd_loopback.py",
".*INTEGRATION.md",
".*HOW-TOS.md",
".*CARS.md",
".*LIMITATIONS.md",
".*CONTRIBUTING.md",
".*sunnyhaibin0850_qrcode_paypal.me.png",
"opendbc/.*.dbc",
]
# Merge the whitelists
whitelist += sunnypilot_whitelist
if __name__ == "__main__":
for f in Path(ROOT).rglob("**/*"):
+5 -4
View File
@@ -122,7 +122,7 @@ class CarSpecificEvents:
elif self.CP.carName == 'volkswagen':
events = self.create_common_events(CS, CS_prev, extra_gears=[GearShifter.eco, GearShifter.sport, GearShifter.manumatic],
pcm_enable=not self.CP.openpilotLongitudinalControl,
pcm_enable=self.CP.pcmCruise,
enable_buttons=(ButtonType.setCruise, ButtonType.resumeCruise))
# Low speed steer alert hysteresis logic
@@ -149,7 +149,7 @@ class CarSpecificEvents:
# Main button also can trigger an engagement on these cars
self.cruise_buttons.append(any(ev.type in HYUNDAI_ENABLE_BUTTONS for ev in CS.buttonEvents))
events = self.create_common_events(CS, CS_prev, extra_gears=(GearShifter.sport, GearShifter.manumatic),
pcm_enable=self.CP.pcmCruise, allow_enable=any(self.cruise_buttons))
pcm_enable=self.CP.pcmCruise, allow_enable=any(self.cruise_buttons), allow_button_cancel=False)
# low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s)
if CS.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.:
@@ -165,7 +165,7 @@ class CarSpecificEvents:
return events
def create_common_events(self, CS: structs.CarState, CS_prev: car.CarState, extra_gears=None, pcm_enable=True,
allow_enable=True, enable_buttons=(ButtonType.accelCruise, ButtonType.decelCruise)):
allow_enable=True, allow_button_cancel=True, enable_buttons=(ButtonType.accelCruise, ButtonType.decelCruise)):
events = Events()
if CS.doorOpen:
@@ -216,7 +216,8 @@ class CarSpecificEvents:
if not self.CP.pcmCruise and (b.type in enable_buttons and not b.pressed):
events.add(EventName.buttonEnable)
# Disable on rising and falling edge of cancel for both stock and OP long
if b.type == ButtonType.cancel:
# TODO: only check the cancel button with openpilot longitudinal on all brands to match panda safety
if b.type == ButtonType.cancel and (allow_button_cancel or not self.CP.pcmCruise):
events.add(EventName.buttonCancel)
# Handle permanent and temporary steering faults
+29 -7
View File
@@ -23,7 +23,7 @@ from openpilot.selfdrive.car.cruise import VCruiseHelper
from openpilot.selfdrive.car.car_specific import MockCarState
from openpilot.sunnypilot.mads.mads import MadsParams
from openpilot.sunnypilot.selfdrive.car.interfaces import setup_car_interface_sp, initialize_car_interface_sp
from openpilot.sunnypilot.selfdrive.car import interfaces
REPLAY = "REPLAY" in os.environ
@@ -75,6 +75,7 @@ class Car:
self.can_rcv_cum_timeout_counter = 0
self.CC_prev = car.CarControl.new_message()
self.CS_prev = car.CarState.new_message()
self.initialized_prev = False
self.last_actuators_output = structs.CarControl.Actuators()
@@ -101,7 +102,7 @@ class Car:
cached_params = _cached_params
self.CI = get_car(*self.can_callbacks, obd_callback(self.params), experimental_long_allowed, num_pandas, cached_params)
setup_car_interface_sp(self.CI.CP, self.params)
interfaces.setup_car_interface_sp(self.CI.CP, self.params)
self.RI = get_radar_interface(self.CI.CP)
self.CP = self.CI.CP
@@ -121,6 +122,9 @@ class Car:
MadsParams().set_alternative_experience(self.CP)
MadsParams().set_car_specific_params(self.CP)
# Dynamic Experimental Control
self.dynamic_experimental_control = self.params.get_bool("DynamicExperimentalControl")
openpilot_enabled_toggle = self.params.get_bool("OpenpilotEnabledToggle")
controller_available = self.CI.CC is not None and openpilot_enabled_toggle and not self.CP.dashcamOnly
@@ -132,6 +136,15 @@ class Car:
self.CP.safetyConfigs = [safety_config]
if self.CP.secOcRequired and not self.params.get_bool("IsReleaseBranch"):
# Copy user key if available
try:
with open("/cache/params/SecOCKey") as f:
user_key = f.readline().strip()
if len(user_key) == 32:
self.params.put("SecOCKey", user_key)
except Exception:
pass
secoc_key = self.params.get("SecOCKey", encoding='utf8')
if secoc_key is not None:
saved_secoc_key = bytes.fromhex(secoc_key.strip())
@@ -163,6 +176,9 @@ class Car:
# card is driven by can recv, expected at 100Hz
self.rk = Ratekeeper(100, print_delay_threshold=None)
# log fingerprint in sentry
interfaces.log_fingerprint(self.CP)
def state_update(self) -> tuple[car.CarState, structs.RadarDataT | None]:
"""carState update loop, driven by can"""
@@ -188,8 +204,12 @@ class Car:
if can_rcv_valid and REPLAY:
self.can_log_mono_time = messaging.log_from_bytes(can_strs[0]).logMonoTime
# TODO: mirror the carState.cruiseState struct?
self.v_cruise_helper.update_v_cruise(CS, self.sm['carControl'].enabled, self.is_metric)
if self.sm['carControl'].enabled and not self.CC_prev.enabled:
# Use CarState w/ buttons from the step selfdrived enables on
self.v_cruise_helper.initialize_v_cruise(self.CS_prev, self.experimental_mode, self.dynamic_experimental_control)
# TODO: mirror the carState.cruiseState struct?
CS.vCruise = float(self.v_cruise_helper.v_cruise_kph)
CS.vCruiseCluster = float(self.v_cruise_helper.v_cruise_cluster_kph)
@@ -232,7 +252,7 @@ class Car:
# Initialize CarInterface, once controls are ready
# TODO: this can make us miss at least a few cycles when doing an ECU knockout
self.CI.init(self.CP, *self.can_callbacks)
initialize_car_interface_sp(self.CP, self.params, *self.can_callbacks)
interfaces.initialize_car_interface_sp(self.CP, self.params, *self.can_callbacks)
# signal pandad to switch to car safety mode
self.params.put_bool_nonblocking("ControlsReady", True)
@@ -247,9 +267,6 @@ class Car:
def step(self):
CS, RD = self.state_update()
if self.sm['carControl'].enabled and not self.CC_prev.enabled:
self.v_cruise_helper.initialize_v_cruise(CS, self.experimental_mode)
self.state_publish(CS, RD)
initialized = (not any(e.name == EventName.selfdriveInitializing for e in self.sm['onroadEvents']) and
@@ -258,11 +275,16 @@ class Car:
self.controls_update(CS, self.sm['carControl'])
self.initialized_prev = initialized
self.CS_prev = CS
def params_thread(self, evt):
while not evt.is_set():
self.is_metric = self.params.get_bool("IsMetric")
self.experimental_mode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl
# sunnypilot
self.dynamic_experimental_control = self.params.get_bool("DynamicExperimentalControl")
time.sleep(0.1)
def card_thread(self):
+6 -5
View File
@@ -1,8 +1,8 @@
import math
import numpy as np
from cereal import car
from openpilot.common.conversions import Conversions as CV
from openpilot.common.numpy_fast import clip
# WARNING: this value was determined based on the model's training distribution,
@@ -106,7 +106,7 @@ class VCruiseHelper:
if CS.gasPressed and button_type in (ButtonType.decelCruise, ButtonType.setCruise):
self.v_cruise_kph = max(self.v_cruise_kph, CS.vEgo * CV.MS_TO_KPH)
self.v_cruise_kph = clip(round(self.v_cruise_kph, 1), V_CRUISE_MIN, V_CRUISE_MAX)
self.v_cruise_kph = np.clip(round(self.v_cruise_kph, 1), V_CRUISE_MIN, V_CRUISE_MAX)
def update_button_timers(self, CS, enabled):
# increment timer for buttons still pressed
@@ -120,16 +120,17 @@ class VCruiseHelper:
self.button_timers[b.type.raw] = 1 if b.pressed else 0
self.button_change_states[b.type.raw] = {"standstill": CS.cruiseState.standstill, "enabled": enabled}
def initialize_v_cruise(self, CS, experimental_mode: bool) -> None:
def initialize_v_cruise(self, CS, experimental_mode: bool, dynamic_experimental_control: bool) -> None:
# initializing is handled by the PCM
if self.CP.pcmCruise:
return
initial = V_CRUISE_INITIAL_EXPERIMENTAL_MODE if experimental_mode else V_CRUISE_INITIAL
initial_experimental_mode = experimental_mode and not dynamic_experimental_control
initial = V_CRUISE_INITIAL_EXPERIMENTAL_MODE if initial_experimental_mode else V_CRUISE_INITIAL
if any(b.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for b in CS.buttonEvents) and self.v_cruise_initialized:
self.v_cruise_kph = self.v_cruise_kph_last
else:
self.v_cruise_kph = int(round(clip(CS.vEgo * CV.MS_TO_KPH, initial, V_CRUISE_MAX)))
self.v_cruise_kph = int(round(np.clip(CS.vEgo * CV.MS_TO_KPH, initial, V_CRUISE_MAX)))
self.v_cruise_cluster_kph = self.v_cruise_kph
+13 -12
View File
@@ -57,16 +57,16 @@ class TestVCruiseHelper:
for _ in range(2):
self.v_cruise_helper.update_v_cruise(car.CarState(cruiseState={"available": False}), enabled=False, is_metric=False)
def enable(self, v_ego, experimental_mode):
def enable(self, v_ego, experimental_mode, dynamic_experimental_control):
# Simulates user pressing set with a current speed
self.v_cruise_helper.initialize_v_cruise(car.CarState(vEgo=v_ego), experimental_mode)
self.v_cruise_helper.initialize_v_cruise(car.CarState(vEgo=v_ego), experimental_mode, dynamic_experimental_control)
def test_adjust_speed(self):
"""
Asserts speed changes on falling edges of buttons.
"""
self.enable(V_CRUISE_INITIAL * CV.KPH_TO_MS, False)
self.enable(V_CRUISE_INITIAL * CV.KPH_TO_MS, False, False)
for btn in (ButtonType.accelCruise, ButtonType.decelCruise):
for pressed in (True, False):
@@ -90,7 +90,7 @@ class TestVCruiseHelper:
CS.buttonEvents = [ButtonEvent(type=ButtonType.decelCruise, pressed=pressed)]
self.v_cruise_helper.update_v_cruise(CS, enabled=enabled, is_metric=False)
if pressed:
self.enable(V_CRUISE_INITIAL * CV.KPH_TO_MS, False)
self.enable(V_CRUISE_INITIAL * CV.KPH_TO_MS, False, False)
# Expected diff on enabling. Speed should not change on falling edge of pressed
assert not pressed == self.v_cruise_helper.v_cruise_kph == self.v_cruise_helper.v_cruise_kph_last
@@ -100,7 +100,7 @@ class TestVCruiseHelper:
Asserts we don't increment set speed if user presses resume/accel to exit cruise standstill.
"""
self.enable(0, False)
self.enable(0, False, False)
for standstill in (True, False):
for pressed in (True, False):
@@ -120,7 +120,7 @@ class TestVCruiseHelper:
for v_ego in np.linspace(0, 100, 101):
self.reset_cruise_speed_state()
self.enable(V_CRUISE_INITIAL * CV.KPH_TO_MS, False)
self.enable(V_CRUISE_INITIAL * CV.KPH_TO_MS, False, False)
# first decrement speed, then perform gas pressed logic
expected_v_cruise_kph = self.v_cruise_helper.v_cruise_kph - IMPERIAL_INCREMENT
@@ -142,10 +142,11 @@ class TestVCruiseHelper:
"""
for experimental_mode in (True, False):
for v_ego in np.linspace(0, 100, 101):
self.reset_cruise_speed_state()
assert not self.v_cruise_helper.v_cruise_initialized
for dynamic_experimental_control in (True, False):
for v_ego in np.linspace(0, 100, 101):
self.reset_cruise_speed_state()
assert not self.v_cruise_helper.v_cruise_initialized
self.enable(float(v_ego), experimental_mode)
assert V_CRUISE_INITIAL <= self.v_cruise_helper.v_cruise_kph <= V_CRUISE_MAX
assert self.v_cruise_helper.v_cruise_initialized
self.enable(float(v_ego), experimental_mode, dynamic_experimental_control)
assert V_CRUISE_INITIAL <= self.v_cruise_helper.v_cruise_kph <= V_CRUISE_MAX
assert self.v_cruise_helper.v_cruise_initialized
+6 -5
View File
@@ -119,15 +119,16 @@ class Controls:
# accel PID loop
pid_accel_limits = self.CI.get_pid_accel_limits(self.CP, CS.vEgo, CS.vCruise * CV.KPH_TO_MS)
actuators.accel = self.LoC.update(CC.longActive, CS, long_plan.aTarget, long_plan.shouldStop, pid_accel_limits)
actuators.accel = float(self.LoC.update(CC.longActive, CS, long_plan.aTarget, long_plan.shouldStop, pid_accel_limits))
# Steering PID loop and lateral MPC
self.desired_curvature = clip_curvature(CS.vEgo, self.desired_curvature, model_v2.action.desiredCurvature)
actuators.curvature = self.desired_curvature
actuators.steer, actuators.steeringAngleDeg, lac_log = self.LaC.update(CC.latActive, CS, self.VM, lp,
actuators.curvature = float(self.desired_curvature)
steer, steeringAngleDeg, lac_log = self.LaC.update(CC.latActive, CS, self.VM, lp,
self.steer_limited, self.desired_curvature,
self.calibrated_pose) # TODO what if not available
actuators.steer = float(steer)
actuators.steeringAngleDeg = float(steeringAngleDeg)
# Ensure no NaNs/Infs
for p in ACTUATOR_FIELDS:
attr = getattr(actuators, p)
@@ -192,7 +193,7 @@ class Controls:
cs.longitudinalPlanMonoTime = self.sm.logMonoTime['longitudinalPlan']
cs.lateralPlanMonoTime = self.sm.logMonoTime['modelV2']
cs.desiredCurvature = self.desired_curvature
cs.desiredCurvature = float(self.desired_curvature)
cs.longControlState = self.LoC.long_control_state
cs.upAccelCmd = float(self.LoC.pid.p)
cs.uiAccelCmd = float(self.LoC.pid.i)
+4 -4
View File
@@ -1,5 +1,5 @@
import numpy as np
from cereal import log
from openpilot.common.numpy_fast import clip
from openpilot.common.realtime import DT_CTRL
MIN_SPEED = 1.0
@@ -13,10 +13,10 @@ MAX_LATERAL_JERK = 5.0
MAX_VEL_ERR = 5.0
def clip_curvature(v_ego, prev_curvature, new_curvature):
new_curvature = clip(new_curvature, -MAX_CURVATURE, MAX_CURVATURE)
new_curvature = np.clip(new_curvature, -MAX_CURVATURE, MAX_CURVATURE)
v_ego = max(MIN_SPEED, v_ego)
max_curvature_rate = MAX_LATERAL_JERK / (v_ego**2) # inexact calculation, check https://github.com/commaai/openpilot/pull/24755
safe_desired_curvature = clip(new_curvature,
safe_desired_curvature = np.clip(new_curvature,
prev_curvature - max_curvature_rate * DT_CTRL,
prev_curvature + max_curvature_rate * DT_CTRL)
@@ -26,6 +26,6 @@ def clip_curvature(v_ego, prev_curvature, new_curvature):
def get_speed_error(modelV2: log.ModelDataV2, v_ego: float) -> float:
# ToDo: Try relative error, and absolute speed
if len(modelV2.temporalPose.trans):
vel_err = clip(modelV2.temporalPose.trans[0] - v_ego, -MAX_VEL_ERR, MAX_VEL_ERR)
vel_err = np.clip(modelV2.temporalPose.trans[0] - v_ego, -MAX_VEL_ERR, MAX_VEL_ERR)
return float(vel_err)
return 0.0
+2 -2
View File
@@ -1,6 +1,6 @@
import numpy as np
from abc import abstractmethod, ABC
from openpilot.common.numpy_fast import clip
from openpilot.common.realtime import DT_CTRL
MIN_LATERAL_CONTROL_SPEED = 0.3 # m/s
@@ -28,5 +28,5 @@ class LatControl(ABC):
self.sat_count += self.sat_count_rate
else:
self.sat_count -= self.sat_count_rate
self.sat_count = clip(self.sat_count, 0.0, self.sat_limit)
self.sat_count = np.clip(self.sat_count, 0.0, self.sat_limit)
return self.sat_count > (self.sat_limit - 1e-3)
+1 -1
View File
@@ -23,7 +23,7 @@ class LatControlAngle(LatControl):
angle_steers_des += params.angleOffsetDeg
angle_control_saturated = abs(angle_steers_des - CS.steeringAngleDeg) > STEER_ANGLE_SATURATION_THRESHOLD
angle_log.saturated = self._check_saturation(angle_control_saturated, CS, False)
angle_log.saturated = bool(self._check_saturation(angle_control_saturated, CS, False))
angle_log.steeringAngleDeg = float(CS.steeringAngleDeg)
angle_log.steeringAngleDesiredDeg = angle_steers_des
return 0, float(angle_steers_des), angle_log
+5 -5
View File
@@ -39,10 +39,10 @@ class LatControlPID(LatControl):
output_steer = self.pid.update(error, override=CS.steeringPressed,
feedforward=steer_feedforward, speed=CS.vEgo)
pid_log.active = True
pid_log.p = self.pid.p
pid_log.i = self.pid.i
pid_log.f = self.pid.f
pid_log.output = output_steer
pid_log.saturated = self._check_saturation(self.steer_max - abs(output_steer) < 1e-3, CS, steer_limited)
pid_log.p = float(self.pid.p)
pid_log.i = float(self.pid.i)
pid_log.f = float(self.pid.f)
pid_log.output = float(output_steer)
pid_log.saturated = bool(self._check_saturation(self.steer_max - abs(output_steer) < 1e-3, CS, steer_limited))
return output_steer, angle_steers_des, pid_log
+12 -12
View File
@@ -1,8 +1,8 @@
import math
import numpy as np
from cereal import log
from opendbc.car.interfaces import LatControlInputs
from openpilot.common.numpy_fast import interp
from openpilot.selfdrive.controls.lib.latcontrol import LatControl
from openpilot.common.pid import PIDController
from openpilot.selfdrive.controls.lib.vehicle_model import ACCELERATION_DUE_TO_GRAVITY
@@ -51,7 +51,7 @@ class LatControlTorque(LatControl):
else:
assert calibrated_pose is not None
actual_curvature_pose = calibrated_pose.angular_velocity.yaw / CS.vEgo
actual_curvature = interp(CS.vEgo, [2.0, 5.0], [actual_curvature_vm, actual_curvature_pose])
actual_curvature = np.interp(CS.vEgo, [2.0, 5.0], [actual_curvature_vm, actual_curvature_pose])
curvature_deadzone = 0.0
desired_lateral_accel = desired_curvature * CS.vEgo ** 2
@@ -60,7 +60,7 @@ class LatControlTorque(LatControl):
actual_lateral_accel = actual_curvature * CS.vEgo ** 2
lateral_accel_deadzone = curvature_deadzone * CS.vEgo ** 2
low_speed_factor = interp(CS.vEgo, LOW_SPEED_X, LOW_SPEED_Y)**2
low_speed_factor = np.interp(CS.vEgo, LOW_SPEED_X, LOW_SPEED_Y)**2
setpoint = desired_lateral_accel + low_speed_factor * desired_curvature
measurement = actual_lateral_accel + low_speed_factor * actual_curvature
gravity_adjusted_lateral_accel = desired_lateral_accel - roll_compensation
@@ -68,7 +68,7 @@ class LatControlTorque(LatControl):
setpoint, lateral_accel_deadzone, friction_compensation=False, gravity_adjusted=False)
torque_from_measurement = self.torque_from_lateral_accel(LatControlInputs(measurement, roll_compensation, CS.vEgo, CS.aEgo), self.torque_params,
measurement, lateral_accel_deadzone, friction_compensation=False, gravity_adjusted=False)
pid_log.error = torque_from_setpoint - torque_from_measurement
pid_log.error = float(torque_from_setpoint - torque_from_measurement)
ff = self.torque_from_lateral_accel(LatControlInputs(gravity_adjusted_lateral_accel, roll_compensation, CS.vEgo, CS.aEgo), self.torque_params,
desired_lateral_accel - actual_lateral_accel, lateral_accel_deadzone, friction_compensation=True,
gravity_adjusted=True)
@@ -80,14 +80,14 @@ class LatControlTorque(LatControl):
freeze_integrator=freeze_integrator)
pid_log.active = True
pid_log.p = self.pid.p
pid_log.i = self.pid.i
pid_log.d = self.pid.d
pid_log.f = self.pid.f
pid_log.output = -output_torque
pid_log.actualLateralAccel = actual_lateral_accel
pid_log.desiredLateralAccel = desired_lateral_accel
pid_log.saturated = self._check_saturation(self.steer_max - abs(output_torque) < 1e-3, CS, steer_limited)
pid_log.p = float(self.pid.p)
pid_log.i = float(self.pid.i)
pid_log.d = float(self.pid.d)
pid_log.f = float(self.pid.f)
pid_log.output = float(-output_torque)
pid_log.actualLateralAccel = float(actual_lateral_accel)
pid_log.desiredLateralAccel = float(desired_lateral_accel)
pid_log.saturated = bool(self._check_saturation(self.steer_max - abs(output_torque) < 1e-3, CS, steer_limited))
# TODO left is positive in this convention
return -output_torque, 0.0, pid_log
+2 -2
View File
@@ -1,5 +1,5 @@
import numpy as np
from cereal import car
from openpilot.common.numpy_fast import clip
from openpilot.common.realtime import DT_CTRL
from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N
from openpilot.common.pid import PIDController
@@ -84,5 +84,5 @@ class LongControl:
output_accel = self.pid.update(error, speed=CS.vEgo,
feedforward=a_target)
self.last_output_accel = clip(output_accel, accel_limits[0], accel_limits[1])
self.last_output_accel = np.clip(output_accel, accel_limits[0], accel_limits[1])
return self.last_output_accel
@@ -4,7 +4,6 @@ import time
import numpy as np
from cereal import log
from opendbc.car.interfaces import ACCEL_MIN
from openpilot.common.numpy_fast import clip
from openpilot.common.realtime import DT_MDL
from openpilot.common.swaglog import cloudlog
# WARNING: imports outside of constants will not trigger a rebuild
@@ -320,9 +319,9 @@ class LongitudinalMpc:
# MPC will not converge if immediate crash is expected
# Clip lead distance to what is still possible to brake for
min_x_lead = ((v_ego + v_lead)/2) * (v_ego - v_lead) / (-ACCEL_MIN * 2)
x_lead = clip(x_lead, min_x_lead, 1e8)
v_lead = clip(v_lead, 0.0, 1e8)
a_lead = clip(a_lead, -10., 5.)
x_lead = np.clip(x_lead, min_x_lead, 1e8)
v_lead = np.clip(v_lead, 0.0, 1e8)
a_lead = np.clip(a_lead, -10., 5.)
lead_xv = self.extrapolate_lead(x_lead, v_lead, a_lead, a_lead_tau)
return lead_xv
+19 -12
View File
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
import math
import numpy as np
from openpilot.common.numpy_fast import clip, interp
import cereal.messaging as messaging
from opendbc.car.interfaces import ACCEL_MIN, ACCEL_MAX
@@ -16,6 +15,8 @@ from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N, get_speed_
from openpilot.selfdrive.car.cruise import V_CRUISE_MAX, V_CRUISE_UNSET
from openpilot.common.swaglog import cloudlog
from openpilot.sunnypilot.selfdrive.controls.lib.longitudinal_planner import LongitudinalPlannerSP
LON_MPC_STEP = 0.2 # first step is 0.2s
A_CRUISE_MIN = -1.2
A_CRUISE_MAX_VALS = [1.6, 1.2, 0.8, 0.6]
@@ -30,7 +31,7 @@ _A_TOTAL_MAX_BP = [20., 40.]
def get_max_accel(v_ego):
return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS)
return np.interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS)
def get_coast_accel(pitch):
return np.sin(pitch) * -5.65 - 0.3 # fitted from data using xx/projects/allow_throttle/compute_coast_accel.py
@@ -43,7 +44,7 @@ def limit_accel_in_turns(v_ego, angle_steers, a_target, CP):
"""
# FIXME: This function to calculate lateral accel is incorrect and should use the VehicleModel
# The lookup table for turns should also be updated if we do this
a_total_max = interp(v_ego, _A_TOTAL_MAX_BP, _A_TOTAL_MAX_V)
a_total_max = np.interp(v_ego, _A_TOTAL_MAX_BP, _A_TOTAL_MAX_V)
a_y = v_ego ** 2 * angle_steers * CV.DEG_TO_RAD / (CP.steerRatio * CP.wheelbase)
a_x_allowed = math.sqrt(max(a_total_max ** 2 - a_y ** 2, 0.))
@@ -55,9 +56,9 @@ def get_accel_from_plan(speeds, accels, action_t=DT_MDL, vEgoStopping=0.05):
v_now = speeds[0]
a_now = accels[0]
v_target = interp(action_t, CONTROL_N_T_IDX, speeds)
v_target = np.interp(action_t, CONTROL_N_T_IDX, speeds)
a_target = 2 * (v_target - v_now) / (action_t) - a_now
v_target_1sec = interp(action_t + 1.0, CONTROL_N_T_IDX, speeds)
v_target_1sec = np.interp(action_t + 1.0, CONTROL_N_T_IDX, speeds)
else:
v_target = 0.0
v_target_1sec = 0.0
@@ -67,10 +68,11 @@ def get_accel_from_plan(speeds, accels, action_t=DT_MDL, vEgoStopping=0.05):
return a_target, should_stop
class LongitudinalPlanner:
class LongitudinalPlanner(LongitudinalPlannerSP):
def __init__(self, CP, init_v=0.0, init_a=0.0, dt=DT_MDL):
self.CP = CP
self.mpc = LongitudinalMpc(dt=dt)
LongitudinalPlannerSP.__init__(self, self.CP, self.mpc)
self.fcw = False
self.dt = dt
self.allow_throttle = True
@@ -105,7 +107,10 @@ class LongitudinalPlanner:
return x, v, a, j, throttle_prob
def update(self, sm):
LongitudinalPlannerSP.update(self, sm)
self.mpc.mode = 'blended' if sm['selfdriveState'].experimentalMode else 'acc'
if dec_mpc_mode := self.get_mpc_mode():
self.mpc.mode = dec_mpc_mode
if len(sm['carControl'].orientationNED) == 3:
accel_coast = get_coast_accel(sm['carControl'].orientationNED[1])
@@ -139,7 +144,7 @@ class LongitudinalPlanner:
if reset_state:
self.v_desired_filter.x = v_ego
# Clip aEgo to cruise limits to prevent large accelerations when becoming active
self.a_desired = clip(sm['carState'].aEgo, accel_limits[0], accel_limits[1])
self.a_desired = np.clip(sm['carState'].aEgo, accel_limits[0], accel_limits[1])
# Prevent divergence, smooth in current v_ego
self.v_desired_filter.x = max(0.0, self.v_desired_filter.update(v_ego))
@@ -151,7 +156,7 @@ class LongitudinalPlanner:
if not self.allow_throttle:
clipped_accel_coast = max(accel_coast, accel_limits_turns[0])
clipped_accel_coast_interp = interp(v_ego, [MIN_ALLOW_THROTTLE_SPEED, MIN_ALLOW_THROTTLE_SPEED*2], [accel_limits_turns[1], clipped_accel_coast])
clipped_accel_coast_interp = np.interp(v_ego, [MIN_ALLOW_THROTTLE_SPEED, MIN_ALLOW_THROTTLE_SPEED*2], [accel_limits_turns[1], clipped_accel_coast])
accel_limits_turns[1] = min(accel_limits_turns[1], clipped_accel_coast_interp)
if force_slow_decel:
@@ -176,7 +181,7 @@ class LongitudinalPlanner:
# Interpolate 0.05 seconds and save as starting point for next iteration
a_prev = self.a_desired
self.a_desired = float(interp(self.dt, CONTROL_N_T_IDX, self.a_desired_trajectory))
self.a_desired = float(np.interp(self.dt, CONTROL_N_T_IDX, self.a_desired_trajectory))
self.v_desired_filter.x = self.v_desired_filter.x + self.dt * (self.a_desired + a_prev) / 2.0
def publish(self, sm, pm):
@@ -200,9 +205,11 @@ class LongitudinalPlanner:
action_t = self.CP.longitudinalActuatorDelay + DT_MDL
a_target, should_stop = get_accel_from_plan(longitudinalPlan.speeds, longitudinalPlan.accels,
action_t=action_t, vEgoStopping=self.CP.vEgoStopping)
longitudinalPlan.aTarget = a_target
longitudinalPlan.shouldStop = should_stop
longitudinalPlan.aTarget = float(a_target)
longitudinalPlan.shouldStop = bool(should_stop)
longitudinalPlan.allowBrake = True
longitudinalPlan.allowThrottle = self.allow_throttle
longitudinalPlan.allowThrottle = bool(self.allow_throttle)
pm.send('longitudinalPlan', plan_send)
self.publish_longitudinal_plan_sp(sm, pm)
+1 -1
View File
@@ -18,7 +18,7 @@ def main():
ldw = LaneDepartureWarning()
longitudinal_planner = LongitudinalPlanner(CP)
pm = messaging.PubMaster(['longitudinalPlan', 'driverAssistance'])
pm = messaging.PubMaster(['longitudinalPlan', 'driverAssistance', 'longitudinalPlanSP'])
sm = messaging.SubMaster(['carControl', 'carState', 'controlsState', 'liveParameters', 'radarState', 'modelV2', 'selfdriveState'],
poll='modelV2', ignore_avg_freq=['radarState'])
+2 -2
View File
@@ -1,11 +1,11 @@
#!/usr/bin/env python3
import math
import numpy as np
from collections import deque
from typing import Any
import capnp
from cereal import messaging, log, car
from openpilot.common.numpy_fast import interp
from openpilot.common.params import Params
from openpilot.common.realtime import DT_MDL, Priority, config_realtime_process
from openpilot.common.swaglog import cloudlog
@@ -44,7 +44,7 @@ class KalmanParams:
0.28144091, 0.27958406, 0.27783249, 0.27617149, 0.27458948, 0.27307714,
0.27162685, 0.27023228, 0.26888809, 0.26758976, 0.26633338, 0.26511557,
0.26393339, 0.26278425]
self.K = [[interp(dt, dts, K0)], [interp(dt, dts, K1)]]
self.K = [[np.interp(dt, dts, K0)], [np.interp(dt, dts, K1)]]
class Track:
+1 -1
View File
@@ -2,8 +2,8 @@
import sys
import argparse
from subprocess import check_output, CalledProcessError
from opendbc.car.uds import UdsClient, MessageTimeoutError, SESSION_TYPE, DTC_GROUP_TYPE
from panda import Panda
from panda.python.uds import UdsClient, MessageTimeoutError, SESSION_TYPE, DTC_GROUP_TYPE
parser = argparse.ArgumentParser(description="clear DTC status")
parser.add_argument("addr", type=lambda x: int(x,0), nargs="?", default=0x7DF) # default is functional (broadcast) address
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
import argparse
from opendbc.car import uds
from openpilot.tools.lib.live_logreader import live_logreader
from openpilot.tools.lib.logreader import LogReader, ReadMode
from panda.python import uds
def main(route: str | None, addrs: list[int]):
@@ -16,8 +16,8 @@ import argparse
from typing import NamedTuple
from subprocess import check_output, CalledProcessError
from opendbc.car.uds import UdsClient, SESSION_TYPE, DATA_IDENTIFIER_TYPE
from panda.python import Panda
from panda.python.uds import UdsClient, SESSION_TYPE, DATA_IDENTIFIER_TYPE
class ConfigValues(NamedTuple):
default_config: bytes
+3 -3
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
import argparse
import numpy as np
import capnp
from collections import defaultdict
from cereal.messaging import SubMaster
from openpilot.common.numpy_fast import mean
def cputime_total(ct):
return ct.user + ct.nice + ct.system + ct.idle + ct.iowait + ct.irq + ct.softirq
@@ -49,7 +49,7 @@ if __name__ == "__main__":
if sm.updated['deviceState']:
t = sm['deviceState']
last_temp = mean(t.cpuTempC)
last_temp = np.mean(t.cpuTempC)
last_mem = t.memoryUsagePercent
if sm.updated['procLog']:
@@ -72,7 +72,7 @@ if __name__ == "__main__":
total_times = total_times_new[:]
busy_times = busy_times_new[:]
print(f"CPU {100.0 * mean(cores):.2f}% - RAM: {last_mem:.2f}% - Temp {last_temp:.2f}C")
print(f"CPU {100.0 * np.mean(cores):.2f}% - RAM: {last_mem:.2f}% - Temp {last_temp:.2f}C")
if args.cpu and prev_proclog is not None and prev_proclog_t is not None:
procs: dict[str, float] = defaultdict(float)
+1 -2
View File
@@ -2,9 +2,8 @@
import sys
import argparse
from subprocess import check_output, CalledProcessError
from opendbc.car.uds import UdsClient, SESSION_TYPE, DTC_REPORT_TYPE, DTC_STATUS_MASK_TYPE, get_dtc_num_as_str, get_dtc_status_names
from panda import Panda
from panda.python.uds import UdsClient, SESSION_TYPE, DTC_REPORT_TYPE, DTC_STATUS_MASK_TYPE
from panda.python.uds import get_dtc_num_as_str, get_dtc_status_names
parser = argparse.ArgumentParser(description="read DTC status")
parser.add_argument("addr", type=lambda x: int(x,0))
+2 -2
View File
@@ -3,9 +3,9 @@
import argparse
import struct
from enum import IntEnum
from panda import Panda
from panda.python.uds import UdsClient, MessageTimeoutError, NegativeResponseError, SESSION_TYPE,\
from opendbc.car.uds import UdsClient, MessageTimeoutError, NegativeResponseError, SESSION_TYPE,\
DATA_IDENTIFIER_TYPE, ACCESS_TYPE
from panda import Panda
from datetime import date
# TODO: extend UDS library to allow custom/vendor-defined data identifiers without ignoring type checks
+7 -8
View File
@@ -8,7 +8,6 @@ import cereal.messaging as messaging
from cereal import car, log
from openpilot.common.params import Params
from openpilot.common.realtime import config_realtime_process, DT_MDL
from openpilot.common.numpy_fast import clip
from openpilot.selfdrive.locationd.models.car_kf import CarKalman, ObservationKind, States
from openpilot.selfdrive.locationd.models.constants import GENERATED_DIR
from openpilot.selfdrive.locationd.helpers import PoseCalibrator, Pose
@@ -66,7 +65,7 @@ class ParamsLearner:
# This is done to bound the road roll estimate when localizer values are invalid
roll = 0.0
roll_std = np.radians(10.0)
self.roll = clip(roll, self.roll - ROLL_MAX_DELTA, self.roll + ROLL_MAX_DELTA)
self.roll = np.clip(roll, self.roll - ROLL_MAX_DELTA, self.roll + ROLL_MAX_DELTA)
yaw_rate_valid = msg.angularVelocityDevice.valid and self.calibrator.calib_valid
yaw_rate_valid = yaw_rate_valid and 0 < self.yaw_rate_std < 10 # rad/s
@@ -203,11 +202,11 @@ def main():
learner = ParamsLearner(CP, CP.steerRatio, 1.0, 0.0)
x = learner.kf.x
angle_offset_average = clip(math.degrees(x[States.ANGLE_OFFSET].item()),
angle_offset_average = np.clip(math.degrees(x[States.ANGLE_OFFSET].item()),
angle_offset_average - MAX_ANGLE_OFFSET_DELTA, angle_offset_average + MAX_ANGLE_OFFSET_DELTA)
angle_offset = clip(math.degrees(x[States.ANGLE_OFFSET].item() + x[States.ANGLE_OFFSET_FAST].item()),
angle_offset = np.clip(math.degrees(x[States.ANGLE_OFFSET].item() + x[States.ANGLE_OFFSET_FAST].item()),
angle_offset - MAX_ANGLE_OFFSET_DELTA, angle_offset + MAX_ANGLE_OFFSET_DELTA)
roll = clip(float(x[States.ROAD_ROLL].item()), roll - ROLL_MAX_DELTA, roll + ROLL_MAX_DELTA)
roll = np.clip(float(x[States.ROAD_ROLL].item()), roll - ROLL_MAX_DELTA, roll + ROLL_MAX_DELTA)
roll_std = float(P[States.ROAD_ROLL].item())
if learner.active and learner.speed > LOW_ACTIVE_SPEED:
# Account for the opposite signs of the yaw rates
@@ -226,9 +225,9 @@ def main():
liveParameters.sensorValid = sensors_valid
liveParameters.steerRatio = float(x[States.STEER_RATIO].item())
liveParameters.stiffnessFactor = float(x[States.STIFFNESS].item())
liveParameters.roll = roll
liveParameters.angleOffsetAverageDeg = angle_offset_average
liveParameters.angleOffsetDeg = angle_offset
liveParameters.roll = float(roll)
liveParameters.angleOffsetAverageDeg = float(angle_offset_average)
liveParameters.angleOffsetDeg = float(angle_offset)
liveParameters.valid = all((
avg_offset_valid,
total_offset_valid,
+1
View File
@@ -10,6 +10,7 @@ cdef extern from "common/clutil.h":
cdef unsigned long CL_DEVICE_TYPE_DEFAULT
cl_device_id cl_get_device_id(unsigned long)
cl_context cl_create_context(cl_device_id)
void cl_release_context(cl_context)
cdef extern from "selfdrive/modeld/models/commonmodel.h":
cppclass ModelFrame:
+5 -1
View File
@@ -8,7 +8,7 @@ from libc.stdint cimport uintptr_t
from msgq.visionipc.visionipc cimport cl_mem
from msgq.visionipc.visionipc_pyx cimport VisionBuf, CLContext as BaseCLContext
from .commonmodel cimport CL_DEVICE_TYPE_DEFAULT, cl_get_device_id, cl_create_context
from .commonmodel cimport CL_DEVICE_TYPE_DEFAULT, cl_get_device_id, cl_create_context, cl_release_context
from .commonmodel cimport mat3, ModelFrame as cppModelFrame, DrivingModelFrame as cppDrivingModelFrame, MonitoringModelFrame as cppMonitoringModelFrame
@@ -17,6 +17,10 @@ cdef class CLContext(BaseCLContext):
self.device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT)
self.context = cl_create_context(self.device_id)
def __dealloc__(self):
if self.context:
cl_release_context(self.context)
cdef class CLMem:
@staticmethod
cdef create(void * cmem):
+3 -3
View File
@@ -1,9 +1,9 @@
from math import atan2
import numpy as np
from cereal import car, log
import cereal.messaging as messaging
from openpilot.selfdrive.selfdrived.events import Events
from openpilot.common.numpy_fast import interp
from openpilot.common.realtime import DT_DMON
from openpilot.common.filter_simple import FirstOrderFilter
from openpilot.common.stat_live import RunningStatFilter
@@ -205,10 +205,10 @@ class DriverMonitoring:
bp = model_data.meta.disengagePredictions.brakeDisengageProbs[0] # brake disengage prob in next 2s
k1 = max(-0.00156*((car_speed-16)**2)+0.6, 0.2)
bp_normal = max(min(bp / k1, 0.5),0)
self.pose.cfactor_pitch = interp(bp_normal, [0, 0.5],
self.pose.cfactor_pitch = np.interp(bp_normal, [0, 0.5],
[self.settings._POSE_PITCH_THRESHOLD_SLACK,
self.settings._POSE_PITCH_THRESHOLD_STRICT]) / self.settings._POSE_PITCH_THRESHOLD
self.pose.cfactor_yaw = interp(bp_normal, [0, 0.5],
self.pose.cfactor_yaw = np.interp(bp_normal, [0, 0.5],
[self.settings._POSE_YAW_THRESHOLD_SLACK,
self.settings._POSE_YAW_THRESHOLD_STRICT]) / self.settings._POSE_YAW_THRESHOLD
+9 -2
View File
@@ -652,8 +652,11 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = {
},
EventName.brakeHold: {
ET.USER_DISABLE: EngagementAlert(AudibleAlert.disengage),
ET.NO_ENTRY: NoEntryAlert("Brake Hold Active"),
ET.WARNING: Alert(
"Press Resume to Exit Brake Hold",
"",
AlertStatus.userPrompt, AlertSize.small,
Priority.LOW, VisualAlert.none, AudibleAlert.none, .2),
},
EventName.parkBrake: {
@@ -1063,6 +1066,10 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = {
EventName.hyundaiRadarTracksConfirmed: {
ET.PERMANENT: NormalPermanentAlert("Radar tracks available. Restart the car to initialize")
},
EventName.experimentalModeSwitched: {
ET.WARNING: NormalPermanentAlert("Experimental Mode Switched", duration=1.5)
}
}
+14 -4
View File
@@ -25,6 +25,7 @@ from openpilot.system.version import get_build_metadata
from openpilot.sunnypilot.mads.mads import ModularAssistiveDrivingSystem
from openpilot.sunnypilot.selfdrive.car.car_specific import CarSpecificEventsSP
from openpilot.sunnypilot.selfdrive.car.experimental_switcher import ExperimentalSwitcher
REPLAY = "REPLAY" in os.environ
SIMULATION = "SIMULATION" in os.environ
@@ -44,7 +45,7 @@ SafetyModel = car.CarParams.SafetyModel
IGNORED_SAFETY_MODES = (SafetyModel.silent, SafetyModel.noOutput)
class SelfdriveD:
class SelfdriveD(ExperimentalSwitcher):
def __init__(self, CP=None):
self.params = Params()
@@ -140,6 +141,8 @@ class SelfdriveD:
self.car_events_sp = CarSpecificEventsSP(self.CP, self.params)
ExperimentalSwitcher.__init__(self, self.params)
def update_events(self, CS):
"""Compute onroadEvents from carState"""
@@ -367,12 +370,18 @@ class SelfdriveD:
if self.sm['modelV2'].frameDropPerc > 20:
self.events.add(EventName.modeldLagging)
# toggle experimental mode once on distance button hold
if self.CP.openpilotLongitudinalControl:
ExperimentalSwitcher.update(self, CS, self.events, self.experimental_mode)
# decrement personality on distance button press
if self.CP.openpilotLongitudinalControl:
if any(not be.pressed and be.type == ButtonType.gapAdjustCruise for be in CS.buttonEvents):
self.personality = (self.personality - 1) % 3
self.params.put_nonblocking('LongitudinalPersonality', str(self.personality))
self.events.add(EventName.personalityChanged)
if not self.experimental_mode_switched:
self.personality = (self.personality - 1) % 3
self.params.put_nonblocking('LongitudinalPersonality', str(self.personality))
self.events.add(EventName.personalityChanged)
self.experimental_mode_switched = False
def data_sample(self):
car_state = messaging.recv_one(self.car_state_sock)
@@ -452,6 +461,7 @@ class SelfdriveD:
ss.alertStatus = self.AM.current_alert.alert_status
ss.alertType = self.AM.current_alert.alert_type
ss.alertSound = self.AM.current_alert.audible_alert
ss.alertHudVisual = self.AM.current_alert.visual_alert
self.pm.send('selfdriveState', ss_msg)
@@ -121,7 +121,7 @@ class Plant:
ss.selfdriveState.personality = self.personality
control.controlsState.forceDecel = self.force_decel
car_state.carState.vEgo = float(self.speed)
car_state.carState.standstill = self.speed < 0.01
car_state.carState.standstill = bool(self.speed < 0.01)
car_state.carState.vCruise = float(v_cruise * 3.6)
car_control.carControl.orientationNED = [0., float(pitch), 0.]
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6e1555145a4482e4148c2e7a5cdbf370720a3cf684f18686a50bf25de0b55650
size 356302
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:79ccc3bd2094ba8a55adedf0007b0152eb3a68edc5e2d35aeccbba122d5811c6
size 356151
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0720a28167410da8dc5aa940f9ff916dcd3e1863ba4fb5b91c73ddf8c7e10c6c
size 256451
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:45f39fe1d1dc8c271f577d1a12812e01da34979bf3fffaad01a19a7a61b6d456
size 256342
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f7b1411e8b4a91b4df94322023d83f5f2f27245fa761db73ffafd06b91068062
size 284390
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:531fae8fa368a3edbcd291174d501095c1760d20ecbf1963f3eb5ce80163251f
size 284311
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:221caa376d9052d375dc82225f6c6f894fa684f4be2f387bf2cf46927ed3cd15
size 332404
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ec8f8d879b38a4c8d4319a3bd67872d5e5d348bc5472443c4c8aa1cb1dd62cf5
size 332404
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d02a7e8de6fcc2f0d2c8371116d9acef752e53f3a0c701f89a8c12927c666678
size 268879
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:68afd54dc68f6abff699d2740f90830b0f492db8818869e8936a63e7bed80458
size 268827
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b17cefe94984aa855dc21f63afabf3514619cc0b4dc5eafc9c3f3594577a655c
size 435709
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:32a458c0b364c1c793a4a843fe7a8fd21dd4ad45ff87dc8ad41a8e8759e52c80
size 437811
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:333ea99fc2d88f0ec405f2ea5f1d86881a5879dc77ceee14700da1063a1319ac
size 308602
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7b3d412d4066f9ac90788e11a20d99ea3ff92eafdc8a317610b7d9c918aedd59
size 308644
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:426f453cd17daaa3db48d98a8e2a34f7f113b91bdfe3da2dbe6d8c13c72f37f6
size 392249
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8ad0c3881d7d88f9038a1b3a5e43c779e84dca47e2f7f6d45a3449cd8a7dec99
size 393122
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:88e0d29b9a909c9cb97e47f62e0b42bb5761ac65d6836eb4d415982954df28f0
size 334267
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6a0f9dc3743e4e09375f7a3289228b64486915ae4ef6dfcff66572a34820d5d2
size 334502
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:77a887290be2730ba5b3d558de4a7c72598c3a20372038f5c9de08b57a84c33b
size 470504
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:944406ae64efb422b568437588fec6a8a8b5b7d9e577dc1d22c83a1d6d3813ff
size 470417
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6e152e4ffbfb1fa9cfaf3971859ea47ca5815735a3c391dc9b8c6e233a26658d
size 260279
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d80c61dc2a0b3685a522013c8aa8347adfdfc6d0611485da88b3a17771c68301
size 260913
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ed0cfd5fff468b94c14ea0d965b0a6d9f827b14f31c87657f4015137f7811e82
size 29648
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:074f0bbd96d130e2350d6a3db872696cd35a4c2fe7e32845b53698528a500587
size 29645
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4223262ea5da92b081a6024d135c2ed892901363c7b2b8be0b121578ee9eb4aa
size 234609
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1c4ddf166d015b6886ee3250c977ff1d37542a6a3b364dc58316b30f21dbe56d
size 234433
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:03aa9d65b2da189437de176269c698deb3fecd6167e958caf3530737cf15a431
size 217479
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3271e31149f7053d134d3a0217851167e573647a8b415138e8c80d429d0a02c9
size 217488
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bd67adc5e5ea3353ef7cdd306b2e3b0f1b02862739ef3e313f0e4a20372c696a
size 293071
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:35c95eaf222affae2e236f0b717c17e7f3b8a30e85d4ebb4ad1506e5025ce0b8
size 293078

Some files were not shown because too many files have changed in this diff Show More