+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20

Thread: Best way to import GPS track for point mass simulation?

Hybrid View

  1. #1

    Best way to import GPS track for point mass simulation?

    Hi all,
    Tim here from RMIT Electric Racing.

    I am working on a simple point mass simulator in MATLAB using the 'critical points' method as described in Chris Patton's thesis (no yaw dynamics yet though)

    In his work, he uses a simple test track with two corners, a straight and a slalom. GPS data is used and the track curvature is calculated using the first and second x and y derivatives, and filtfilt is used in MATLAB to smooth the resultant curvature.

    I have successfully replicated this using the GPS file released by SAE-A from the 2016 endurance/autox track, however the calculated lap time is quite sensitive to the method used to derive the curvature from the GPS log.

    For example with parameters from the RMIT-E 2016 car. (lots of power, no downforce)
    Smoothing with csaps(), p=0.1, laptime= 86.38s
    csaps, p=0.9, laptime = 87.78
    pchip, laptime = 88.24s
    Butterworth filter filtfilt 0.25hz 2nd order (as in Chris Patton's thesis) , laptime = 80.65s (!!!!)

    For reference, the best time at the 2016 event was ~76s, we got ~79.5s as our best time.

    The improvement in lap time with the Butterworth filter is coming from it rounding off the peaks of the curvature substantially, however I suspect that those peaks are an artifact of the curvature calculation to start off with.
    Here is a plot with the different methods of curvature filtering, bottom scale is distance in m

    https://i.imgur.com/j99BjLy.png

    I would appreciate any suggestions on how to best treat this data, or if there is another method I could use.

    I have attached the GPS file and the matlab script I am currently using if anyone would like to have a look.
    lapsim_.zip
    Cheers,
    Tim

  2. #2
    Senior Member
    Join Date
    Mar 2008
    Location
    Buffalo, NY USA
    Posts
    340
    Quote Originally Posted by tim_pattinson View Post
    Smoothing with csaps(), p=0.1, laptime= 86.38s
    csaps, p=0.9, laptime = 87.78
    pchip, laptime = 88.24s
    Butterworth filter filtfilt 0.25hz 2nd order (as in Chris Patton's thesis) , laptime = 80.65s (!!!!)
    For reference, the best time at the 2016 event was ~76s, we got ~79.5s as our best time.
    You may have (inadvertently?) just shown why the very top drivers are well paid(grin).

    My questions:
    What are you trying to learn or accomplish with this modeling effort?
    Do all these different filters keep the car between the cones on the original track?

  3. #3
    Nb. the output of a GPS signal is lat & long plus noise, which can be converted to relative x & y coords plus noise without adding in additional noise. In order to calculate curvature, you need the single and double derivatives of x & y wrt arc length. Differentiating noisy signals is generally Bad News Bears.

    In general, it's best to filter raw signals and then apply math to it as necessary, rather than applying math and then filtering (advice given with all relative caveats and exceptions, particularly related to statistical smooshing - i.e. Kalman filters).

  4. #4
    Senior Member
    Join Date
    Oct 2007
    Location
    Bolton, CT
    Posts
    144
    Quote Originally Posted by rory.gover View Post
    Nb. the output of a GPS signal is lat & long plus noise, which can be converted to relative x & y coords plus noise without adding in additional noise. In order to calculate curvature, you need the single and double derivatives of x & y wrt arc length. Differentiating noisy signals is generally Bad News Bears.

    In general, it's best to filter raw signals and then apply math to it as necessary, rather than applying math and then filtering (advice given with all relative caveats and exceptions, particularly related to statistical smooshing - i.e. Kalman filters).
    Agreed. If you are going with a filtering method (rather than the above curve-fit to arc methods), working with the raw signal is often preferential. Not sure what GPS noise looks like, but it's likely possible to remove. I'd at least recommend trying to remove some before the differentiation and taking a second pass at the final data only if necessary. I work in the image processing world (laser diagnostics) and most of our filtering is to reduce dark noise, Gaussian noise, etc. which can often be done relatively easily before doing heavy math on the data.
    Jim
    "Old guy #1" at UCONN Racing

  5. #5
    Senior Member
    Join Date
    Mar 2008
    Location
    Brighton, MI
    Posts
    686

    GPS filter

    see attached.Aus2016.jpg

  6. #6
    Senior Member
    Join Date
    Mar 2008
    Location
    Buffalo, NY USA
    Posts
    340
    Quote Originally Posted by BillCobb View Post
    see attached.
    Ha!! I don't have the Signal Processing Toolbox so can't test directly, but I'm sure that heavily filtering really straightens out the corners.

    Back when we were running our LTS, we used an in-house zero-phase-loss filter (very simple) to smooth out manually entered racing lines. This was early 1980s, there was no GPS or dead-reckoning data available to us. Instead, we worked from paper maps of the tracks. I think I still have the blueprints for the first Detroit GP (city street course) that we obtained from the city's civil engineer, several months before the race.

  7. #7
    Senior Member
    Join Date
    Mar 2008
    Location
    Brighton, MI
    Posts
    686

    Cones Fear Me.

    Just 2 of many options.Lap It Up_1.jpgLap It Up_2.jpg

  8. #8
    Senior Member
    Join Date
    Mar 2008
    Location
    Brighton, MI
    Posts
    686

    Tracking Curvaciousness

    But wait, curvature is just the inverse of the track radius at each section. It takes 3 points to define a circle which they would lie on, and so
    all you need to do is traipse thru the track data and figure the radii of all those circles. When you are done, flip them over and you have the
    track curvatures. Like so: ( I took some latitude with the units to set the track size to metery-like dimentia). The radii come out looking
    pretty sane, if I may say so. No heavy lifting toolboxes required !

    fid=fopen('Aus2016.gpx');

    for n=1:12Aus2016_curvature.jpg
    str = fgetl(fid); %Preamble crap
    end

    for n=1:200
    str=fgetl(fid);
    if length(str) < 25
    break
    else
    lat(n)=str2double(str(13:22));
    lon(n)=str2double(str(30:39));
    end
    end

    lat = (lat - lat(1))*100000; % The center of OZ.
    lon = (lon - lon(1))*100000;

    figure
    plot(lat,lon,'bo'),hold on,axis equal

    figure,hold on,grid on
    for n=3:length(lat)-4
    x=lat(n:n+2);
    y=lon(n:n+2);
    mx = mean(x);
    my = mean(y);
    X = x - mx;
    Y = y - my; % Get differences from means
    dx2 = mean(X.^2);
    dy2 = mean(Y.^2); % Get variances
    t = [X,Y]\(X.^2-dx2+Y.^2-dy2)/2; % Solve least mean squares problem
    a0 = t(1);
    b0 = t(2); % t is the 2 x 1 solution array [a0;b0]
    r(n) = sqrt(dx2+dy2+a0^2+b0^2); % Calculate the radius
    a = a0 + mx;
    b = b0 + my; % Locate the circle's center
    curv(n) = 1/r(n); % Get the curvature
    end
    plot(curv,'k.-')
    ylim([0 .5])
    grid on
    xlabel('Starting marker (Cone?)')
    ylabel('Curvature (1/m)')
    title('Aus215.gpx Track Data')
    Last edited by BillCobb; 01-07-2018 at 09:31 PM.

  9. #9
    Senior Member
    Join Date
    Mar 2005
    Location
    Australia
    Posts
    1,690
    IT'S AN OUTRAGE!
    ==============
    Quote Originally Posted by BillCobb View Post
    Just 2 of many options.
    Bill,

    I am very disappointed in your Northern Hemispheric imperialist attitude shown above!

    And shame on all you 'Strayan students for being so slow to protest this outrage!
    ~o0o~

    What is the old-fart going on about?

    Well, Bill has drawn the Calder Park track-map from a viewpoint somewhere around the North Pole. Or more likely from his secret underground bunker, somewhere under North Merca. Namely, from deep underground, looking UP at the track.

    Geez, what will this do to the laptimes???

    I suspect the first few cars will be very slow, given the very long tunnel they will have to dig under the bitumen. Then there is the inverted gravitational field to contend with. And perhaps even negative laptimes ... but will that be good or bad for points? On the upside, driving underground might mean no problems hitting the cones, err...???

    Aarghhh, all this standing on my head trying to figure this out is hurting my brain!
    ~o0o~

    Tim,

    Bill got it right in a later post where he questioned why you want to follow "the line" that was set by a vehicle probably a lot longer and wider than the average FSAE car. And travelling much slower.

    Methinks that all you really need is the positions of the cones. The track-map (right-way-up, of course!), together with some of the abundant video footage available, should allow you to reasonably accurately determine those cone positions.

    Then on to the whole business of writing a HALF-DECENT VD-simulator. "Point-mass" is oh-so last century...

    Z

  10. #10
    Senior Member
    Join Date
    Mar 2008
    Location
    Brighton, MI
    Posts
    686

    InFarted Track Map

    Z: It was the only way I could get you to bite on the total concept at hand from an unblemished, unMatlabed and unOptimumed podium. No need for gpxread, just a couple of moving median filters. Who cares what the track is. Can they address the real problem(s) using Excel ? Or in your case Visual Basic.

    I have a few other cone deliniated tracks that have been a challenge. Just what do the children say about this one ?track1.JPG

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts