openpilot v0.3.7 tweaks
old-commit-hash: 48303589e9e8e5b76acb4934634083fa77559b93
This commit is contained in:
2
opendbc
2
opendbc
Submodule opendbc updated: e25689edc1...b8c0034c5d
@@ -58,7 +58,7 @@ def isEnabled(state):
|
|||||||
return (isActive(state) or state == State.PRE_ENABLED)
|
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 ***
|
# *** read can and compute car states ***
|
||||||
CS = CI.update(CC)
|
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
|
# thermal data, checked every second
|
||||||
td = messaging.recv_sock(thermal)
|
td = messaging.recv_sock(thermal)
|
||||||
if td is not None:
|
if td is not None:
|
||||||
# Check temperature
|
# overtemp above 95 deg
|
||||||
overtemp = any(
|
overtemp = any(
|
||||||
t > 950
|
t > 950
|
||||||
for t in (td.thermal.cpu0, td.thermal.cpu1, td.thermal.cpu2,
|
for t in (td.thermal.cpu0, td.thermal.cpu1, td.thermal.cpu2,
|
||||||
td.thermal.cpu3, td.thermal.mem, td.thermal.gpu))
|
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
|
# under 15% of space free no enable allowed
|
||||||
if td.thermal.freeSpace < 0.15:
|
free_space = td.thermal.freeSpace < 0.15
|
||||||
events.append(create_event('outOfSpace', [ET.NO_ENTRY]))
|
|
||||||
|
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 ***
|
# *** read calibration status ***
|
||||||
cal = messaging.recv_sock(cal)
|
cal = messaging.recv_sock(cal)
|
||||||
if cal is not None:
|
if cal is not None:
|
||||||
cal_status = cal.liveCalibration.calStatus
|
cal_status = cal.liveCalibration.calStatus
|
||||||
cal_perc = cal.liveCalibration.calPerc
|
|
||||||
|
|
||||||
if cal_status != Calibration.CALIBRATED:
|
if cal_status != Calibration.CALIBRATED:
|
||||||
if cal_status == Calibration.UNCALIBRATED:
|
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:
|
if not controls_allowed:
|
||||||
events.append(create_event('controlsMismatch', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE]))
|
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):
|
def calc_plan(CS, events, PL, LoC):
|
||||||
@@ -119,7 +121,7 @@ def calc_plan(CS, events, PL, LoC):
|
|||||||
return plan, plan_ts
|
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
|
# compute conditional state transitions and execute actions on state transitions
|
||||||
enabled = isEnabled(state)
|
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]):
|
for e in get_events(events, [ET.SOFT_DISABLE, ET.IMMEDIATE_DISABLE]):
|
||||||
AM.add(e, enabled)
|
AM.add(e, enabled)
|
||||||
for e in get_events(events, [ET.NO_ENTRY]):
|
for e in get_events(events, [ET.NO_ENTRY]):
|
||||||
txt = str(cal_perc) + '%' if e == 'calibrationInProgress' else ''
|
AM.add(str(e) + "NoEntry", enabled)
|
||||||
AM.add(str(e) + "NoEntry", enabled, txt)
|
|
||||||
else:
|
else:
|
||||||
if get_events(events, [ET.PRE_ENABLE]):
|
if get_events(events, [ET.PRE_ENABLE]):
|
||||||
state = State.PRE_ENABLED
|
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:
|
elif soft_disable_timer <= 0:
|
||||||
state = State.DISABLED
|
state = State.DISABLED
|
||||||
|
|
||||||
# TODO: PRE ENABLING
|
# TODO: PRE ENABLING
|
||||||
elif state == State.PRE_ENABLED:
|
elif state == State.PRE_ENABLED:
|
||||||
if get_events(events, [ET.USER_DISABLE]):
|
if get_events(events, [ET.USER_DISABLE]):
|
||||||
@@ -447,7 +448,8 @@ def controlsd_thread(gctx, rate=100):
|
|||||||
state = State.DISABLED
|
state = State.DISABLED
|
||||||
soft_disable_timer = 0
|
soft_disable_timer = 0
|
||||||
v_cruise_kph = 255
|
v_cruise_kph = 255
|
||||||
cal_perc = 0
|
overtemp = False
|
||||||
|
free_space = False
|
||||||
cal_status = Calibration.UNCALIBRATED
|
cal_status = Calibration.UNCALIBRATED
|
||||||
rear_view_toggle = False
|
rear_view_toggle = False
|
||||||
rear_view_allowed = params.get("IsRearViewMirror") == "1"
|
rear_view_allowed = params.get("IsRearViewMirror") == "1"
|
||||||
@@ -474,7 +476,8 @@ def controlsd_thread(gctx, rate=100):
|
|||||||
prof.reset() # avoid memory leak
|
prof.reset() # avoid memory leak
|
||||||
|
|
||||||
# sample data and compute car events
|
# 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")
|
prof.checkpoint("Sample")
|
||||||
|
|
||||||
# define plan
|
# define plan
|
||||||
@@ -482,7 +485,7 @@ def controlsd_thread(gctx, rate=100):
|
|||||||
prof.checkpoint("Plan")
|
prof.checkpoint("Plan")
|
||||||
|
|
||||||
# update control state
|
# 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")
|
prof.checkpoint("State transition")
|
||||||
|
|
||||||
# compute actuators
|
# compute actuators
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ class AlertManager(object):
|
|||||||
|
|
||||||
"calibrationInProgressNoEntry": Alert(
|
"calibrationInProgressNoEntry": Alert(
|
||||||
"Comma Unavailable",
|
"Comma Unavailable",
|
||||||
"Calibration in Progress: ",
|
"Calibration in Progress",
|
||||||
PT.LOW, None, "chimeDouble", .4, 2., 3.),
|
PT.LOW, None, "chimeDouble", .4, 2., 3.),
|
||||||
|
|
||||||
"doorOpenNoEntry": Alert(
|
"doorOpenNoEntry": Alert(
|
||||||
|
|||||||
@@ -175,7 +175,10 @@ def radard_thread(gctx=None):
|
|||||||
# publish tracks (debugging)
|
# publish tracks (debugging)
|
||||||
dat = messaging.new_message()
|
dat = messaging.new_message()
|
||||||
dat.init('liveTracks', len(tracks))
|
dat.init('liveTracks', len(tracks))
|
||||||
|
#print "NEW TRACKS"
|
||||||
for cnt, ids in enumerate(tracks.keys()):
|
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].trackId = ids
|
||||||
dat.liveTracks[cnt].dRel = float(tracks[ids].dRel)
|
dat.liveTracks[cnt].dRel = float(tracks[ids].dRel)
|
||||||
dat.liveTracks[cnt].yRel = float(tracks[ids].yRel)
|
dat.liveTracks[cnt].yRel = float(tracks[ids].yRel)
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
|
|||||||
|
|
||||||
s->scene = (UIScene){
|
s->scene = (UIScene){
|
||||||
.frontview = 0,
|
.frontview = 0,
|
||||||
|
.cal_status = CALIBRATION_CALIBRATED,
|
||||||
.transformed_width = ui_info.transformed_width,
|
.transformed_width = ui_info.transformed_width,
|
||||||
.transformed_height = ui_info.transformed_height,
|
.transformed_height = ui_info.transformed_height,
|
||||||
.front_box_x = ui_info.front_box_x,
|
.front_box_x = ui_info.front_box_x,
|
||||||
@@ -854,7 +855,7 @@ static void ui_draw_vision(UIState *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw calibration progress (if needed)
|
// 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 rec_width = 1020;
|
||||||
int x_pos = 470;
|
int x_pos = 470;
|
||||||
nvgBeginPath(s->vg);
|
nvgBeginPath(s->vg);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:973fdfae18bb0b5c33b107d06241d22e11f6794468c8327d413874aad5945ff0
|
oid sha256:98b5f05a3820850ec41add581d6cd7d23afc68af354a7fd29556f97448e4be92
|
||||||
size 13285152
|
size 13285152
|
||||||
|
|||||||
Reference in New Issue
Block a user