mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-25 01:02:13 +08:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 40dc4e1591 | |||
| cce4810904 | |||
| 5b58f9c1f5 | |||
| 815ac7732b | |||
| 2321f9d8f5 | |||
| b9020e0003 | |||
| ceb466578a | |||
| e1cfea4924 | |||
| dd8a2bf83a | |||
| ba36a28f2a | |||
| cf2010389a | |||
| 43522c4922 | |||
| 1cb5f24439 | |||
| b6a3f21a52 | |||
| 2ecc26b623 | |||
| 145f75fe06 | |||
| bd0578cbf9 | |||
| 40f24cc0b6 | |||
| 754efac063 | |||
| 132cc156f4 | |||
| 95ad932efb | |||
| ae30f4119f | |||
| d251ae4976 | |||
| 33324e590b | |||
| fea10ffd22 | |||
| f1e11e3f06 | |||
| c562eca8a1 | |||
| d9a690dac3 | |||
| a0eed058d1 | |||
| abc9f47a6f | |||
| b064f6fcaf | |||
| 0c7d7df2ec | |||
| dc86f35957 | |||
| 9685b0aa9b | |||
| f23cc408e3 | |||
| cea00a6c14 | |||
| f2949e1dc2 | |||
| 5f1f34fa7f | |||
| 2c041f9025 | |||
| 74b2d519b9 |
@@ -180,6 +180,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
|
|||||||
{"ShowTurnSignals", {PERSISTENT | BACKUP, BOOL, "0"}},
|
{"ShowTurnSignals", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||||
{"StandstillTimer", {PERSISTENT | BACKUP, BOOL, "0"}},
|
{"StandstillTimer", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||||
{"TrueVEgoUI", {PERSISTENT | BACKUP, BOOL, "0"}},
|
{"TrueVEgoUI", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||||
|
{"SteeringCustomButtonMapping", {PERSISTENT | BACKUP, INT, "0"}},
|
||||||
|
|
||||||
// MADS params
|
// MADS params
|
||||||
{"Mads", {PERSISTENT | BACKUP, BOOL, "1"}},
|
{"Mads", {PERSISTENT | BACKUP, BOOL, "1"}},
|
||||||
|
|||||||
+1
-1
Submodule opendbc_repo updated: 8289577096...a9e627dfb1
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import cereal.messaging as messaging
|
import cereal.messaging as messaging
|
||||||
|
from enum import Enum
|
||||||
from openpilot.common.params import Params
|
from openpilot.common.params import Params
|
||||||
from openpilot.common.swaglog import cloudlog
|
from openpilot.common.swaglog import cloudlog
|
||||||
from cereal import car
|
from cereal import car
|
||||||
@@ -8,6 +9,14 @@ from openpilot.system.micd import SAMPLE_RATE, SAMPLE_BUFFER
|
|||||||
FEEDBACK_MAX_DURATION = 10.0
|
FEEDBACK_MAX_DURATION = 10.0
|
||||||
ButtonType = car.CarState.ButtonEvent.Type
|
ButtonType = car.CarState.ButtonEvent.Type
|
||||||
|
|
||||||
|
# TODO-SP: Use common python enum when we move to raylib?
|
||||||
|
CUSTOM_MAPPING_BOOKMARK = 1 # Custom button mapping value for bookmark action
|
||||||
|
|
||||||
|
class ButtonPressType(Enum):
|
||||||
|
NONE = 'NONE'
|
||||||
|
LKAS = 'LKAS'
|
||||||
|
CUSTOM = 'CUSTOM'
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
params = Params()
|
params = Params()
|
||||||
@@ -21,29 +30,25 @@ def main():
|
|||||||
while True:
|
while True:
|
||||||
sm.update()
|
sm.update()
|
||||||
should_send_bookmark = False
|
should_send_bookmark = False
|
||||||
|
btn_pressed = get_button_event(sm, params)
|
||||||
|
|
||||||
# TODO: https://github.com/commaai/openpilot/issues/36015
|
if btn_pressed is not ButtonPressType.NONE:
|
||||||
# only allow the LKAS button to record feedback when MADS is disabled
|
if not should_record_audio:
|
||||||
if False and sm.updated['carState'] and sm['carState'].canValid and not sm['selfdriveStateSP'].mads.available:
|
if params.get_bool("RecordAudioFeedback"): # Start recording on first press if toggle set
|
||||||
for be in sm['carState'].buttonEvents:
|
should_record_audio = True
|
||||||
if be.type == ButtonType.lkas:
|
block_num = 0
|
||||||
if be.pressed:
|
waiting_for_release = False
|
||||||
if not should_record_audio:
|
early_stop_triggered = False
|
||||||
if params.get_bool("RecordAudioFeedback"): # Start recording on first press if toggle set
|
cloudlog.info(f"{btn_pressed.value} button pressed - starting 10-second audio feedback")
|
||||||
should_record_audio = True
|
else:
|
||||||
block_num = 0
|
should_send_bookmark = True # immediately send bookmark if toggle false
|
||||||
waiting_for_release = False
|
cloudlog.info(f"{btn_pressed.value} button pressed - bookmarking")
|
||||||
early_stop_triggered = False
|
elif should_record_audio and not waiting_for_release: # Wait for release of second press to stop recording early
|
||||||
cloudlog.info("LKAS button pressed - starting 10-second audio feedback")
|
waiting_for_release = True
|
||||||
else:
|
elif waiting_for_release: # Second press released
|
||||||
should_send_bookmark = True # immediately send bookmark if toggle false
|
waiting_for_release = False
|
||||||
cloudlog.info("LKAS button pressed - bookmarking")
|
early_stop_triggered = True
|
||||||
elif should_record_audio and not waiting_for_release: # Wait for release of second press to stop recording early
|
cloudlog.info(f"{btn_pressed.value} button released - ending recording early")
|
||||||
waiting_for_release = True
|
|
||||||
elif waiting_for_release: # Second press released
|
|
||||||
waiting_for_release = False
|
|
||||||
early_stop_triggered = True
|
|
||||||
cloudlog.info("LKAS button released - ending recording early")
|
|
||||||
|
|
||||||
if should_record_audio and sm.updated['rawAudioData']:
|
if should_record_audio and sm.updated['rawAudioData']:
|
||||||
raw_audio = sm['rawAudioData']
|
raw_audio = sm['rawAudioData']
|
||||||
@@ -68,5 +73,26 @@ def main():
|
|||||||
pm.send('userBookmark', msg)
|
pm.send('userBookmark', msg)
|
||||||
|
|
||||||
|
|
||||||
|
def get_button_event(sm, params):
|
||||||
|
|
||||||
|
custom_button_mapping = params.get("SteeringCustomButtonMapping")
|
||||||
|
custom_mapped = custom_button_mapping == CUSTOM_MAPPING_BOOKMARK
|
||||||
|
btn_pressed = ButtonPressType.NONE
|
||||||
|
|
||||||
|
# use custom button mapping if available
|
||||||
|
use_custom = custom_mapped and sm.updated['carState']
|
||||||
|
# only allow the LKAS button to record feedback when MADS is disabled & custom button mapping is not set
|
||||||
|
# TODO: https://github.com/commaai/openpilot/issues/36015
|
||||||
|
use_lkas = False #sm.updated['carState'] and sm['carState'].canValid and not sm['selfdriveStateSP'].mads.available
|
||||||
|
|
||||||
|
if use_custom or use_lkas:
|
||||||
|
for be in sm['carState'].buttonEvents:
|
||||||
|
if use_custom and be.type == ButtonType.altButton2:
|
||||||
|
btn_pressed = ButtonPressType.CUSTOM if be.pressed else ButtonPressType.NONE
|
||||||
|
elif use_lkas and be.type == ButtonType.lkas:
|
||||||
|
btn_pressed = ButtonPressType.LKAS if be.pressed else ButtonPressType.NONE
|
||||||
|
|
||||||
|
return btn_pressed
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -1203,6 +1203,20 @@
|
|||||||
"title": "[TIZI/TICI only] Standstill Timer",
|
"title": "[TIZI/TICI only] Standstill Timer",
|
||||||
"description": "Show a timer on the HUD when the car is at a standstill."
|
"description": "Show a timer on the HUD when the car is at a standstill."
|
||||||
},
|
},
|
||||||
|
"SteeringCustomButtonMapping": {
|
||||||
|
"title": "Steering Custom Button Mapping",
|
||||||
|
"description": "Customize the steering wheel custom/star button for openpilot control.",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"value": 0,
|
||||||
|
"label": "Off"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": 1,
|
||||||
|
"label": "Bookmark"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"SubaruStopAndGo": {
|
"SubaruStopAndGo": {
|
||||||
"title": "Subaru Stop and Go",
|
"title": "Subaru Stop and Go",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
|||||||
Reference in New Issue
Block a user