1
$\begingroup$

I am in the middle of a vehicle tracking project where I have to calculate the distance traveled by the vehicle in a given amount of time.

Data I am getting:

Speed : 30.2 km/hr   12.7 km/hr    15 km/hr    21.8 km/hr 
Time :  11:00:00     11:00:22      11:00:45    11:01:10

That is I am getting the speed of the vehicle every 20-25 seconds. So what is the best way to calculate the distance traveled by the vehicle during this whole duration? Is taking the median of two speeds the best way to calculate the average speed here?

$\endgroup$
1
  • 2
    $\begingroup$ Beware of the infamous "which average" gotcha :-) . Typically we want the average with respect to time, but one could calculate the average wrt distance. The original teaser: drive 50 miles out at 40 mph, then return at 60 mph, what's the average speed? :-) $\endgroup$ Commented Dec 4, 2013 at 12:37

4 Answers 4

1
$\begingroup$

A simple approach is to vary the speed linearly with time and integrate that to get distance. Of course in real life a lot can happen in 25 seconds so this will not give good results. The more closely spaced points the better.

Look up numerical integration and choose a scheme of your liking, like trapezoidal, simpsons rule, guassian quadrature, romberg's method, and more.

What tools to you have available for doing data processing and number crunching, and how many data points to do have? The choise depends on what you are familiar with, also.

I strongly adivse to tighten up the sample intervals, and to control the measurement error as much as possible. What is your target error in distance?

I did an example calculation, with trapezoidal rule at 11:00:45 you have traveled 212.1 meters, but with a higher order method the result is 204.1 meters (4% difference is huge).

$\endgroup$
1
$\begingroup$

You first have to get a clear definition of what the speed samples mean. Are they the instantaneous speed at the time of the sample? Are they the low pass filtered result of recent signals? If so, how recent? What kind of filter? Are they the average speed during the last interval?

The best for your purposes would be the average over the previous interval, since you can then calulate the distance traveled over that interval directly.

If the samples are instantaneous (on the scale of the sample period), then data has been lost. The best theoretical thing you can do to reconstruct the continuous function from a series of point samples is to apply a reconstruction filter. Filter out all the frequencies you know your point samples can't possibly be represeting, which are all frequenies above 1/(2x sample period). For regular samples, one realization of this is to convolve them with a sync kernel.

In practise, I'd probably not bother with the sync filter unless this data is really important and every last bit of error matters. Of course in that case one has to wonder why odometer snapshots weren't included in the data. Given normal circumstances, I'd just assume the speed varies linearly between adjacent samples and be done with it.

$\endgroup$
0
$\begingroup$

Well, this is an easy problem in kinematics. "The rule" for solving it is drawing a graphic of the (differences of) time versus the speed. You will get some points. Join these points to obtain a trapezoid histogram. So, what do you think it is the area beneath this curve? It has the dimensions of a length, so... Now, you want an average speed, that is a constant speed for the whole path. In the previous graphic, a constant speed would be a horizontal line. You can solve this problem drawing a horizontal line that creates a rectangle in your graphic, whose area is the same as that of the trapezoid.

These are just a guidelines. The analytical part follows straightforward from these hints..!

$\endgroup$
3
  • 1
    $\begingroup$ Just a comment: as @jk88 said, you can't calculate the exact distance travelled if you don't know the exact speed at each time. Nevertheless, from your data, you can get an approximation, via the trapezoid histogram I told. This approx corresponds with taking a constant acceleration between each steps, that is assuming a linearly varying speed. $\endgroup$ Commented Dec 4, 2013 at 11:14
  • $\begingroup$ Suppose I am calculating distance travelled in each time interval assuming a constant acceleration during that interval and adding all the values to get the total distance travelled, will there be a difference between this value and the approximation made using trapezoid histogram? $\endgroup$ Commented Dec 4, 2013 at 11:32
  • $\begingroup$ No, there isn't. This trapezoid approximation is exactly the graphical representation of a constant acceleration in each time interval. Just for clarity's sake, with a trapezoid histogram I mean something like that: stmary.ws/highschool/physics/home/notes/kinematics/equation/… $\endgroup$ Commented Dec 4, 2013 at 11:41
0
$\begingroup$

From this data, you don't actually know how the speed varies between steps. If you have more information about the acceleration then you could change the model from this but I would propose the following...

Assume a linear change in the speed between steps, you could take a simple graphical approach. Plot the speed (in km/s) on a vertical axis, against the total time elapsed since the beginning (in seconds) on a horizontal axis. Join up the points in your plot with consecutive straight lines. The total distance covered is given by the area under the line.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.