move around

This commit is contained in:
Jason Wen
2025-03-23 23:26:16 -04:00
parent 9262497186
commit c5ca9eb2d5
2 changed files with 11 additions and 13 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
from cereal import log
from openpilot.common.conversions import Conversions as CV
from openpilot.common.realtime import DT_MDL
from openpilot.sunnypilot.selfdrive.controls.lib.alc import AutoLaneChangeController
from openpilot.sunnypilot.selfdrive.controls.lib.auto_lane_change import AutoLaneChangeController
LaneChangeState = log.LaneChangeState
@@ -41,7 +41,7 @@ class DesireHelper:
self.keep_pulse_timer = 0.0
self.prev_one_blinker = False
self.desire = log.Desire.none
self.lane_change_controller = AutoLaneChangeController(self)
self.alc = AutoLaneChangeController(self)
def update(self, carstate, lateral_active, lane_change_prob):
v_ego = carstate.vEgo
@@ -70,7 +70,7 @@ class DesireHelper:
blindspot_detected = ((carstate.leftBlindspot and self.lane_change_direction == LaneChangeDirection.left) or
(carstate.rightBlindspot and self.lane_change_direction == LaneChangeDirection.right))
auto_lane_change_allowed = self.lane_change_controller.update(blindspot_detected, carstate.brakePressed)
auto_lane_change_allowed = self.alc.update(blindspot_detected, carstate.brakePressed)
if not one_blinker or below_lane_change_speed:
self.lane_change_state = LaneChangeState.off
@@ -28,6 +28,11 @@ class AutoLaneChangeController:
self.prev_brake_pressed = False
self.read_param()
def reset(self):
self.lane_change_wait_timer = 0.0
self.prev_brake_pressed = False
def read_param(self):
self.lane_change_set_timer = int(self.param_s.get("AutoLaneChangeTimer", encoding="utf8"))
self.lane_change_bsm_delay = self.param_s.get_bool("AutoLaneChangeBsmDelay")
@@ -56,15 +61,8 @@ class AutoLaneChangeController:
self.prev_brake_pressed = brake_pressed
# Auto reset if parent state indicates we should
if (hasattr(self.desire_helper, 'lane_change_state') and
hasattr(self.desire_helper, 'lane_change_direction')):
if (self.desire_helper.lane_change_state == log.LaneChangeState.off and
self.desire_helper.lane_change_direction == log.LaneChangeDirection.none):
self.reset()
if (self.desire_helper.lane_change_state == log.LaneChangeState.off and
self.desire_helper.lane_change_direction == log.LaneChangeDirection.none):
self.reset()
return auto_lane_change_allowed
def reset(self):
self.lane_change_wait_timer = 0.0
self.prev_brake_pressed = False