8000 Ford CANFD Radar Parser by blue-genie · Pull Request #1835 · commaai/opendbc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 12 commits into from
Jun 1, 2025
Merged

Ford CANFD Radar Parser #1835

merged 12 commits into from
Jun 1, 2025

Conversation

blue-genie
Copy link
Contributor
@blue-genie blue-genie commented Feb 24, 2025

Radar enabled with the same logic as for CAN - see below for more details:

e36b272d5679115f/00000308--b61d26edc1/0

Radar Enabled - with final version of the code:

e36b272d5679115f/0000033b--8d4b7c8da5/0
e36b272d5679115f/0000033c--d7640794bc/0

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.
image

CAN logic uses yRel = -sin(azimuth) * dist and I used the same for CANFD and I got the above artifacts, then I switched to yRel = 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.
image

I will add some more comments in the code.

@github-actions github-actions bot added car related to opendbc/car/ ford labels Feb 24, 2025
@@ -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:
Copy link
Contributor Author

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

8000
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
yRel = sin(azimuth) * dist # in car frame's y axis, right is positive
Copy link
Contributor Author

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

@blue-genie blue-genie marked this pull request as ready for review February 24, 2025 22:18
@coffee-cake-isaac
Copy link
Contributor

🚀

Copy link
Contributor

This PR has had no activity for 60 days. It will be automatically closed in 7 days if there is no activity.

@github-actions github-actions bot added the stale label May 12, 2025

# 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
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor
@sshane sshane Jun 2, 2025

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.

@github-actions github-actions bot removed the stale label May 15, 2025
@adeebshihadeh
Copy link
Contributor

Gonna merge, then we can do final validation once we use it for OP long. For now, it'll only affect FCW.

@adeebshihadeh adeebshihadeh merged commit 8ecf142 into commaai:master Jun 1, 2025
5 checks passed

# average of 20 Hz radar timestep / 4 scan modes = 100 ms
RADAR.DELPHI_MRR_64: 0.1
}.get(Bus.radar, 0.1)
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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.

sshane added a commit that referenced this pull request Jun 2, 2025
sshane added a commit that referenced this pull request Jun 2, 2025
Revert "Ford CANFD Radar Parser (#1835)"

This reverts commit 8ecf142.
Copy link
Contributor Author
@blue-genie blue-genie left a 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
Copy link
Contributor Author

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)
Copy link
9E81 Contributor Author

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.

@sshane
Copy link
Contributor
sshane commented Jun 2, 2025

I'll collect a new route with clustering on headerScanIndex 2 and 3, not only on 3 and see how everything looks.

Make sure you understand what each is

@sshane
Copy link
Contributor
sshane commented Jun 2, 2025

Can you provide a route? The two in the description don't have rlogs

@blue-genie
Copy link
Contributor Author
blue-genie commented Jun 2, 2025

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:
e36b272d5679115f/00000478--81ffd3e440
e36b272d5679115f/00000477--46bd01ebcd
e36b272d5679115f/00000476--442fdcaba9
e36b272d5679115f/00000369--a3e8499a85

All 4 routes have empty GitDiff. See if they help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
car related to opendbc/car/ ford
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0