mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-08 22:33:46 +08:00
fix
This commit is contained in:
@@ -20,7 +20,7 @@ from openpilot.common.swaglog import cloudlog
|
||||
|
||||
from openpilot.selfdrive.car.car_helpers import get_car_interface, get_startup_event
|
||||
from openpilot.selfdrive.controls.lib.alertmanager import AlertManager, set_offroad_alert
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import VCruiseHelper, clip_curvature, get_lag_adjusted_curvature
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import VCruiseHelper, clip_curvature, get_lag_adjusted_curvature, CRUISE_LONG_PRESS
|
||||
from openpilot.selfdrive.controls.lib.events import Events, ET
|
||||
from openpilot.selfdrive.controls.lib.latcontrol import LatControl, MIN_LATERAL_CONTROL_SPEED
|
||||
from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID
|
||||
@@ -717,18 +717,20 @@ class Controls:
|
||||
cloudlog.error(f"actuators.{p} not finite {actuators.to_dict()}")
|
||||
setattr(actuators, p, 0.0)
|
||||
|
||||
# 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))
|
||||
|
||||
# toggle experimental mode once on distance button hold
|
||||
if self.CP.openpilotLongitudinalControl:
|
||||
if self.v_cruise_helper.experimental_mode_update and self.v_cruise_helper.button_timers[ButtonType.gapAdjustCruise] == 50:
|
||||
if self.v_cruise_helper.experimental_mode_update and self.v_cruise_helper.button_timers[ButtonType.gapAdjustCruise] == CRUISE_LONG_PRESS:
|
||||
self.experimental_mode = not self.experimental_mode
|
||||
self.params.put_bool_nonblocking("ExperimentalMode", 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) and \
|
||||
not self.v_cruise_helper.experimental_mode_update:
|
||||
self.personality = (self.personality - 1) % 3
|
||||
self.params.put_nonblocking('LongitudinalPersonality', str(self.personality))
|
||||
self.v_cruise_helper.experimental_mode_update = False
|
||||
|
||||
return CC, lac_log
|
||||
|
||||
def publish_logs(self, CS, start_time, CC, lac_log):
|
||||
|
||||
@@ -113,6 +113,7 @@ class VCruiseHelper:
|
||||
else:
|
||||
self.v_cruise_kph = V_CRUISE_UNSET
|
||||
self.v_cruise_cluster_kph = V_CRUISE_UNSET
|
||||
self.experimental_mode_update = False
|
||||
|
||||
def _update_v_cruise_non_pcm(self, CS, enabled, is_metric, reverse_acc):
|
||||
# handle button presses. TODO: this should be in state_control, but a decelCruise press
|
||||
@@ -242,15 +243,13 @@ class VCruiseHelper:
|
||||
self.is_metric_prev = is_metric
|
||||
|
||||
def _update_experimental_mode(self, CS):
|
||||
self.experimental_mode_update = False
|
||||
|
||||
for b in CS.buttonEvents:
|
||||
if b.type == ButtonType.gapAdjustCruise and not b.pressed:
|
||||
if self.button_timers[ButtonType.gapAdjustCruise] > CRUISE_LONG_PRESS:
|
||||
return # end long press
|
||||
break
|
||||
else:
|
||||
if self.button_timers[ButtonType.gapAdjustCruise] and self.button_timers[ButtonType.gapAdjustCruise] % CRUISE_LONG_PRESS == 0:
|
||||
if self.button_timers[ButtonType.gapAdjustCruise] and self.button_timers[ButtonType.gapAdjustCruise] == CRUISE_LONG_PRESS:
|
||||
self.experimental_mode_update = True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user