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 CANFD Radar Parser #1835

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

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

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

🚀

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.

2 participants