Skip to content

Commit

Permalink
Merge pull request #6 from arne182/dynamic-follow
Browse files Browse the repository at this point in the history
Dynamic follow
  • Loading branch information
sshane authored Mar 9, 2019
2 parents f9296dc + 15b9336 commit 898fc9d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
2 changes: 2 additions & 0 deletions selfdrive/car/car_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from common.fingerprints import eliminate_incompatible_cars, all_known_cars
from selfdrive.swaglog import cloudlog
import selfdrive.messaging as messaging
import selfdrive.crash as crash

def load_interfaces(x):
ret = {}
Expand Down Expand Up @@ -82,6 +83,7 @@ def fingerprint(logcan, timeout):
time.sleep(0.01)

cloudlog.warning("fingerprinted %s", candidate_cars[0])
crash.capture_warning("fingerprinted %s" % candidate_cars[0])
return (candidate_cars[0], finger)


Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/gm/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, CP, canbus):
self.prev_left_blinker_on = False
self.right_blinker_on = False
self.prev_right_blinker_on = False
self.follow_level = 4
self.follow_level = 3
self.prev_lka_button = 0
self.lka_button = 0
self.lkMode = True
Expand Down
10 changes: 3 additions & 7 deletions selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(self, CP):
self.visionMode = 0
self.trLabels = ["0.9","1.8","2.7","dyn"]
self.alcaMode = 0
self.trMode = 3
self.trMode = 1
#if (CP.carFingerprint == CAR.MODELS):
# ALCA PARAMS
# max REAL delta angle for correction vs actuator
Expand Down Expand Up @@ -276,7 +276,7 @@ def update_ui_buttons(self,id,btn_status):

elif (id == 4) and (btn_status == 0) and self.cstm_btns.btns[id].btn_name=="tr":
if self.cstm_btns.btns[id].btn_label2 == self.trLabels[self.trMode]:
self.trMode = (self.trMode + 1 ) % 4
self.trMode = (self.trMode + 1 ) % 3
else:
self.trMode = 0
self.cstm_btns.btns[id].btn_label2 = self.trLabels[self.trMode]
Expand Down Expand Up @@ -421,8 +421,6 @@ def update(self, cp, cp_cam):
self.hud_lead = cp.vl["ACC_HUD"]['HUD_LEAD']
if self.cruise_setting == 3:
if cp.vl["SCM_BUTTONS"]["CRUISE_SETTING"] == 0:
if self.trMode == 3:
self.trMode = 1
self.trMode = (self.trMode + 1 ) % 3
self.cstm_btns.btns[4].btn_label2 = self.trLabels[self.trMode]
self.prev_cruise_setting = self.cruise_setting
Expand All @@ -432,11 +430,9 @@ def update(self, cp, cp_cam):
if self.read_distance_lines == 1:
self.UE.custom_alert_message(2,"Following distance set to 0.9s",200,3)
if self.read_distance_lines == 2:
self.UE.custom_alert_message(2,"Following distance set to 1.8s",200,3)
self.UE.custom_alert_message(2,"Dynamic following distance",200,3)
if self.read_distance_lines == 3:
self.UE.custom_alert_message(2,"Following distance set to 2.7s",200,3)
if self.read_distance_lines == 4:
self.UE.custom_alert_message(2,"Dynamic following distance",200,3)
self.read_distance_lines_prev = self.read_distance_lines

