Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fixup-ford-radar
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Oct 24, 2024
2 parents 5ccf294 + 5aaad51 commit 6b31bbf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion opendbc/car/ford/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from opendbc.car import get_safety_config, structs
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.ford.fordcan import CanBus
from opendbc.car.ford.values import Ecu, FordFlags
from opendbc.car.ford.values import DBC, Ecu, FordFlags, RADAR
from opendbc.car.interfaces import CarInterfaceBase

TransmissionType = structs.CarParams.TransmissionType
Expand All @@ -19,6 +19,11 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime
ret.steerActuatorDelay = 0.2
ret.steerLimitTimer = 1.0

if DBC[candidate]['radar'] == RADAR.DELPHI_MRR:
# average of 33.3 Hz radar timestep / 4 scan modes = 60 ms
# MRR_Header_Timestamps->CAN_DET_TIME_SINCE_MEAS reports 61.3 ms
ret.radarDelay = 0.06

CAN = CanBus(fingerprint=fingerprint)
cfgs = [get_safety_config(structs.CarParams.SafetyModel.ford)]
if CAN.main >= 4:
Expand Down
10 changes: 6 additions & 4 deletions opendbc/car/ford/radar_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
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 Down Expand Up @@ -85,6 +87,7 @@ def update(self, can_strings):

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

Expand Down Expand Up @@ -129,8 +132,8 @@ def _update_delphi_mrr(self):
look_id = int(header['CAN_LOOK_ID'])
# print('scan_index', int(scan_index) & 0b11, scan_index)

# self.can_range_coverage[scan_index & 0b11] = int(self.rcp.vl['MRR_Header_SensorCoverage']['CAN_RANGE_COVERAGE'])
if self.can_range_coverage[headerScanIndex] != int(self.rcp.vl['MRR_Header_SensorCoverage']['CAN_RANGE_COVERAGE']):
errors = []
if DELPHI_MRR_RADAR_RANGE_COVERAGE[headerScanIndex] != int(self.rcp.vl["MRR_Header_SensorCoverage"]["CAN_RANGE_COVERAGE"]):
errors.append("wrongConfig")

print(self.can_range_coverage)
Expand All @@ -155,8 +158,7 @@ def _update_delphi_mrr(self):
# continue
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?
Expand Down

0 comments on commit 6b31bbf

Please sign in to comment.