poor-sha
If you are using data from the PDR in Pi Toolbox by default the Distance channel is undefined.  What is the most correct way to define Distance for PDR data?

I've been using a math channel for "integral([Speed],Reset)" which works but seems to show the Lap Distance at approximately 70% of what the actual GPS distance shows (Map Position D if you generated a GPS map).  I think this might be the cause of my issues with split times and I don't know what other issues it's causing.

In the channels option dialog the only other options that appear to work are "Odometer Distance" and "Recording Event Odometer" but both of those are fairly course grained and result in the "Compare Time" channel being very jagged.

Is there a math channel I can create to define Distance based on the Latitude and Longitude data?  Is there a better way that I'm not aware of?

I would have expected this to work out of the box and I can't find any documentation saying I need to create a math channel for distance so any help is appreciated.
Quote 0 0
poor-sha
It took a bit of research but I figured out how to create a math channel that calculates distance from the Lat/Long channels.  The contents are below in case anyone else wants to try it.  It was largely adapted from this article here - https://stackoverflow.com/questions/365826/calculate-distance-between-2-gps-coordinates 

/* Calculate distance using the difference between current and last GPS coordinates. */
register @distance = 0;
register @lat1 = [Latitude];
register @lon1 = [Longitude];
register @lat2;
register @lon2;

register @pi = 0.0174532925199433; //pi / 180
register @radius = 3959 * 5280; //radius of Earth in ft

register @dLat;
register @dLon;
register @lat1Rad;
register @lat2Rad;

register @a;
register @c;

@lat2 = [Latitude];
@lon2 = [Longitude];

@dLat = (@lat2-@lat1) * @pi;
@dLon = (@lon2-@lon1) * @pi;
@lat1Rad = @lat1 * @pi;
@lat2Rad = @lat2 * @pi;

@a = sin(@dLat / 2) * sin(@dLat / 2) + sin(@dLon / 2) * sin(@dLon / 2) * cos(@lat1Rad) * cos(@lat2Rad);
@c = 2 * atan2(sqrt(@a), sqrt(1-@a));

@lat1 = @lat2;
@lon1 = @lon2;

@distance = @distance + (@radius * @c);
@distance
 
Quote 0 0
Rob_Jarvis
Hi poor-sha,

Would you be able to make some data available to us? If you have a decent speed trace then you should simply be able to integrate speed like you suggest, below is an example of one I have done previously from a GPS trace.


integral( [Speed_Vehicle m/s_Toolbox] , Ignore )

Many thanks,

Rob 

Cosworth Support
Cosworth Electronics 

Quote 0 0
poor-sha
Thanks Rob, I PM'ed you a link to some data.
Quote 0 0
Rob_Jarvis
Hi poor-sha,

So if you do the following you should be fine.

Create the following math channel, make sure you have the unit types etc in the bottom left exactly the same as I have.

Calculated Distance.jpg 

Set you default Distance channel to this maths channel.

Distance Channel.jpg 

Then create you compare time channel:

Compare Time.jpg 

You might to change your Compare Time channel properties from Autoscale to fixed limits. This is due to ever so slightly distances that don't perfectly match up each lap due to the fact we're calculating it instead. Therefore depending on how you reference your laps to each other when comparing them, sometimes it might show a big time difference right at the very end of the lap if there is distance left over on one of the laps.

The maths channels are in the zip file attached to this post if you prefer to just import them rather than create them yourself.

Many thanks,

Rob

Cosworth Support
Cosworth Electronics 

Quote 0 0
poor-sha
That worked - thanks Rob.  
Quote 0 0
Car54
Hi Rob

This apparently worked for Poor-sha....but not for me. I think I have done all the same steps and followed Poor-Sha's video that he posted but when I try to define the distance channel as you show above. I get no data in my time/distance chart. What information can I get you that will help in the analysis?

thanks

bill

Quote 0 0
poor-sha
Hi Bill.  I tried to answer you in the comment on Youtube but here is my reply below.

First make sure you go in to Tools - Options - Channels and map the Distance channel to Distance_Toolbox like I show around 9:50 in the video. Do you already have an MP4 file when you created the channel? Without that, it will show unknown for quantity and unit of speed. The channel definition is - (integral([Speed],Ignore))

If you want to use the file that Rob provided instead you need to first save the file to your PC, open it, then click extract all and select a folder.  It's save maths.pxm there.  Then in Pi toolbox, go to Tools - Pi Math - Import.  Select the .pxm file you saved and click through the wizard then you will have the new channels.

I good way to test this is to just create a new time/distance display on the worksheet and just add the "Lap Distance" channel.  You should see a line roughly moving from bottom left to top right of the chart.

For anyone else interested, I put together a video on getting started with Pi Toolbox and PDR data here - 
 
Quote 0 0
Car54
well....good grief.  I imported Robs file that already had the distance and time channel set up and sure enough the data reappeared. The syntax of my channel looks the same as yours and as his. I did however do the import before I set up the time/distance chart and before adding accelerator,brake,speed, and steering angle.  Thank you very much for your  help.

bill

Quote 1 0