Skip to content

Commit

Permalink
Nudge speed (commaai#369)
Browse files Browse the repository at this point in the history
* Add param to change the speed at which a nudge is not required.

* Update description

* Update description

* updates
  • Loading branch information
sshane committed Apr 1, 2021
1 parent d2ed714 commit 11e6381
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions common/op_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/lib/lateral_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 11e6381

Please sign in to comment.