|
|
|
@ -112,7 +112,7 @@ class FCWChecker(object): |
|
|
|
|
|
|
|
|
|
def update(self, mpc_solution, cur_time, v_ego, a_ego, x_lead, v_lead, a_lead, y_lead, vlat_lead, fcw_lead, blinkers): |
|
|
|
|
mpc_solution_a = list(mpc_solution[0].a_ego) |
|
|
|
|
self.last_min_a = min(mpc_solution_a[1:]) |
|
|
|
|
self.last_min_a = min(mpc_solution_a) |
|
|
|
|
self.v_lead_max = max(self.v_lead_max, v_lead) |
|
|
|
|
|
|
|
|
|
if (fcw_lead > 0.99): |
|
|
|
@ -127,7 +127,7 @@ class FCWChecker(object): |
|
|
|
|
self.counters['blinkers'] = self.counters['blinkers'] + 10.0 / (20 * 3.0) if not blinkers else 0 |
|
|
|
|
|
|
|
|
|
a_thr = interp(v_lead, _FCW_A_ACT_BP, _FCW_A_ACT_V) |
|
|
|
|
a_delta = min(mpc_solution_a[1:15]) - min(0.0, a_ego) |
|
|
|
|
a_delta = min(mpc_solution_a[:15]) - min(0.0, a_ego) |
|
|
|
|
|
|
|
|
|
fcw_allowed = all(c >= 10 for c in self.counters.values()) |
|
|
|
|
if (self.last_min_a < -3.0 or a_delta < a_thr) and fcw_allowed and self.last_fcw_time + 5.0 < cur_time: |
|
|
|
@ -164,6 +164,7 @@ class LongitudinalMpc(object): |
|
|
|
|
dat.liveLongitudinalMpc.xLead = list(self.mpc_solution[0].x_l) |
|
|
|
|
dat.liveLongitudinalMpc.vLead = list(self.mpc_solution[0].v_l) |
|
|
|
|
dat.liveLongitudinalMpc.aLead = list(self.mpc_solution[0].a_l) |
|
|
|
|
dat.liveLongitudinalMpc.cost = self.mpc_solution[0].cost |
|
|
|
|
dat.liveLongitudinalMpc.aLeadTau = self.l |
|
|
|
|
dat.liveLongitudinalMpc.qpIterations = qp_iterations |
|
|
|
|
dat.liveLongitudinalMpc.mpcId = self.mpc_id |
|
|
|
@ -235,10 +236,10 @@ class LongitudinalMpc(object): |
|
|
|
|
self.v_mpc_future = self.mpc_solution[0].v_ego[10] |
|
|
|
|
|
|
|
|
|
# Reset if NaN or goes through lead car |
|
|
|
|
dls = np.array(list(self.mpc_solution[0].x_l)[1:]) - np.array(list(self.mpc_solution[0].x_ego)[1:]) |
|
|
|
|
dls = np.array(list(self.mpc_solution[0].x_l)) - np.array(list(self.mpc_solution[0].x_ego)) |
|
|
|
|
crashing = min(dls) < -50.0 |
|
|
|
|
nans = np.any(np.isnan(list(self.mpc_solution[0].v_ego))) |
|
|
|
|
backwards = min(list(self.mpc_solution[0].v_ego)[1:]) < -0.01 |
|
|
|
|
backwards = min(list(self.mpc_solution[0].v_ego)) < -0.01 |
|
|
|
|
|
|
|
|
|
if ((backwards or crashing) and self.prev_lead_status) or nans: |
|
|
|
|
if t > self.last_cloudlog_t + 5.0: |
|
|
|
@ -336,7 +337,7 @@ class Planner(object): |
|
|
|
|
self.v_acc_future = min([self.mpc1.v_mpc_future, self.mpc2.v_mpc_future, v_cruise_setpoint]) |
|
|
|
|
|
|
|
|
|
# this runs whenever we get a packet that can change the plan |
|
|
|
|
def update(self, CS, LoC, v_cruise_kph, user_distracted): |
|
|
|
|
def update(self, CS, LaC, LoC, v_cruise_kph, user_distracted): |
|
|
|
|
cur_time = sec_since_boot() |
|
|
|
|
v_cruise_setpoint = v_cruise_kph * CV.KPH_TO_MS |
|
|
|
|
|
|
|
|
@ -459,6 +460,8 @@ class Planner(object): |
|
|
|
|
events.append(create_event('radarCommIssue', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) |
|
|
|
|
if 'fault' in self.radar_errors: |
|
|
|
|
events.append(create_event('radarFault', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) |
|
|
|
|
if LaC.mpc_solution[0].cost > 10000. or LaC.mpc_nans: # TODO: find a better way to detect when MPC did not converge |
|
|
|
|
events.append(create_event('plannerError', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) |
|
|
|
|
|
|
|
|
|
# Interpolation of trajectory |
|
|
|
|
dt = min(cur_time - self.acc_start_time, _DT_MPC + _DT) + _DT # no greater than dt mpc + dt, to prevent too high extraps |
|
|
|
|