Coordinate transformation from Cartesian to Frenet Frame
38 views (last 30 days)
Show older comments
Suvo Ganguli
on 9 Mar 2021
Answered: Cameron Stabile
on 26 Jan 2023
Can anyone tell me how to convert from Cartesian to Frenet Frame for a vehicle driving on a curved road? In other words how do I convert from (x,y) -> (s,d) where is along the curve and d is perpendicular to the curve?
Is there a Matlab code someone can share?
For example if the vehicle is 1 m off centerline and driving along the arc of a circle at speed 1 m/s, then the coordinates at every 1 sec in Cartesian and Frenet frame are given by:
x = cos(theta) ... [with the appropriate scalings for radius and speed]
y = sin(theta) ... [with the appropriate scalings for radius and speed]
s = (0, 1, 2, ...)
d = (1, 1, 1, ...)
I have been looking into Matlab codes but the solutions I got are in the form of (T, N, B) - the tangent, normal and binormal. How do I convert them to distance along the centerline and perpendicular to the centerline?
Thanks.
1 Comment
M I
on 21 May 2021
i recently found this: https://github.com/fjp/frenet/blob/master/matlab/Cart2FRT.m
Accepted Answer
Cameron Stabile
on 26 Jan 2023
Hi Suvo,
The referencePathFrenet feature from the Navigation Toolbox might be of use to you. The feature fits a piece-wise clothoid spline between a set of
or
waypoints, after which you can convert between Cartesian
and Frenet
space.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1275195/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1275200/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1275205/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1275210/image.png)
There are a number of tools at your disposal, which loosely fall into the following categories:
Projection XY point to Curve:
- closestPoint - Find closest point on reference path to global point
- closestProjections - Find orthogonal projections between path tangent vector and query point
- closestPointsToSequence - Projects sequence of points onto path
Conversion between Cartesian
and Frenet ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1275220/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1275215/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1275220/image.png)
- frenet2global - Convert Frenet states to global states
- global2frenet - Convert global states to Frenet states
Evaluating Curve at Arclength (S)
- interpolate - Interpolate reference path at provided arc lengths
- position - Return xy-position at arclength
- tangentAngle - Return tangent angle at arclength
- curvature - Return curvature at arclength
- changeInCurvature - Return change-in-curvature at arclength
There are also a number of examples that show how this can be applied to road-based planners, a good one to get you started could be Highway Trajectory Planning Using Frenet Reference Path.
Hope this helps,
Cameron
0 Comments
More Answers (0)
See Also
Categories
Find more on Motion Planning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!