mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-06 17:35:44 +08:00
fix(accel-controller): use current radar lead field
This commit is contained in:
@@ -46,7 +46,7 @@ def is_lead_source(source) -> bool:
|
||||
|
||||
|
||||
def has_radar_lead(radar_state) -> bool:
|
||||
return bool(radar_state.leadOne.status or radar_state.leadTwo.status)
|
||||
return bool(radar_state.leadOne.present or radar_state.leadTwo.present)
|
||||
|
||||
|
||||
def _project_ego(v_ego: float, a_ego: float, delay: float) -> tuple[float, float]:
|
||||
@@ -59,7 +59,7 @@ def _project_ego(v_ego: float, a_ego: float, delay: float) -> tuple[float, float
|
||||
|
||||
|
||||
def _lead_values(lead) -> tuple[float, float, float, float] | None:
|
||||
if not lead.status:
|
||||
if not lead.present:
|
||||
return None
|
||||
d_rel, v_lead = float(lead.dRel), float(lead.vLeadK)
|
||||
if not math.isfinite(d_rel) or d_rel < 0.0 or not math.isfinite(v_lead) or v_lead < MIN_LEAD_SPEED:
|
||||
@@ -80,7 +80,7 @@ def calculate_lead_plan(radar_state, v_ego: float, a_ego: float, delay: float, p
|
||||
return LeadPlan()
|
||||
|
||||
leads = (radar_state.leadOne, radar_state.leadTwo)
|
||||
lead_status = any(lead.status for lead in leads)
|
||||
lead_status = any(lead.present for lead in leads)
|
||||
t_follow = get_T_FOLLOW(follow_personality)
|
||||
if not math.isfinite(t_follow) or t_follow < 0.0:
|
||||
return LeadPlan(lead_status=lead_status)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ from openpilot.sunnypilot.selfdrive.controls.lib.accel_controller.lead import Le
|
||||
|
||||
|
||||
def make_lead(*, status=False, d_rel=0.0, v_lead_k=0.0, a_lead_k=0.0, a_lead_tau=1.5, radar_track_id=-1):
|
||||
return SimpleNamespace(status=status, dRel=d_rel, vLeadK=v_lead_k, aLeadK=a_lead_k, aLeadTau=a_lead_tau,
|
||||
return SimpleNamespace(present=status, dRel=d_rel, vLeadK=v_lead_k, aLeadK=a_lead_k, aLeadTau=a_lead_tau,
|
||||
radarTrackId=radar_track_id)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user