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

Ford: check expected radar configuration #1414

Merged
merged 7 commits into from
Oct 24, 2024
Merged
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
25 changes: 19 additions & 6 deletions opendbc/car/ford/radar_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
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_HEADER_ADDR = 0x174 # MRR_Header_SensorCoverage
DELPHI_MRR_RADAR_MSG_COUNT = 64

DELPHI_MRR_RADAR_RANGE_COVERAGE = {0: 42, 1: 164, 2: 45, 3: 175} # scan index to detection range (m)


def _create_delphi_esr_radar_can_parser(CP) -> CANParser:
msg_n = len(DELPHI_ESR_RADAR_MSGS)
Expand All @@ -21,7 +23,10 @@ def _create_delphi_esr_radar_can_parser(CP) -> CANParser:


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

for i in range(1, DELPHI_MRR_RADAR_MSG_COUNT + 1):
msg = f"MRR_Detection_{i:03d}"
Expand Down Expand Up @@ -63,14 +68,14 @@ def update(self, can_strings):
errors = []
if not self.rcp.can_valid:
errors.append("canError")
ret.errors = errors

if self.radar == RADAR.DELPHI_ESR:
self._update_delphi_esr()
elif self.radar == RADAR.DELPHI_MRR:
self._update_delphi_mrr()
errors.extend(self._update_delphi_mrr())

ret.points = list(self.pts.values())
ret.errors = errors
self.updated_messages.clear()
return ret

Expand Down Expand Up @@ -106,11 +111,17 @@ def _update_delphi_esr(self):
def _update_delphi_mrr(self):
headerScanIndex = int(self.rcp.vl["MRR_Header_InformationDetections"]['CAN_SCAN_INDEX']) & 0b11

errors = []
if DELPHI_MRR_RADAR_RANGE_COVERAGE[headerScanIndex] != int(self.rcp.vl["MRR_Header_SensorCoverage"]["CAN_RANGE_COVERAGE"]):
errors.append("wrongConfig")

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

# SCAN_INDEX rotates through 0..3 on each message
# treat these as separate points
# SCAN_INDEX rotates through 0..3 on each message for different measurement modes
# Indexes 0 and 2 have a max range of ~40m, 1 and 3 are ~170m (MRR_Header_SensorCoverage->CAN_RANGE_COVERAGE)
# TODO: filter out close range index 1 and 3 points, contain false positives
# TODO: can we group into 2 groups?
scanIndex = msg[f"CAN_SCAN_INDEX_2LSB_{ii:02d}"]
i = (ii - 1) * 4 + scanIndex

Expand Down Expand Up @@ -148,3 +159,5 @@ def _update_delphi_mrr(self):

else:
del self.pts[i]

return errors
Loading