From 11e6381645bcc3efdf728052cc0037775d64bcb9 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 1 Apr 2021 10:09:36 -0500 Subject: [PATCH] Nudge speed (#369) * Add param to change the speed at which a nudge is not required. * Update description * Update description * updates --- README.md | 3 +-- common/op_params.py | 6 ++---- selfdrive/controls/lib/lateral_planner.py | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f65e6996c5dcb3..ff3eb67e18dfed 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,7 @@ Here are the main parameters you can change with this fork: - [`enable_long_derivative`](#pi---pid-controller-for-long-and-lat): This enables derivative-based integral wind-down to help overshooting within the PID loop. Useful for Toyotas with pedals or cars with bad long tuning - [`use_lqr`](#pi---pid-controller-for-long-and-lat): Enable this to use LQR for lateral control with any car. It uses the RAV4 tuning, but has proven to work well for many cars - **General fork params**: - - `alca_nudge_required`: Whether to wait for applied torque to the wheel (nudge) before making lane changes - - `alca_min_speed`: The minimum speed allowed for an automatic lane change in mph + - `alca_no_nudge_speed`: Above this speed (mph), lane changes initiate IMMEDIATELY after turning on the blinker. Behavior is stock under this speed (waits for torque) - `upload_on_hotspot`: Controls whether your EON will upload driving data on your phone's hotspot - [`update_behavior`](#Automatic-updates): `off` will never update, `alert` shows an alert on-screen. `auto` will reboot the device when an update is seen - `disengage_on_gas`: Whether you want openpilot to disengage on gas input or not diff --git a/common/op_params.py b/common/op_params.py index 0cbba54d9ff4cc..f8096a299ff864 100644 --- a/common/op_params.py +++ b/common/op_params.py @@ -104,9 +104,7 @@ def __init__(self): 'This is multiplied by any profile that\'s active. Set to 1. to disable', live=True), 'min_TR': Param(0.9, NUMBER, 'The minimum allowed following distance in seconds. Default is 0.9 seconds\n' 'The range is limited from 0.85 to 2.7', live=True), - 'alca_nudge_required': Param(True, bool, 'Whether to wait for applied torque to the wheel (nudge) before making lane changes. ' - 'If False, lane change will occur IMMEDIATELY after signaling'), - 'alca_min_speed': Param(25.0, NUMBER, 'The minimum speed allowed for an automatic lane change (in MPH)'), + 'alca_no_nudge_speed': Param(90., NUMBER, 'Above this speed (mph), lane changes initiate IMMEDIATELY. Behavior is stock under'), 'steer_ratio': Param(None, NONE_OR_NUMBER, '(Can be: None, or a float) If you enter None, openpilot will use the learned sR.\n' 'If you use a float/int, openpilot will use that steer ratio instead', live=True), # 'lane_speed_alerts': Param('silent', str, 'Can be: (\'off\', \'silent\', \'audible\')\n' @@ -136,7 +134,7 @@ def __init__(self): 'rav4TSS2_use_indi': Param(False, bool, 'Enable this to use INDI for lat with your TSS2 RAV4', static=True), 'standstill_hack': Param(False, bool, 'Some cars support stop and go, you just need to enable this', static=True)} - self._to_delete = ['steer_rate_fix', 'uniqueID'] # a list of unused params you want to delete from users' params file + self._to_delete = ['alca_min_speed', 'alca_nudge_required'] # a list of unused params you want to delete from users' params file self._to_reset = [] # a list of params you want reset to their default values self._run_init() # restores, reads, and updates params diff --git a/selfdrive/controls/lib/lateral_planner.py b/selfdrive/controls/lib/lateral_planner.py index f39925c8a00b05..05f68a5b8281d5 100644 --- a/selfdrive/controls/lib/lateral_planner.py +++ b/selfdrive/controls/lib/lateral_planner.py @@ -105,7 +105,7 @@ def update(self, sm, CP, VM): # Lane change logic one_blinker = sm['carState'].leftBlinker != sm['carState'].rightBlinker - below_lane_change_speed = v_ego < self.op_params.get('alca_min_speed') * CV.MPH_TO_MS + below_lane_change_speed = False if sm['carState'].leftBlinker: self.lane_change_direction = LaneChangeDirection.left @@ -119,7 +119,7 @@ def update(self, sm, CP, VM): torque_applied = sm['carState'].steeringPressed and \ ((sm['carState'].steeringTorque > 0 and self.lane_change_direction == LaneChangeDirection.left) or (sm['carState'].steeringTorque < 0 and self.lane_change_direction == LaneChangeDirection.right)) - if not self.op_params.get('alca_nudge_required'): + if v_ego >= self.op_params.get('alca_no_nudge_speed') * CV.MPH_TO_MS: torque_applied = True blindspot_detected = ((sm['carState'].leftBlindspot and self.lane_change_direction == LaneChangeDirection.left) or