From ec72ee096db000287290042dec4b24c6461c1afe Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 15 Jul 2026 11:52:31 -0700 Subject: [PATCH] cleanup unused radar fields (#38346) * cleanup unused radar fields * bump opendbc * this is nice for debugging * bring that back too * bring these back * more revert --- opendbc_repo | 2 +- openpilot/cereal/log.capnp | 24 +++++++++---------- openpilot/selfdrive/controls/radard.py | 14 +++-------- .../test/longitudinal_maneuvers/plant.py | 2 +- .../test/process_replay/migration.py | 2 -- openpilot/tools/replay/lib/ui_helpers.py | 2 +- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/opendbc_repo b/opendbc_repo index 8c0b1367c..402335de1 160000 --- a/opendbc_repo +++ b/opendbc_repo @@ -1 +1 @@ -Subproject commit 8c0b1367c5178f919c05ae58a1dcf7439ed3eb37 +Subproject commit 402335de16dc75946ac4727b1513156411bdf3e0 diff --git a/openpilot/cereal/log.capnp b/openpilot/cereal/log.capnp index c7923bd37..722213daa 100644 --- a/openpilot/cereal/log.capnp +++ b/openpilot/cereal/log.capnp @@ -704,8 +704,7 @@ struct UsbState { } struct RadarState @0x9a185389d6fdd05f { - mdMonoTime @6 :UInt64; - carStateMonoTime @11 :UInt64; + mdMonoTime @6 :UInt64; # for debugging radarErrors @13 :Car.RadarData.Error; leadOne @3 :LeadData; @@ -715,21 +714,21 @@ struct RadarState @0x9a185389d6fdd05f { dRel @0 :Float32; yRel @1 :Float32; vRel @2 :Float32; - aRel @3 :Float32; vLead @4 :Float32; - dPath @6 :Float32; - vLat @7 :Float32; - vLeadK @8 :Float32; - aLeadK @9 :Float32; - fcw @10 :Bool; + vLeadK @8 :Float32; # kalman-filtered lead speed + aLeadK @9 :Float32; # kalman-filtered lead accel present @11 :Bool; aLeadTau @12 :Float32; modelProb @13 :Float32; - radar @14 :Bool; - radarTrackId @15 :Int32 = -1; + radar @14 :Bool; # true if lead is radar-matched (vs vision-only) + radarTrackId @15 :Int32 = -1; # for debugging deprecated :group { + aRel @3 :Float32; aLead @5 :Float32; + dPath @6 :Float32; + vLat @7 :Float32; + fcw @10 :Bool; } } @@ -742,6 +741,7 @@ struct RadarState @0x9a185389d6fdd05f { calPerc @9 :Int8; canMonoTimes @10 :List(UInt64); cumLagMs @5 :Float32; + carStateMonoTime @11 :UInt64; radarErrors @12 :List(Car.RadarData.ErrorDEPRECATED); } } @@ -1041,7 +1041,6 @@ struct ModelDataV2 { roadEdgeStds @14 :List(Float32); # predicted lead cars - leads @11 :List(LeadDataV2); leadsV3 @18 :List(LeadDataV3); meta @12 :MetaData; @@ -1051,8 +1050,9 @@ struct ModelDataV2 { action @26: Action; lateralPlannerSolutionDEPRECATED @25: Deprecated.LateralPlannerSolution; + leadsDEPRECATED @11 :List(LeadDataV2DEPRECATED); - struct LeadDataV2 { + struct LeadDataV2DEPRECATED { prob @0 :Float32; # probability that car is your lead at time t t @1 :Float32; diff --git a/openpilot/selfdrive/controls/radard.py b/openpilot/selfdrive/controls/radard.py index 1474b31cf..30824c07b 100755 --- a/openpilot/selfdrive/controls/radard.py +++ b/openpilot/selfdrive/controls/radard.py @@ -23,7 +23,6 @@ SPEED, ACCEL = 0, 1 # Kalman filter states enum # stationary qualification parameters V_EGO_STATIONARY = 4. # no stationary object flag below this speed -RADAR_TO_CENTER = 2.7 # (deprecated) RADAR is ~ 2.7m ahead from center of car RADAR_TO_CAMERA = 1.52 # RADAR is ~ 1.5m ahead from center of mesh frame @@ -59,13 +58,12 @@ class Track: self.K_K = kalman_params.K self.kf = KF1D([[v_lead], [0.0]], self.K_A, self.K_C, self.K_K) - def update(self, d_rel: float, y_rel: float, v_rel: float, v_lead: float, measured: float): + def update(self, d_rel: float, y_rel: float, v_rel: float, v_lead: float): # relative values, copy self.dRel = d_rel # LONG_DIST self.yRel = y_rel # -LAT_DIST self.vRel = v_rel # REL_SPEED self.vLead = v_lead - self.measured = measured # measured or estimate # computed velocity and accelerations if self.cnt > 0: @@ -92,7 +90,6 @@ class Track: "aLeadK": float(self.aLeadK), "aLeadTau": float(self.aLeadTau.x), "present": True, - "fcw": self.is_potential_fcw(model_prob), "modelProb": model_prob, "radar": True, "radarTrackId": self.identifier, @@ -103,9 +100,6 @@ class Track: # Radar points closer than 0.75, are almost always glitches on toyota radars return abs(self.yRel) < 1.0 and (v_ego < V_EGO_STATIONARY) and (0.75 < self.dRel < 25) - def is_potential_fcw(self, model_prob: float): - return model_prob > .9 - def __str__(self): ret = f"x: {self.dRel:4.1f} y: {self.yRel:4.1f} v: {self.vRel:4.1f} a: {self.aLeadK:4.1f}" return ret @@ -149,7 +143,6 @@ def get_RadarState_from_vision(lead_msg: capnp._DynamicStructReader, v_ego: floa "vLeadK": float(v_ego + lead_v_rel_pred), "aLeadK": float(lead_msg.a[0]), "aLeadTau": 0.3, - "fcw": False, "modelProb": float(lead_prob), "present": True, "radar": False, @@ -209,7 +202,7 @@ class RadarD: self.v_ego_hist.append(self.v_ego) self.last_v_ego_frame = sm.recv_frame['carState'] - ar_pts = {pt.trackId: [pt.dRel, pt.yRel, pt.vRel, pt.measured] for pt in rr.points} + ar_pts = {pt.trackId: [pt.dRel, pt.yRel, pt.vRel] for pt in rr.points} # *** remove missing points from meta data *** for ids in list(self.tracks.keys()): @@ -226,14 +219,13 @@ class RadarD: # create the track if it doesn't exist or it's a new track if ids not in self.tracks: self.tracks[ids] = Track(ids, v_lead, self.kalman_params) - self.tracks[ids].update(rpt[0], rpt[1], rpt[2], v_lead, rpt[3]) + self.tracks[ids].update(rpt[0], rpt[1], rpt[2], v_lead) # *** publish radarState *** self.radar_state_valid = sm.all_checks() self.radar_state = log.RadarState.new_message() self.radar_state.mdMonoTime = sm.logMonoTime['modelV2'] self.radar_state.radarErrors = rr.errors - self.radar_state.carStateMonoTime = sm.logMonoTime['carState'] if len(sm['modelV2'].velocity.x): model_v_ego = sm['modelV2'].velocity.x[0] diff --git a/openpilot/selfdrive/test/longitudinal_maneuvers/plant.py b/openpilot/selfdrive/test/longitudinal_maneuvers/plant.py index 733c1ab2f..23ccbdb85 100755 --- a/openpilot/selfdrive/test/longitudinal_maneuvers/plant.py +++ b/openpilot/selfdrive/test/longitudinal_maneuvers/plant.py @@ -89,7 +89,6 @@ class Plant: lead.dRel = float(d_rel) lead.yRel = 0.0 lead.vRel = float(v_rel) - lead.aRel = float(a_lead - self.acceleration) lead.vLead = float(v_lead) lead.vLeadK = float(v_lead) lead.aLeadK = float(a_lead) @@ -97,6 +96,7 @@ class Plant: lead.aLeadTau = float(_LEAD_ACCEL_TAU) lead.present = status lead.modelProb = float(prob_lead) + lead.radar = True if not self.only_lead2: radar.radarState.leadOne = lead radar.radarState.leadTwo = lead diff --git a/openpilot/selfdrive/test/process_replay/migration.py b/openpilot/selfdrive/test/process_replay/migration.py index 0045fa8a8..a6e466bef 100644 --- a/openpilot/selfdrive/test/process_replay/migration.py +++ b/openpilot/selfdrive/test/process_replay/migration.py @@ -175,8 +175,6 @@ def migrate_liveTracks(msgs): pt.dRel = track.dRel pt.yRel = track.yRel pt.vRel = track.vRel - pt.aRel = track.aRel - pt.measured = True pts.append(pt) new_msg.liveTracks.points = pts diff --git a/openpilot/tools/replay/lib/ui_helpers.py b/openpilot/tools/replay/lib/ui_helpers.py index b5fdd1802..6a3e8c20e 100644 --- a/openpilot/tools/replay/lib/ui_helpers.py +++ b/openpilot/tools/replay/lib/ui_helpers.py @@ -201,7 +201,7 @@ def maybe_update_radar_points(lt, lid_overlay): if lt is not None: ar_pts = {} for track in lt: - ar_pts[track.trackId] = [track.dRel, track.yRel, track.vRel, track.aRel] + ar_pts[track.trackId] = [track.dRel, track.yRel, track.vRel] for pt in ar_pts.values(): # negative here since radar is left positive px, py = to_topdown_pt(pt[0], -pt[1])