How to align the lane road and vehicle trajectory?

38 vues (au cours des 30 derniers jours)
Xinyu Yang
Xinyu Yang le 23 Oct 2024 à 21:43
Commenté : Umar le 26 Oct 2024 à 1:16
Hello everyone,
I followed these 2 example to rebuild driving scenario.
Ego Localization Using Lane Detections and HD Map for Scenario Generation:
Generate High Definition Scene from Lane Detections and OpenStreetMap:
This thin blue line is the vehicle track, its reference point is the first point and the reference koordination is ENU, so it begins from [0,0]. But the road, I got the reference point from this code
"[roadData,geoReference] = roadprops("OpenStreetMap",filename);",
I changed the reference point of the road, but it cant run anymore in this step:
"egoRoadsWithUpdatedLanes = updateLaneSpec(laneDetections,egoRoadData,refLaneSpec,egoTrajectory,firstEgoWaypointLaneIdx,ReplicateUpdatedLaneWidth=true);",
Could anyone please provide me some suggestions, if I don't want to change the reference point of the vehicle, how can I align the road and the vehicle trajectory?
Best regards,
Xinyu

Réponses (1)

Umar
Umar le 24 Oct 2024 à 2:14

Hi @Xinyu Yang,

In your scenario, you have a vehicle trajectory defined in East-North-Up (ENU) coordinates, but your road data from OpenStreetMap is likely in a different coordinate system. The goal is to update the lane specifications for the ego vehicle without altering its reference point. So, what you need to do is to convert the road's geographic coordinates into ENU coordinates based on a defined origin. This will align the road data with your vehicle trajectory. Utilize functions like latlon2local to convert latitude and longitude from your road data to ENU coordinates. For more information on this function, please refer to

https://www.mathworks.com/help/driving/ref/latlon2local.html

Once both datasets are in ENU, you can proceed with updating the lane specifications as intended. Here is an updated code snippet incorporating these steps:

% Assuming you've already loaded gpsData and roadData from OSM
% Define the reference point for transformation (e.g., from gpsData)
geoReference = [gpsData.latitude(1), gpsData.longitude(1),     
gpsData.altitude(1)];
% Convert road centers from geographic to ENU coordinates
roadCentersENU = zeros(size(roadData, 1), 2);
for i = 1:size(roadData, 1)
  [xEast, yNorth, ~] = latlon2local(roadData.RoadCenters{i}(:, 1), ...
                                     roadData.RoadCenters{i}(:, 2), ...
                                     roadData.RoadCenters{i}(1, 3), ...
                                     geoReference);
  roadCentersENU(i, :) = [xEast, yNorth];
end
% Update the RoadData with ENU coordinates
roadData.EastCoordinates = {roadCentersENU(:, 1)};
roadData.NorthCoordinates = {roadCentersENU(:, 2)};
% Now you can update lane specifications without changing ego vehicle 
 reference
egoRoadsWithUpdatedLanes = updateLaneSpec(laneDetections,   
egoRoadData, refLaneSpec, ...
egoTrajectory, firstEgoWaypointLaneIdx, ...
ReplicateUpdatedLaneWidth=true);
% Continue with your scenario simulation as before

So, the loop transforms each road's center coordinates from geographic format to ENU using latlon2local. This ensures that all spatial references are consistent. With both datasets in ENU format, you can now call updateLaneSpec without changing the reference point of the ego vehicle. For more information on this function, please refer to

https://www.mathworks.com/help/driving/ref/updatelanespec.html?searchHighlight=updateLaneSpec&s_tid=srchtitle_support_results_1_updateLaneSpec

After transforming coordinates, it is crucial to validate that both the road and vehicle trajectories visually align in your simulation environment. If issues arise during execution, use debugging tools or print statements to verify intermediate values (like transformed coordinates) for troubleshooting.

This approach will allow you to maintain the integrity of your ego vehicle's reference point while ensuring that all relevant data is accurately aligned for simulation purposes.

Hope this helps.

If you have further questions, please let me know.

  8 commentaires
Xinyu Yang
Xinyu Yang le 25 Oct 2024 à 14:06
Hello Umar,
the result didnt change anymore.
I want to rebuild scenario, before I do ego location Using Lane Detections and HD Map, I have already used "Ego Vehicle Localization Using GPS and IMU Fusion for Scenario Generation" to generate the right GPS data, and now I want to use Lane Detections and HD Map to do ego location again to get accurate lane-level localization of ego trajectory.
Thanks for your suggestions, but the noise from GPS is not the key to solve this problem, it even didnt have a right direction. If I rotate the road 90°, it has the right direction, and the shape of the road is also right. But after that the problem is that they didnt begin from same point.
Best regards,
Xinyu
Umar
Umar le 26 Oct 2024 à 1:16
It is just happening on your post where I am trying to hit submit button by writing code snippet, it just pops up an error. However,please see attached feedback based on your comments. It is a technical issue which is not happening when posting comments on other OP’s posts. Don’t know why.

Connectez-vous pour commenter.

Produits


Version

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by