mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-08 14:54:46 +08:00
Compare commits
40 Commits
deep-rl
...
hyundai-cu
| 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"}},
|
||||
{"StandstillTimer", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"TrueVEgoUI", {PERSISTENT | BACKUP, BOOL, "0"}},
|
||||
{"SteeringCustomButtonMapping", {PERSISTENT | BACKUP, INT, "0"}},
|
||||
|
||||
// MADS params
|
||||
{"Mads", {PERSISTENT | BACKUP, BOOL, "1"}},
|
||||
|
||||
Submodule opendbc_repo updated: 8289577096...a9e627dfb1
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import cereal.messaging as messaging
|
||||
from enum import Enum
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from cereal import car
|
||||
@@ -8,6 +9,14 @@ from openpilot.system.micd import SAMPLE_RATE, SAMPLE_BUFFER
|
||||
FEEDBACK_MAX_DURATION = 10.0
|
||||
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():
|
||||
params = Params()
|
||||
@@ -21,29 +30,25 @@ def main():
|
||||
while True:
|
||||
sm.update()
|
||||
should_send_bookmark = False
|
||||
btn_pressed = get_button_event(sm, params)
|
||||
|
||||
# TODO: https://github.com/commaai/openpilot/issues/36015
|
||||
# only allow the LKAS button to record feedback when MADS is disabled
|
||||
if False and sm.updated['carState'] and sm['carState'].canValid and not sm['selfdriveStateSP'].mads.available:
|
||||
for be in sm['carState'].buttonEvents:
|
||||
if be.type == ButtonType.lkas:
|
||||
if be.pressed:
|
||||
if not should_record_audio:
|
||||
if params.get_bool("RecordAudioFeedback"): # Start recording on first press if toggle set
|
||||
should_record_audio = True
|
||||
block_num = 0
|
||||
waiting_for_release = False
|
||||
early_stop_triggered = False
|
||||
cloudlog.info("LKAS button pressed - starting 10-second audio feedback")
|
||||
else:
|
||||
should_send_bookmark = True # immediately send bookmark if toggle false
|
||||
cloudlog.info("LKAS button pressed - bookmarking")
|
||||
elif should_record_audio and not waiting_for_release: # Wait for release of second press to stop 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 btn_pressed is not ButtonPressType.NONE:
|
||||
if not should_record_audio:
|
||||
if params.get_bool("RecordAudioFeedback"): # Start recording on first press if toggle set
|
||||
should_record_audio = True
|
||||
block_num = 0
|
||||
waiting_for_release = False
|
||||
early_stop_triggered = False
|
||||
cloudlog.info(f"{btn_pressed.value} button pressed - starting 10-second audio feedback")
|
||||
else:
|
||||
should_send_bookmark = True # immediately send bookmark if toggle false
|
||||
cloudlog.info(f"{btn_pressed.value} button pressed - bookmarking")
|
||||
elif should_record_audio and not waiting_for_release: # Wait for release of second press to stop recording early
|
||||
waiting_for_release = True
|
||||
elif waiting_for_release: # Second press released
|
||||
waiting_for_release = False
|
||||
early_stop_triggered = True
|
||||
cloudlog.info(f"{btn_pressed.value} button released - ending recording early")
|
||||
|
||||
if should_record_audio and sm.updated['rawAudioData']:
|
||||
raw_audio = sm['rawAudioData']
|
||||
@@ -68,5 +73,26 @@ def main():
|
||||
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__':
|
||||
main()
|
||||
|
||||
@@ -1203,6 +1203,20 @@
|
||||
"title": "[TIZI/TICI only] Standstill Timer",
|
||||
"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": {
|
||||
"title": "Subaru Stop and Go",
|
||||
"description": ""
|
||||
|
||||
Reference in New Issue
Block a user