mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-23 20:52:06 +08:00
Auto Lane Change: Add option to disable lane change
This commit is contained in:
@@ -167,7 +167,6 @@ class Controls:
|
||||
self.nn_alert_shown = False
|
||||
self.enable_nnff = self.params.get_bool("NNFF")
|
||||
|
||||
self.lane_change_set_timer = int(self.params.get("AutoLaneChangeTimer", encoding="utf8"))
|
||||
self.reverse_acc_change = False
|
||||
self.dynamic_experimental_control = False
|
||||
|
||||
@@ -935,7 +934,6 @@ class Controls:
|
||||
if self.CP.notCar:
|
||||
self.joystick_mode = self.params.get_bool("JoystickDebugMode")
|
||||
|
||||
self.lane_change_set_timer = int(self.params.get("AutoLaneChangeTimer", encoding="utf8"))
|
||||
self.reverse_acc_change = self.params.get_bool("ReverseAccChange")
|
||||
self.dynamic_experimental_control = self.params.get_bool("DynamicExperimentalControl")
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ DESIRES = {
|
||||
}
|
||||
|
||||
AUTO_LANE_CHANGE_TIMER = {
|
||||
-1: 0.0,
|
||||
0: 0.0,
|
||||
1: 0.1,
|
||||
2: 0.5,
|
||||
@@ -84,7 +85,7 @@ class DesireHelper:
|
||||
if self.model_use_lateral_planner:
|
||||
self.road_edge = get_road_edge(carstate, model_data, self.edge_toggle)
|
||||
|
||||
if not carstate.madsEnabled or self.lane_change_timer > LANE_CHANGE_TIME_MAX:
|
||||
if not carstate.madsEnabled or self.lane_change_timer > LANE_CHANGE_TIME_MAX or self.lane_change_set_timer == -1:
|
||||
self.lane_change_state = LaneChangeState.off
|
||||
self.lane_change_direction = LaneChangeDirection.none
|
||||
self.prev_lane_change = False
|
||||
|
||||
@@ -64,7 +64,7 @@ void LaneChangeSettings::updateToggles() {
|
||||
}
|
||||
|
||||
auto auto_lane_change_bsm_delay_toggle = toggles["AutoLaneChangeBsmDelay"];
|
||||
auto auto_lane_change_timer_param = QString::fromStdString(params.get("AutoLaneChangeTimer"));
|
||||
auto auto_lane_change_timer_param = std::atoi(params.get("AutoLaneChangeTimer").c_str());
|
||||
|
||||
auto cp_bytes = params.get("CarParamsPersistent");
|
||||
if (!cp_bytes.empty()) {
|
||||
@@ -75,7 +75,7 @@ void LaneChangeSettings::updateToggles() {
|
||||
if (!CP.getEnableBsm()) {
|
||||
params.remove("AutoLaneChangeBsmDelay");
|
||||
}
|
||||
auto_lane_change_bsm_delay_toggle->setEnabled(CP.getEnableBsm() && auto_lane_change_timer_param != "0");
|
||||
auto_lane_change_bsm_delay_toggle->setEnabled(CP.getEnableBsm() && (auto_lane_change_timer_param > 0));
|
||||
|
||||
auto_lane_change_bsm_delay_toggle->refresh();
|
||||
} else {
|
||||
@@ -86,10 +86,10 @@ void LaneChangeSettings::updateToggles() {
|
||||
// Auto Lane Change Timer (ALCT)
|
||||
AutoLaneChangeTimer::AutoLaneChangeTimer() : SPOptionControl (
|
||||
"AutoLaneChangeTimer",
|
||||
tr("Auto Lane Change Timer"),
|
||||
tr("Set a timer to delay the auto lane change operation when the blinker is used. No nudge on the steering wheel is required to auto lane change if a timer is set.\nPlease use caution when using this feature. Only use the blinker when traffic and road conditions permit."),
|
||||
tr("Auto Lane Change"),
|
||||
tr("Set a timer to delay the auto lane change operation when the blinker is used. No nudge on the steering wheel is required to auto lane change if a timer is set. Default is Nudge.\nPlease use caution when using this feature. Only use the blinker when traffic and road conditions permit."),
|
||||
"../assets/offroad/icon_blank.png",
|
||||
{0, 5}) {
|
||||
{-1, 5}) {
|
||||
|
||||
refresh();
|
||||
}
|
||||
@@ -97,7 +97,9 @@ AutoLaneChangeTimer::AutoLaneChangeTimer() : SPOptionControl (
|
||||
void AutoLaneChangeTimer::refresh() {
|
||||
QString option = QString::fromStdString(params.get("AutoLaneChangeTimer"));
|
||||
QString second = tr("s");
|
||||
if (option == "0") {
|
||||
if (option == "-1") {
|
||||
setLabel(tr("Off"));
|
||||
} else if (option == "0") {
|
||||
setLabel(tr("Nudge"));
|
||||
} else if (option == "1") {
|
||||
setLabel(tr("Nudgeless"));
|
||||
|
||||
Reference in New Issue
Block a user