-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Ford CANFD Radar Parser #1835
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 CANFD Radar Parser #1835
Conversation
opendbc/car/ford/interface.py
Outdated
@@ -34,6 +34,10 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime | |||
# MRR_Header_Timestamps->CAN_DET_TIME_SINCE_MEAS reports 61.3 ms | |||
ret.radarDelay = 0.06 | |||
|
|||
if not ret.radarUnavailable and DBC[candidate][Bus.radar] == RADAR.DELPHI_MRR_64: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't really understood how the 60ms was calculated, but I tried to apply a similar logic for CANFD
azimuth = msg[f"CAN_DET_AZIMUTH_{ii:02d}_{iii:02d}"] # rad [-3.1416|3.13964] | ||
distRate = msg[f"CAN_DET_RANGE_RATE_{ii:02d}_{iii:02d}"] # m/s [-128|127.984] | ||
dRel = cos(azimuth) * dist # m from front of car | ||
8000 | yRel = sin(azimuth) * dist # in car frame's y axis, right is positive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the major change between CAN and CANFD, I can't say if it's correct not not the one for CAN, but this one makes the most sense for CANFD. See the PR details for more explanation
🚀 |
This PR has had no activity for 60 days. It will be automatically closed in 7 days if there is no activity. |
|
||
# Update once we've cycled through all 4 scan modes | ||
if headerScanIndex != 3: | ||
return True, [] # MRR_Detection_* messages in CANFD are at 20Hz, services.py expects liveTracks to be at 20Hz - we'll send messages to meet the 20Hz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CANFD MRR is at 20MHz
liveTracks
is at 20Hz in services.py
- https://github.com/commaai/openpilot/blob/master/cereal/services.py#L33
Sending for 2 scans out of 4 does not mark liveTracks
as invalid, but sporadically some liveTracks
don't make it to radard
which causes radard
alerts - since it's marked as invalid as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this even needed for CAN FD? This was only for clustering since the track IDs didn't match positionally that well, and radard requires consistent tracks in time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, based on what you said, I should track how a track changes over time. I should check how its position shifts from one frame to the next, how smooth the graph of the track is. Is this right?
My understanding was that you didn't want to over load the system with multiple clustering.
I'll graph the tracks and see how they change over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the clustering here isn't very clean and should ideally go into radard. If we can avoid another platform that uses it in the meantime, that's better.
Gonna merge, then we can do final validation once we use it for OP long. For now, it'll only affect FCW. |
|
||
# average of 20 Hz radar timestep / 4 scan modes = 100 ms | ||
RADAR.DELPHI_MRR_64: 0.1 | ||
}.get(Bus.radar, 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use an if statement, dict.get never looks clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're comparing an auto enum against a set of unrelated strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll bring back the if
statements in a clean way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll collect a new route with clustering on headerScanIndex
2 and 3, not only on 3 and see how everything looks.
|
||
# Update once we've cycled through all 4 scan modes | ||
if headerScanIndex != 3: | ||
return True, [] # MRR_Detection_* messages in CANFD are at 20Hz, services.py expects liveTracks to be at 20Hz - we'll send messages to meet the 20Hz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, based on what you said, I should track how a track changes over time. I should check how its position shifts from one frame to the next, how smooth the graph of the track is. Is this right?
My understanding was that you didn't want to over load the system with multiple clustering.
I'll graph the tracks and see how they change over time.
|
||
# average of 20 Hz radar timestep / 4 scan modes = 100 ms | ||
RADAR.DELPHI_MRR_64: 0.1 | ||
}.get(Bus.radar, 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll bring back the if
statements in a clean way.
Make sure you understand what each is |
Can you provide a route? The two in the description don't have rlogs |
I'm guessing the old routes were archived. These are routes on a clean master: All 4 routes have empty GitDiff. See if they help. |
Radar enabled with the same logic as for CAN - see below for more details:
Radar Enabled - with final version of the code:
I started with using the same logic used for CAN Fords, adjusting the code for the missing signals in CANFD, and I had some artifacts like:
https://github.com/user-attachments/assets/f4537216-9a6d-43a3-b973-a7bca28b8ff9
Check the lead chevron how it bounces.
https://github.com/user-attachments/assets/dfd9ff2a-e680-4d3f-afd5-2f34bd463ee9
I'm expecting the old radar points to remain in the right and new ones to come on the left.
The road curves to the right and the radar points cross the lanes, when there is noting on the lanes.

CAN logic uses
yRel = -sin(azimuth) * dist
and I used the same for CANFD and I got the above artifacts, then I switched toyRel = sin(azimuth) * dist
and I got:AdjustedRadar-small.mp4
Note how nice old points are left on the right and new ones come from the left.
https://github.com/user-attachments/assets/d2120681-f914-4c7c-b338-2d0f11cf1e35
Note how nice the radar points match with the left edge of the road.

I will add some more comments in the code.