# carstate standalone tester
Expand Down
8 changes: 3 additions & 5 deletions selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(self, CP):
# ALCA PARAMS
# max REAL delta angle for correction vs actuator
self.CL_MAX_ANGLE_DELTA_BP = [10., 15., 32., 44.]#[10., 44.]
self.CL_MAX_ANGLE_DELTA = [2.0, 1.75, 0.96, 0.4]
self.CL_MAX_ANGLE_DELTA = [2.0, 1.65, 0.96, 0.4]
# adjustment factor for merging steer angle to actuator; should be over 4; the higher the smoother
self.CL_ADJUST_FACTOR_BP = [10., 44.]
self.CL_ADJUST_FACTOR = [16. , 8.]
Expand Down Expand Up @@ -367,7 +367,7 @@ def update(self, cp, cp_cam):
if self.trfix:
self.read_distance_lines = cp.vl["PCM_CRUISE_SM"]['DISTANCE_LINES']
else:
self.read_distance_lines = 4
self.read_distance_lines = 2
if self.distance_toggle <> self.distance_toggle_prev:
if self.read_distance_lines == self.distance_toggle:
self.distance_toggle_prev = self.distance_toggle
Expand All @@ -378,11 +378,9 @@ def update(self, cp, cp_cam):
if self.read_distance_lines == 1:
self.UE.custom_alert_message(2,"Following distance set to 0.9s",200,3)
if self.read_distance_lines == 2:
self.UE.custom_alert_message(2,"Following distance set to 1.8s",200,3)
self.UE.custom_alert_message(2,"Dynamic following distance",200,3)
if self.read_distance_lines == 3:
self.UE.custom_alert_message(2,"Following distance set to 2.7s",200,3)
if self.read_distance_lines == 4:
self.UE.custom_alert_message(2,"Dynamic following distance",200,3)
self.read_distance_lines_prev = self.read_distance_lines

if bool(cp.vl["JOEL_ID"]['ACC_SLOW']) <> self.acc_slow_on_prev:
Expand Down
21 changes: 7 additions & 14 deletions selfdrive/controls/lib/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,6 @@ def update(self, CS, lead, v_cruise_setpoint):
self.libmpc.init(MPC_COST_LONG.TTC, 1.0, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = CS.readdistancelines
elif CS.readdistancelines == 2:
if CS.readdistancelines == self.lastTR:
TR=1.8 # 20m at 40km/hr
else:
TR=1.8
self.libmpc.init(MPC_COST_LONG.TTC, 0.1, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = CS.readdistancelines
elif CS.readdistancelines == 3:
if CS.readdistancelines == self.lastTR:
TR = 2.7
else:
TR = 2.7 # 30m at 40km/hr
self.libmpc.init(MPC_COST_LONG.TTC, 0.05, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = CS.readdistancelines
elif CS.readdistancelines == 4:
if len(self.speed_list) > 400 and len(self.speed_list) != 0:
self.speed_list.pop(0)
self.speed_list.append(CS.vEgo * 2.236936)
Expand All @@ -314,6 +300,13 @@ def update(self, CS, lead, v_cruise_setpoint):
if abs(self.generate_cost(generatedTR)-self.last_cost) > .2:
self.libmpc.init(MPC_COST_LONG.TTC, self.generate_cost(generatedTR), MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.last_cost = self.generate_cost(generatedTR)
elif CS.readdistancelines == 3:
if CS.readdistancelines == self.lastTR:
TR = 2.7
else:
TR = 2.7 # 30m at 40km/hr
self.libmpc.init(MPC_COST_LONG.TTC, 0.05, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK)
self.lastTR = CS.readdistancelines
else:
TR=1.8 # if readdistancelines = 0
#print TR
Expand Down
8 changes: 7 additions & 1 deletion selfdrive/crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ def install():
else:
from raven import Client
from raven.transport.http import HTTPTransport
client = Client('https://1994756b5e6f41cf939a4c65de45f4f2:cefebaf3a8aa40d182609785f7189bd7@app.getsentry.com/77924',
client = Client('https://137e8e621f114f858f4c392c52e18c6d:8aba82f49af040c8aac45e95a8484970@sentry.io/1404547',
install_sys_hook=False, transport=HTTPTransport, release=version, tags={'dirty': dirty})

def capture_exception(*args, **kwargs):
client.captureException(*args, **kwargs)
cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))

def capture_warning(warning_string):
client.captureMessage(warning_string, level='warning')

def capture_info(info_string):
client.captureMessage(info_string, level='info')

def bind_user(**kwargs):
client.user_context(kwargs)

Expand Down

0 comments on commit 898fc9d

Please sign in to comment.