Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant code #450

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions selfdrive/controls/radard.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,26 @@ def radard_thread(gctx=None):
PP.update(v_ego, md)

# run kalman filter only if prob is high enough
if PP.lead_prob > 0.7:
high_lead_prob = PP.lead_prob > 0.7
if high_lead_prob:
reading = speedSensorV.read(PP.lead_dist, covar=np.matrix(PP.lead_var))
ekfv.update_scalar(reading)
ekfv.predict(tsv)

# When changing lanes the distance to the lead car can suddenly change,
# which makes the Kalman filter output large relative acceleration
if mocked and abs(PP.lead_dist - ekfv.state[XV]) > 2.0:
ekfv.state[XV] = PP.lead_dist
ekfv.covar = (np.diag([PP.lead_var, ekfv.var_init]))
ekfv.state[SPEEDV] = 0.

ar_pts[VISION_POINT] = (float(ekfv.state[XV]), np.polyval(PP.d_poly, float(ekfv.state[XV])),
float(ekfv.state[SPEEDV]), False)
else:

# When changing lanes the distance to the lead car can suddenly change,
# which makes the Kalman filter output large relative acceleration
sudden_lead_change = abs(PP.lead_dist - ekfv.state[XV]) > 2.0
if not high_lead_prob or (mocked and sudden_lead_change):
ekfv.state[XV] = PP.lead_dist
ekfv.covar = (np.diag([PP.lead_var, ekfv.var_init]))
ekfv.covar = np.array([[PP.lead_var, 0.],
[0., ekfv.var_init]])
ekfv.state[SPEEDV] = 0.

if VISION_POINT in ar_pts:
del ar_pts[VISION_POINT]
if high_lead_prob:
ar_pts[VISION_POINT] = (float(ekfv.state[XV]), np.polyval(PP.d_poly, float(ekfv.state[XV])),
float(ekfv.state[SPEEDV]), False)
elif VISION_POINT in ar_pts:
del ar_pts[VISION_POINT]

# *** compute the likely path_y ***
if (active and not steer_override) or mocked:
Expand Down