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

Frenet to Cartesian Coordinates #8

Closed
YashRunwal opened this issue Aug 24, 2020 · 2 comments
Closed

Frenet to Cartesian Coordinates #8

YashRunwal opened this issue Aug 24, 2020 · 2 comments

Comments

@YashRunwal
Copy link

YashRunwal commented Aug 24, 2020

Hello,

I have some doubts in the FRT2Cart function in MATLAB.

    nNextRefPoint = 0;

    while ((i_fS > i_faRefRunLength(nNextRefPoint+1)) && (nNextRefPoint < length(i_faRefRunLength)))

        nNextRefPoint = nNextRefPoint + 1;
    end

    nPrevRefPoint = nNextRefPoint-1;

Can you please explain me what these variables mean? And what exactly is happening here?

@fjp
Copy link
Owner

fjp commented Aug 31, 2020

Hi @YashRunwal and sorry for the late reply. I agree the variable names can seem strange but these follow some MISRA C style guide. For example nNexRefPoint means that it is a variable of type int and i_faRefRunLength denotes a function input (hence i_ ... and fa refers to a float array:

n: int
f: float
fa: array of floats (or float array)
strName: string
...

nNextRefPoint and nPrevRefPoint specify two consecutive indices of the reference path. nNextRefPoint starts at zero and is increased until the current value of the running length i_fS is reached, which is checked with the first condition of the while loop: (i_fS > i_faRefRunLength(nNextRefPoint+1)). The second condition makes sure that the index nNextRefPoint doesn't exceed the length or last index of the array i_faRefRunLength, which stores the running length values of the reference path. Hope this helps?

@fjp
Copy link
Owner

fjp commented Nov 18, 2021

To give another interpretation in case you or someone else needs it: In this function we try to locate the given input running length i_fS (in frenet coordinates) on the reference path, which consists of sampled points and has itself a running length (obtained by i_faRefRunLength(nNextRefPoint+1)). To do this we use the two points nPrevRefPoint and nNextRefPoint to locate an interval on the reference path into which the input running length i_fS falls. Given this interval we can compute the heading of the vehicle and use i_fD to compute the desired Cartesian output coordiantes o_fX and o_fY.

@fjp fjp closed this as completed Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants