From 48303589e9e8e5b76acb4934634083fa77559b93 Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Tue, 3 Oct 2017 23:40:21 -0700 Subject: [PATCH] openpilot v0.3.7 tweaks --- opendbc | 2 +- selfdrive/controls/controlsd.py | 35 ++++++++++++++----------- selfdrive/controls/lib/alertmanager.py | 2 +- selfdrive/controls/radard.py | 3 +++ selfdrive/ui/ui.c | 3 ++- selfdrive/visiond/visiond | Bin 13285152 -> 13285152 bytes 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/opendbc b/opendbc index e25689edc18276..b8c0034c5d6ded 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit e25689edc18276f3ef728f0cdf63939240fcebda +Subproject commit b8c0034c5d6ded3d85a4f0414b3509baae35a34b diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 867062c54b4acf..80b25875d7c5c0 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -58,7 +58,7 @@ def isEnabled(state): return (isActive(state) or state == State.PRE_ENABLED) -def data_sample(CI, CC, thermal, health, cal, cal_status, cal_perc): +def data_sample(CI, CC, thermal, health, cal, cal_status, overtemp, free_space): # *** read can and compute car states *** CS = CI.update(CC) @@ -68,23 +68,25 @@ def data_sample(CI, CC, thermal, health, cal, cal_status, cal_perc): # thermal data, checked every second td = messaging.recv_sock(thermal) if td is not None: - # Check temperature + # overtemp above 95 deg overtemp = any( t > 950 for t in (td.thermal.cpu0, td.thermal.cpu1, td.thermal.cpu2, td.thermal.cpu3, td.thermal.mem, td.thermal.gpu)) - if overtemp: - events.append(create_event('overheat', [ET.NO_ENTRY, ET.SOFT_DISABLE])) - # under 15% of space free - if td.thermal.freeSpace < 0.15: - events.append(create_event('outOfSpace', [ET.NO_ENTRY])) + # under 15% of space free no enable allowed + free_space = td.thermal.freeSpace < 0.15 + + if overtemp: + events.append(create_event('overheat', [ET.NO_ENTRY, ET.SOFT_DISABLE])) + + if free_space: + events.append(create_event('outOfSpace', [ET.NO_ENTRY])) # *** read calibration status *** cal = messaging.recv_sock(cal) if cal is not None: cal_status = cal.liveCalibration.calStatus - cal_perc = cal.liveCalibration.calPerc if cal_status != Calibration.CALIBRATED: if cal_status == Calibration.UNCALIBRATED: @@ -99,7 +101,7 @@ def data_sample(CI, CC, thermal, health, cal, cal_status, cal_perc): if not controls_allowed: events.append(create_event('controlsMismatch', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) - return CS, events, cal_status, cal_perc + return CS, events, cal_status, overtemp, free_space def calc_plan(CS, events, PL, LoC): @@ -119,7 +121,7 @@ def calc_plan(CS, events, PL, LoC): return plan, plan_ts -def state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, cal_perc, AM): +def state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM): # compute conditional state transitions and execute actions on state transitions enabled = isEnabled(state) @@ -146,8 +148,7 @@ def state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, ca for e in get_events(events, [ET.SOFT_DISABLE, ET.IMMEDIATE_DISABLE]): AM.add(e, enabled) for e in get_events(events, [ET.NO_ENTRY]): - txt = str(cal_perc) + '%' if e == 'calibrationInProgress' else '' - AM.add(str(e) + "NoEntry", enabled, txt) + AM.add(str(e) + "NoEntry", enabled) else: if get_events(events, [ET.PRE_ENABLE]): state = State.PRE_ENABLED @@ -191,7 +192,7 @@ def state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, ca elif soft_disable_timer <= 0: state = State.DISABLED - + # TODO: PRE ENABLING elif state == State.PRE_ENABLED: if get_events(events, [ET.USER_DISABLE]): @@ -447,7 +448,8 @@ def controlsd_thread(gctx, rate=100): state = State.DISABLED soft_disable_timer = 0 v_cruise_kph = 255 - cal_perc = 0 + overtemp = False + free_space = False cal_status = Calibration.UNCALIBRATED rear_view_toggle = False rear_view_allowed = params.get("IsRearViewMirror") == "1" @@ -474,7 +476,8 @@ def controlsd_thread(gctx, rate=100): prof.reset() # avoid memory leak # sample data and compute car events - CS, events, cal_status, cal_perc = data_sample(CI, CC, thermal, health, cal, cal_status, cal_perc) + CS, events, cal_status, overtemp, free_space = data_sample(CI, CC, thermal, health, cal, cal_status, + overtemp, free_space) prof.checkpoint("Sample") # define plan @@ -482,7 +485,7 @@ def controlsd_thread(gctx, rate=100): prof.checkpoint("Plan") # update control state - state, soft_disable_timer, v_cruise_kph = state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, cal_perc, AM) + state, soft_disable_timer, v_cruise_kph = state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM) prof.checkpoint("State transition") # compute actuators diff --git a/selfdrive/controls/lib/alertmanager.py b/selfdrive/controls/lib/alertmanager.py index a87667322812b3..19512b579ccb43 100644 --- a/selfdrive/controls/lib/alertmanager.py +++ b/selfdrive/controls/lib/alertmanager.py @@ -249,7 +249,7 @@ class AlertManager(object): "calibrationInProgressNoEntry": Alert( "Comma Unavailable", - "Calibration in Progress: ", + "Calibration in Progress", PT.LOW, None, "chimeDouble", .4, 2., 3.), "doorOpenNoEntry": Alert( diff --git a/selfdrive/controls/radard.py b/selfdrive/controls/radard.py index d966ba59f26f60..353b7a73a58a5a 100755 --- a/selfdrive/controls/radard.py +++ b/selfdrive/controls/radard.py @@ -175,7 +175,10 @@ def radard_thread(gctx=None): # publish tracks (debugging) dat = messaging.new_message() dat.init('liveTracks', len(tracks)) + #print "NEW TRACKS" for cnt, ids in enumerate(tracks.keys()): + #print "%5s %5s %5s %5s" % \ + # (ids, round(tracks[ids].dRel, 2), round(tracks[ids].vRel, 2), round(tracks[ids].yRel, 2)) dat.liveTracks[cnt].trackId = ids dat.liveTracks[cnt].dRel = float(tracks[ids].dRel) dat.liveTracks[cnt].yRel = float(tracks[ids].yRel) diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index b17434fd6ec665..3e1d5ea12fd5db 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -333,6 +333,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, s->scene = (UIScene){ .frontview = 0, + .cal_status = CALIBRATION_CALIBRATED, .transformed_width = ui_info.transformed_width, .transformed_height = ui_info.transformed_height, .front_box_x = ui_info.front_box_x, @@ -854,7 +855,7 @@ static void ui_draw_vision(UIState *s) { } // Draw calibration progress (if needed) - if (scene->cal_status == CALIBRATION_UNCALIBRATED && scene->cal_perc > 0) { + if (scene->cal_status == CALIBRATION_UNCALIBRATED) { int rec_width = 1020; int x_pos = 470; nvgBeginPath(s->vg); diff --git a/selfdrive/visiond/visiond b/selfdrive/visiond/visiond index 3257247f7c1741d99a29dfd80895defcfbe87809..10ed8069330fadbbf7e1aabce049c284dfd6059d 100755 GIT binary patch delta 688 zcmWl|hgyvR0D$4YIFam4Mn?9?CI?4WMpoG~d(X^_=p!qeY{w>>IQHIG;R?<*_`J{a zM&sp4Q5TUwB9*92h$N~|m1L@sLUn3TlUmfK4t1$VeHze^Ml_}gO-ZF0&1peP(r86% z+R&DC+R>g4bfgoV=|We!(VYx>(34*DrVoATM}G#8$w0ykVlYF9FqABYF`N;MWE9zq zW(;E)M-Jnez(gi7xgwW%a#lhRWF!VbW~?-xo1K%ARuBpP`&%3-%a7!xmxRK3p5m#V z=INf{nV#j@p5wWm=lRa}0x$F;FZL2I^)fH_3a|7kul5?R^*XQj25)qMH+i$Sc&oR0 zy9>R;JH5-hUF1F9>tf@5-tQ70@IfE)VIOg+kNTL8`-D&Wlu!GN&$`U#eBKv)(U*ML zSA5k`U-Na}@J-+HZQt=--*dU|`+*<&kstespZb}fyTUL0(lNjCYrpYZzw>*4@JE00 XXMgcmfAe?$@K68p?^r1OC$;b&Ps!&+ delta 688 zcmWl|2U`pP0D$2uE|R^;R`$qVM`tHxl|8ff%*=>BWn~jtXOm5wEqnY5zuubwNmcpbz<+;>!ex2k+|-g_DA&_H!!te0 zvpvUiJPVaJo zcYBZbdY=ou-v?Y|e9*-%@gX1f5g+w2m-@I*_@qzyw9ojg&-uK|e8Cr8?n}PxE57P$ zj`+H7_@;09w(t0^@A