Skip to content

Commit

Permalink
Ford: trigger radar update on header message (#1410)
Browse files Browse the repository at this point in the history
* check header message

* ""
  • Loading branch information
sshane authored Oct 24, 2024
1 parent 8738eb5 commit ad9afe6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions opendbc/car/ford/radar_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DELPHI_ESR_RADAR_MSGS = list(range(0x500, 0x540))

DELPHI_MRR_RADAR_START_ADDR = 0x120
DELPHI_MRR_RADAR_HEADER_ADDR = 0x170 # MRR_Header_InformationDetections
DELPHI_MRR_RADAR_MSG_COUNT = 64


Expand All @@ -20,7 +21,7 @@ def _create_delphi_esr_radar_can_parser(CP) -> CANParser:


def _create_delphi_mrr_radar_can_parser(CP) -> CANParser:
messages = []
messages = [("MRR_Header_InformationDetections", 33)]

for i in range(1, DELPHI_MRR_RADAR_MSG_COUNT + 1):
msg = f"MRR_Detection_{i:03d}"
Expand All @@ -44,7 +45,7 @@ def __init__(self, CP):
self.valid_cnt = {key: 0 for key in DELPHI_ESR_RADAR_MSGS}
elif self.radar == RADAR.DELPHI_MRR:
self.rcp = _create_delphi_mrr_radar_can_parser(CP)
self.trigger_msg = DELPHI_MRR_RADAR_START_ADDR + DELPHI_MRR_RADAR_MSG_COUNT - 1
self.trigger_msg = DELPHI_MRR_RADAR_HEADER_ADDR
else:
raise ValueError(f"Unsupported radar: {self.radar}")

Expand Down Expand Up @@ -103,6 +104,8 @@ def _update_delphi_esr(self):
del self.pts[ii]

def _update_delphi_mrr(self):
headerScanIndex = int(self.rcp.vl["MRR_Header_InformationDetections"]['CAN_SCAN_INDEX']) & 0b11

for ii in range(1, DELPHI_MRR_RADAR_MSG_COUNT + 1):
msg = self.rcp.vl[f"MRR_Detection_{ii:03d}"]

Expand All @@ -111,6 +114,10 @@ def _update_delphi_mrr(self):
scanIndex = msg[f"CAN_SCAN_INDEX_2LSB_{ii:02d}"]
i = (ii - 1) * 4 + scanIndex

# Throw out old measurements. Very unlikely to happen, but is proper behavior
if scanIndex != headerScanIndex:
continue

if i not in self.pts:
self.pts[i] = structs.RadarData.RadarPoint()
self.pts[i].trackId = self.track_id
Expand Down

0 comments on commit ad9afe6

Please sign in to comment.