Computes velocity from sampled position
You have to estimate a velocity based on a regularly sampled signal. The velocity is given by the derivative on a continuous time signal. The approximation of this value with discrete data is a long-lasting topic. @Juancho is correct with the proposal of the $2$-point difference scheme. 

As the sampling is never perfect, and $x[i]-x[i-1]$ is not symmetric. So if you do not need fully causal results, there exists more symmetric derivative schemes, such as an average of forward and backward differences:  $\frac{1}{2}(x[i]-x[i-1])+(x[i+1]-x[i]) = \frac{x[i+1]-x[i-1]}{2}$. Other schemes can be found in Numerical differentiation formulae (see here for a discussion).

If you need to compute forward derivatives for real-time purposes, a paper (in French, but formulae are readable) is Estimation par maximum de vraisemblance de la dérivée d'un signal bruité, with cares about noise issues.