Commit Graph

859 Commits

Author SHA1 Message Date
Kumar
34bbdf4d7f Controls: Automatic lane change (#653)
* init alc controller

* only for sunny

* rebase fix

* ui

* add ui preview

* Update common/params_keys.h

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>

* Update selfdrive/ui/sunnypilot/SConscript

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>

* Update selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/lane_change_settings.h

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>

* Update selfdrive/ui/sunnypilot/qt/offroad/settings/lateral/lane_change_settings.cc

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>

* review sugg

* code review

* renaming

* move around

* style

* fix types and params exceptions handling

* take out magic numbers

* more

* rename

* shorter

* make sure reset happens at the end of every DH loop

* split into multiple updates

* just 3 seconds

* use default states

* oops

* more readable

* oops

* some space and lines

* run in DH loop directly

* adjust ui preview

* nudgeless should process immediately

* check option instead

* more explicit

* even more explicit

* tests

* brake pedal release should not allow auto lane change (caught by test)

* unnecessary

* no continuous auto lane change

* Revert "unnecessary"

This reverts commit 93d135b54a.

* more tests

* less

* less less

* update again

* more cleanup

* better

* AutoLaneChangeState -> AutoLaneChangeMode

* update

* lint

* unused

* test all states

* license

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
2025-03-24 22:26:48 -04:00
Kumar
029a601674 Device: Quiet Mode (#654)
* init quiet mode

* only for sunny

* static

* toggle

* let's back this up

* review sugg

* oh okay

* review

* fix: ensure boolean conversion for QuietDrive parameter

* Refactor return statement to use boolean conversion for clarity in quiet mode logic

* Update selfdrive/ui/sunnypilot/quietmode.py

* rename

* sunny

* Revert "sunny"

This reverts commit 6ac4cf4b8d.

* sunny

* Revert "sunny"

This reverts commit c2bffddc05.

* sunny

* ui: support dynamic state updates for `PushButtonSP`

* test btn

* override mouse release events

* Revert "test btn"

This reverts commit cd9c9dde9a.

* Reapply "test btn"

This reverts commit 9b36b2e085.

* abstract param flipping

* Revert "Reapply "test btn""

This reverts commit 8104a262b0.

* use new button state for PushButtonSP

* Quiet Drive -> Quiet Mode

* driver camera btn moved

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
2025-03-23 23:15:11 -04:00
Jason Wen
e6177c49aa athenad: avoid infinite loop waiting for comma registration (#701)
Athenad: avoid infinite loop waiting for comma registration
2025-03-22 22:48:58 -04:00
DevTekVE
43e43849ad sunnylink: Settings backup & restore (#681)
* Add AES encryption and utility methods

This commit introduces a new AESCipher class that can be used for AES encryption with support for both AES-128 and AES-256. It also adds a set of utility functions, including methods for RSA to AES key derivation, file decryption and compression, and encryption and decompression. These changes provide fundamental cryptographic functionalities for data security within the system.

* Revised backup management system with new structures

This update introduces important revisions to the backup management system. A new struct named 'BackupManagerSP' has been integrated into the 'custom.capnp' file, replacing 'CustomReserved6'. This new struct includes several variables that help keep track of backup and restore status, progress and related messages.

Additional code modifications were made in 'base.py' and 'api.py' to include a 'json' parameter in the 'api_get' method. Lastly, 'manager.py' has been updated with functions to manage device configuration backups to and from sunnylink.

The changes promote better handling and management of data backup and restoration processes. The update is specifically designed to ensure that the backup information is well integrated into the system, with properly tracked status and progress.

* Refactor `allKeys` to filter by parameter key type

Updated the `allKeys` method to support filtering by `ParamKeyType`, allowing more specific key retrieval. Added a default value for backward compatibility and updated related bindings and keys to reflect this change.

* Improve Backup and Restore mechanisms

The commit refactors and improves several aspects of the backup and restore mechanisms in the `BackupManagerSP` class.

These improvements include removing redundant status tracking variables and replacing them with unified ones, updating the messaging system to handle all changes correctly, and including an enumeration `OperationType` to keep track of the type of operation currently being processed.

This commit also applies stricter conditions for restore operations, such that it only restores parameters that are currently marked as backupable, and skips those that are not. This is a preventive measure against potential issues when restoring parameters that are no longer relevant or could conflict with current versions.

Also, the encryption and decryption methods were updated to use AES-256 for more security. These changes have increased the robustness and reliability of the backup and restoration processes.

* copyright

* Add backup_manager process to offroad sunnypilot tasks

The backup_manager process is introduced to handle backups during offroad mode when SunnyLink is ready. This ensures proper backup management functionality integrated into the system.

* Simplify backup endpoint construction in restore method

Replaced conditional expression with a more concise and readable `or` operation for constructing the backup endpoint. This makes the code cleaner and easier to maintain while preserving functionality.

* Added support for backing up and restoring sunnypilot settings

An update to the sunnypilot functionality now provides two new features that allow users to backup and restore their sunnypilot settings. The changes include the addition of UI controls for initiating backup and restore operations, and the creation of a system-wide state management function for tracking these operations. This enhancement significantly improves the user experience by providing a safety net for user settings in case of software failures, bugs, or unintended changes.

* Refactor type hints to use PEP 604 syntax for clarity

Replaced `Optional` and `Dict` type hints with `|` and `dict` syntax for improved readability and compliance with Python 3.10+. Updated related imports and adjusted list comprehension for cleaner code.

* Update import path for hardware module in utils.py

Replaced the import path for the `Paths` module to align with the new directory structure under `openpilot`. This ensures compatibility with recent project reorganization and avoids import errors.

* Improve RSA key handling and fix backup status comparison

Added explicit RSA key type checks to handle invalid key formats. Enhanced type safety in `manager.py` by ensuring the backup status comparison returns a boolean. These changes improve robustness and error handling in backups.

* format

* more

* Improve backup and restore flow with progress tracking and fixes

Added proper progress tracking and cleanup logic during restore operations. Enhanced restore experience by resetting progress after completion and introducing confirmation dialogs for errors and completion. Updated API compatibility with a version query parameter for backups.

* Enable backup button only when restore process is complete

Previously, the backup button could be enabled during a restore operation, which might cause unintended behavior. This update introduces a check to ensure the backup button remains disabled while a restore process is active. This improves user experience and prevents potential conflicts.

* Fix restore button state handling during restore process

Ensure the restore button is disabled consistently when a restore is in progress. This prevents user interaction issues and aligns the button state with the restore operation status.

* "Refactor restore logic and improve button state handling"

Replaced `is_restoring` with `restore_request_pending` for clarity and better state management. Adjusted button behavior to immediately disable upon user action, ensuring improved UX and preventing repeat inputs. Refined restore completion flow for better consistency and reliability.

* Refine restore process logic for SunnyLink settings.

Introduced `restore_request_started` to improve handling of restore states and ensure accurate UI updates during the process. Adjusted case handling to enhance clarity and maintain proper behavior when restoring settings, especially during ongoing or completed requests.

* revert

* move around

* fix enabled states for different statuses

* add prompt to notify backup is complete

* same states as restore

* disable buttons if sunnylink is off

* can use the same texts

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
2025-03-22 15:58:04 +00:00
Jason Wen
309304a352 Controls: Neural Network Lateral Control (NNLC) for Torque Lateral Accel Control (#695)
* init

* more init

* keep it alive

* fixes

* more fixes

* more fix

* new submodule for nn data

* bump submodule

* update path to submodule

* spacing???

* update submodule path

* update submodule path

* bump

* dump

* bump

* introduce params

* Add Neural Network Lateral Control toggle to developer panel

This introduces a new toggle for enabling Neural Network Lateral Control (NNLC), providing detailed descriptions of its functionality and compatibility. It includes UI integration, car compatibility checks, and feedback links for unsupported vehicles.

* decouple even more

* static

* codespell

* remove debug

* in structs

* fix import

* convert to capnp

* fixes

* debug

* only initialize if NNLC is enabled or allow to enable

* oops

* fix initialization

* only allow engage if nnlc is off

* fix toggle param

* fix tests

* lint

* fix more test

* capnp test

* try this out

* validate if it's not None

* make it 33 to match

* align

* share the same friction input calculation

* return stock values if not enabled

* unused

* split base and child

* space

* rename

* NeuralNetworkFeedForwardModel

* less

* just use file name

* try this

* more explicit

* rename

* move it

* child class for additional controllers

* rename

* time to split out custom lateral acceleration

* move around

* space

* fix

* TODO-SP

* TODO-SP

* update regardless, it's an extension now

* update name and expose toggle

* ui: sunnypilot Panel -> Steering Panel

* Update selfdrive/ui/sunnypilot/qt/offroad/settings/lateral_panel.h

* merge

* move to steering panel

* no need for this

* live params in a thread

* no live for now

* new structs

* more ui

* more flexible

* more ui

* no longer needed

* another ui

* cereal changes

* bump opendbc

* simplify checks

* all in one place

* split Enhanced Lat Accel

* handle unrecognized platform

* test for fingerprinting

* fix fingerprint

* NNLC: Mock data for unrecognized cars

* fix fingerprints

* test to verify model loading

* bump neural_network_data

* use pytest

* use different one for now

* fix ui preview alignments

* typing

* more type

* show a platform

* show match

* init params for tests

* ok ruff

* make sure to loop through tests

* ok again ruff

* ok we need this lol

---------

Co-authored-by: DevTekVE <devtekve@gmail.com>
2025-03-22 09:40:29 -04:00
Jason Wen
0990212edc Revert "Controls: Neural Network Lateral Control (NNLC) for Torque Lateral Accel Control" (#694)
Revert "Controls: Neural Network Lateral Control (NNLC) for Torque Lateral Ac…"

This reverts commit ecb4026269.
2025-03-21 16:13:50 -04:00
Jason Wen
ecb4026269 Controls: Neural Network Lateral Control (NNLC) for Torque Lateral Accel Control (#667)
* init

* more init

* keep it alive

* fixes

* more fixes

* more fix

* new submodule for nn data

* bump submodule

* update path to submodule

* spacing???

* update submodule path

* update submodule path

* bump

* dump

* bump

* introduce params

* Add Neural Network Lateral Control toggle to developer panel

This introduces a new toggle for enabling Neural Network Lateral Control (NNLC), providing detailed descriptions of its functionality and compatibility. It includes UI integration, car compatibility checks, and feedback links for unsupported vehicles.

* decouple even more

* static

* codespell

* remove debug

* in structs

* fix import

* convert to capnp

* fixes

* debug

* only initialize if NNLC is enabled or allow to enable

* oops

* fix initialization

* only allow engage if nnlc is off

* fix toggle param

* fix tests

* lint

* fix more test

* capnp test

* try this out

* validate if it's not None

* make it 33 to match

* align

* share the same friction input calculation

* return stock values if not enabled

* unused

* split base and child

* space

* rename

* NeuralNetworkFeedForwardModel

* less

* just use file name

* try this

* more explicit

* rename

* move it

* child class for additional controllers

* rename

* time to split out custom lateral acceleration

* move around

* space

* fix

* TODO-SP

* TODO-SP

* update regardless, it's an extension now

* update name and expose toggle

* ui: sunnypilot Panel -> Steering Panel

* Update selfdrive/ui/sunnypilot/qt/offroad/settings/lateral_panel.h

* merge

* move to steering panel

* no need for this

* live params in a thread

* no live for now

* new structs

* more ui

* more flexible

* more ui

* no longer needed

* another ui

* cereal changes

* bump opendbc

* simplify checks

* all in one place

* split Enhanced Lat Accel

---------

Co-authored-by: DevTekVE <devtekve@gmail.com>
2025-03-21 15:38:31 -04:00
Jason Wen
bf2731b470 MADS: Steering Mode on Brake Pedal Press (#687)
* reimplement

* bump opendbc

* Apply suggestions from code review

Co-authored-by: DevTekVE <devtekve@gmail.com>

* update toggle positions

* translations from bot later

---------

Co-authored-by: DevTekVE <devtekve@gmail.com>
2025-03-19 18:24:56 -04:00
Jason Wen
dd37a35b59 Revert "MADS: Steering Mode on Brake Pedal Press" (#686)
* Revert "MADS: Steering Mode on Brake Pedal Press (#684)"

This reverts commit 4525659a7e.

* bump
2025-03-19 16:02:45 -04:00
Jason Wen
4525659a7e MADS: Steering Mode on Brake Pedal Press (#684)
* MADS: cleanup param assignments

* MADS: Steering Mode on Brake Pedal Press

* bump opendbc

* translations

* make sure to initialize

* ci try this

* Revert "ci try this"

This reverts commit da975f61c3.

* Revert "translations"

This reverts commit a65aad5911.
2025-03-19 13:57:15 -04:00
DevTekVE
f0abacbc59 Merge branch 'refs/heads/master-at-17032025' into sync-17032025
# Conflicts:
#	opendbc_repo
#	selfdrive/car/card.py
#	selfdrive/car/tests/test_car_interfaces.py
#	selfdrive/car/tests/test_models.py
#	selfdrive/controls/controlsd.py
#	selfdrive/controls/lib/tests/test_latcontrol.py
#	selfdrive/pandad/panda.h
#	system/manager/process_config.py
Sync: `commaai/opendbc:master` into `sunnypilot/opendbc:master-new`
2025-03-18 01:05:34 -04:00
Adeeb Shihadeh
519ea9dcab Make model daemons Python processes (#34880) 2025-03-15 15:55:29 -07:00
Adeeb Shihadeh
fb7b9c0f94 camerad: log failed sync time (#34878)
* camerad: log failed sync time

* mv

---------

Co-authored-by: Comma Device <device@comma.ai>
2025-03-15 14:02:03 -07:00
Adeeb Shihadeh
e1eac057ca camerad: fix rare BPS startup issues (#34871)
* repros

* handle old frames

* cleanup

* more freq

* fix request id skipping

---------

Co-authored-by: Comma Device <device@comma.ai>
2025-03-14 19:30:09 -07:00
Jason Wen
70f8225efc Merge branch 'upstream/openpilot/master' into sync-20250312
# Conflicts:
#    opendbc_repo
#    selfdrive/car/tests/test_models.py
2025-03-13 02:41:16 -04:00
Adeeb Shihadeh
196eb50d23 camerad: log whether sync fails in IFE or BPS (#34854) 2025-03-12 15:59:27 -07:00
Adeeb Shihadeh
800a41c4e1 agnos 11.11 (#34816) 2025-03-12 14:02:54 -07:00
Adeeb Shihadeh
8c359892be camerad: clear request queue on exit (#34842)
* camerad: doesn't need rt

* clear q
2025-03-11 11:02:02 -07:00
Adeeb Shihadeh
b33342c18f loggerd: limit encoded queue size (#34837)
* loggerd: limit encoded queue size

* less spammy
2025-03-11 10:22:49 -07:00
ZwX1616
1c678c910e camerad: fix AE oscillation (#34833)
* flooring is fine

* .

* better solution

---------

Co-authored-by: Comma Device <device@comma.ai>
2025-03-10 16:01:03 -07:00
Dean Lee
5574b91d17 python ui: add confirm dialog implementation (#34828)
add confirm dialog implementation
2025-03-10 08:28:32 -07:00
Dean Lee
2bfbb181e5 python ui: add Keyboard Implementation (#34827)
implement keyboard
2025-03-09 18:48:01 -07:00
DevTekVE
a4ef5ad982 Merge remote-tracking branch 'comma/master' into sync-20250309
# Conflicts:
#	.github/workflows/ui_preview.yaml
#	common/params_keys.h
#	msgq_repo
#	opendbc_repo
#	panda
#	selfdrive/ui/qt/offroad/firehose.h
#	selfdrive/ui/tests/test_ui/run.py
#	system/manager/process_config.py
2025-03-09 14:53:03 +01:00
Jason Wen
290383128e Sync: Fix conflicts 2025-03-09 00:53:06 -05:00
Adeeb Shihadeh
878ca53d78 hw: remove unused function 2025-03-07 19:01:11 -08:00
Dean Lee
2d2efb3f58 pyui: implement styled label and text box (#34813)
implement styled label
2025-03-07 14:20:49 -08:00
Dean Lee
3e629acf79 camerad: use ALL_CAMERA_CONFIGS array (#34810)
use ALL_CAMERA_CONFIGS array
2025-03-07 10:31:01 -08:00
Dean Lee
a0a9df2d55 loggerd: enhance ZstdFileWriter test coverage with variable data sizes (#34812)
enhance ZstdFileWriter test coverage
2025-03-07 10:23:46 -08:00
Adeeb Shihadeh
ca7b4340c1 camerad: make recovery reset threshold based on queue depth (#34803)
Co-authored-by: Comma Device <device@comma.ai>
2025-03-06 16:57:37 -08:00
Dean Lee
e9f7c01a3a camerad: move output_type to config (#34792)
move output_type to config
2025-03-06 10:17:58 -08:00
Dean Lee
2c2c6e6437 deleter: fix duplicate segments in get_preserved_segments return value (#34795)
fix duplicate segments in get_preserved_segments return value
2025-03-06 10:16:56 -08:00
Adeeb Shihadeh
8c2cd247f0 camerad: stress test (#34735)
* refactor a bunch of stuff

* prob

* enable

* rm print

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai>
2025-03-05 19:31:44 -08:00
Adeeb Shihadeh
4bb0dfd59c camerad: cleaner queueing logic (#34786) 2025-03-05 17:12:30 -08:00
Adeeb Shihadeh
f4d17cbfdd camerad: sanity check tests (#34785)
lil more
2025-03-05 16:54:35 -08:00
Adeeb Shihadeh
701868d5cd firehose auto start + stats (#34747)
* don't need that

* stats

* lil more

* lil more

* cleanup

* tweaks

---------

Co-authored-by: Comma Device <device@comma.ai>
2025-03-03 18:21:02 -08:00
Adeeb Shihadeh
41346b2cc7 agnos 11.10 (#34764) 2025-03-03 16:40:35 -08:00
Adeeb Shihadeh
97ffda4ada agnos 11.9 (#34762) 2025-03-03 10:16:05 -08:00
Adeeb Shihadeh
a2bc5061e4 camerad: fix bps flush (#34758) 2025-03-02 20:22:06 -08:00
Dean Lee
c52112ad4e loggerd: eliminate recursion from handle_encoder_msg (#33453)
* refactor handle_encoder_msg

* removing the recursion only

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2025-03-02 20:01:21 -08:00
Adeeb Shihadeh
c32c405f65 remove model shims (#34750) 2025-03-02 13:39:36 -08:00
Adeeb Shihadeh
54f1b00447 Log git source commit (#34749)
* Log git source commit

* strip

* fix trim

* no trim
2025-03-02 13:11:38 -08:00
DevTekVE
1a8dd310ae Model: split modeld into it's own contained modeld implementation (#642)
* Add support for TinyGrad model runner processing

Introduced a new function `is_tinygrad_model` to detect TinyGrad as an active model runner. Updated the `is_stock_model` logic to account for TinyGrad models and added a new process entry for TinyGrad in the model manager. This enables handling TinyGrad models alongside existing configurations.

adding modeld back

Add support for `modeld_v2` and update paths for consistency

Updated `SConscript` files to integrate `modeld_v2` alongside `modeld` and adjusted script paths for correct metadata handling. Adjusted various configurations and scripts, such as `labeler.yaml` and `build_release.sh`, to include `modeld_v2` and ensure cohesive project structure.

Refactor imports to use updated `modeld_v2` paths.

Replaced outdated `modeld` references with their `modeld_v2` counterparts for consistency and clarity across the codebase. Also updated `.gitignore` to accommodate new directory structure. This change ensures better maintainability and alignment with the new directory schema.

Refactor and reorganize modeld to sunnypilot/modeld_v2 structure.

Moved and renamed `modeld` components to the new `sunnypilot/modeld_v2` directory for better organization and modularity. Updated imports and file references to align with the new structure, ensuring compatibility and functionality. Streamlined project structure to improve maintainability and future development.

* typo

* Use `stock` model runner and refactor model checks.

Replaces outdated model detection logic with unified `stock` runner integration, simplifying the decision flow for model selection. Includes `stock` as a new enum in the `Runner` type and updates affected references accordingly.

* Handle missing 'sim_pose' in model outputs gracefully.

Added conditional checks to ensure the code handles cases where 'sim_pose' is absent in the model outputs. Fallback behaviors use 'plan' data when 'sim_pose' is unavailable, preventing potential errors and enhancing robustness.
2025-03-02 20:49:30 +01:00
Adeeb Shihadeh
00e447bc30 Revert "camerad: make robust to introduced failures (#34723)"
This reverts commit c10abce1d5.
2025-02-28 14:09:53 -08:00
Dean Lee
d9bc9be388 camerad: ensure sync objects are assigned only on successful creation (#34731)
ensure sync objects are assigned only on successful creation
2025-02-28 07:49:48 -08:00
Dean Lee
1bd0d6577c camerad: remove unnecessary pthread linkage (#34732)
remove unnecessary pthread linkage
2025-02-28 07:49:10 -08:00
Adeeb Shihadeh
c10abce1d5 camerad: make robust to introduced failures (#34723)
* camerad: make robust to introduced failures

* more test

* start here

---------

Co-authored-by: Comma Device <device@comma.ai>
2025-02-27 18:26:31 -08:00
Maxime Desroches
25463deeec Disable IR switch before setting torch (#34725)
switch reset
2025-02-27 17:20:32 -08:00
Adeeb Shihadeh
937e2f7eb2 camerad: spectra stress test (#34716)
* cam stress

* lint fixes

---------

Co-authored-by: Comma Device <device@comma.ai>
2025-02-27 13:41:33 -08:00
Dean Lee
cd014325c5 camerad: remove unused CameraState forward declaration (#34703)
remove unused CameraState forward declaration
2025-02-24 15:58:15 -08:00
Dean Lee
0619e9a581 v4l_encoder: used encoder_info.fps instead of hardcoded 20 (#34701)
Used encoder_info.fps instead of hardcoded 20
2025-02-24 07:06:38 -08:00