Skip to content

Commit

Permalink
Enabled toggle for ALC in kegman.json and minSpeed (commaai#250)
Browse files Browse the repository at this point in the history
* Remove annoying brake chime, disable stock fcw and print thermal msg (commaai#248)

* ALC toggles (commaai#249)

* Add ALC toggles to kegman.json

* Fix retrieval of ALC vars from kegman.json

* Fix ALCnudgeLess logic

* Fix - remove CV import and fix 'true' to True

* Fix kegman.json ALC variable retrieval

* Re-enable LKAS button
  • Loading branch information
kegman authored Dec 18, 2019
1 parent f311255 commit 728a5aa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion selfdrive/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def update(self, enabled, CS, frame, actuators, \
apply_brake = int(clip(self.brake_last * BRAKE_MAX, 0, BRAKE_MAX - 1))
apply_steer = int(clip(-actuators.steer * STEER_MAX, -STEER_MAX, STEER_MAX))

lkas_active = enabled and not CS.steer_not_allowed # and CS.lkMode and not CS.left_blinker_on and not CS.right_blinker_on # add LKAS button to toggle steering
lkas_active = enabled and not CS.steer_not_allowed and CS.lkMode #and not CS.left_blinker_on and not CS.right_blinker_on # add LKAS button to toggle steering

# Send CAN commands.
can_sends = []
Expand Down
17 changes: 11 additions & 6 deletions selfdrive/controls/lib/pathplanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from selfdrive.controls.lib.lane_planner import LanePlanner
from selfdrive.kegman_conf import kegman_conf
from common.numpy_fast import interp
from selfdrive.config import Conversions as CV
import cereal.messaging as messaging
from cereal import log

Expand Down Expand Up @@ -75,7 +74,10 @@ def __init__(self, CP):

self.steerRateCost_prev = self.steerRateCost
self.setup_mpc()


self.alc_nudge_less = bool(kegman.conf['ALCnudgeLess'])
self.alc_min_speed = float(kegman.conf['ALCminSpeed'])

self.lane_change_state = LaneChangeState.off
self.lane_change_timer = 0.0
self.prev_one_blinker = False
Expand Down Expand Up @@ -159,10 +161,13 @@ def update(self, sm, pm, CP, VM):
elif sm['carState'].rightBlinker:
lane_change_direction = LaneChangeDirection.right

if lane_change_direction == LaneChangeDirection.left:
torque_applied = sm['carState'].steeringTorque > 0 and sm['carState'].steeringPressed
if self.alc_nudge_less:
torque_applied = True
else:
torque_applied = sm['carState'].steeringTorque < 0 and sm['carState'].steeringPressed
if lane_change_direction == LaneChangeDirection.left:
torque_applied = sm['carState'].steeringTorque > 0 and sm['carState'].steeringPressed
else:
torque_applied = sm['carState'].steeringTorque < 0 and sm['carState'].steeringPressed

lane_change_prob = self.LP.l_lane_change_prob + self.LP.r_lane_change_prob

Expand All @@ -186,7 +191,7 @@ def update(self, sm, pm, CP, VM):
self.lane_change_state = LaneChangeState.preLaneChange

# Don't allow starting lane change below 45 mph
if (v_ego < 45 * CV.MPH_TO_MS) and (self.lane_change_state == LaneChangeState.preLaneChange):
if (v_ego < self.alc_min_speed) and (self.lane_change_state == LaneChangeState.preLaneChange):
self.lane_change_state = LaneChangeState.off

if self.lane_change_state in [LaneChangeState.off, LaneChangeState.preLaneChange]:
Expand Down
9 changes: 8 additions & 1 deletion selfdrive/kegman_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def read_config(self):
self.config.update({"sR_time":"1"})
self.element_updated = True

if "ALCnudgeLess" not in self.config:
self.config.update({"ALCnudgeLess":"0"})
self.config.update({"ALCminSpeed":"20.1168"})
self.element_updated = True

if self.element_updated:
print("updated")
self.write_config(self.config)
Expand All @@ -122,7 +127,9 @@ def read_config(self):
"3barBP1":"3.0", "1barMax":"2.1", "2barMax":"2.1", "3barMax":"2.1", \
"1barHwy":"0.4", "2barHwy":"0.3", "3barHwy":"0.1", \
"steerRatio":"-1", "steerRateCost":"-1", "slowOnCurves":"0", "Kf":"-1", \
"sR_boost":"0", "sR_BP0":"0", "sR_BP1":"0", "sR_time":"1"}
"sR_boost":"0", "sR_BP0":"0", "sR_BP1":"0", "sR_time":"1", \
"ALCnudgeLess":"0", "ALCminSpeed":"20.1168"}


self.write_config(self.config)
return self.config
Expand Down

0 comments on commit 728a5aa

Please sign in to comment.