Calculate local linear accelerations from trajectory I'm trying to simulate linear accelerations and angular velocity of a vehicle which drives on a flat surface. For this, I want to use a trajectory consisting of position ($x_i, y_i$) and orientation $\theta_i$, where i relates to a point in time ($t(i) = i \cdot \Delta t$)


Both accelerometer and gyroscope are part of a strap-down IMU (blue dashed line). I'm calculating the angular velocity simply using the discrete derivative of $\theta_i$.
$\omega(i) = \frac{\theta_{i+1} - \theta_i}{\Delta t}$
For the acceleration component in heading direction, I simply use the change in velocity along the trajectory.
$P(i) = [x_i, y_i]^T$
$v(i) \approx \frac{| P(i+1) - P(i) |}{\Delta t}$
$a_x(i) \approx \frac{v(i+1) - v(i)}{\Delta t}$
I have two questions about this:


*

*Is my approach correct or are the equations wrong

*How can I calculate the linear velocity $a_y(i)$ which is orthogonal
to the vehicle trajectory
 A: Your equations seem alright, but why are you dividing by 2 in your definition of acceleration?
To your second question: I think you want to calculate both linear (tangential) acceleration and radial (orthogonal) acceleration. Linear acceleration causes the speed to increase/decrease, while radial acceleration only changes the direction of the velocity without changing the length. (I'm repeating the definition to avoid confusion). You can calculate the velocity vector which has both magnitude and direction:
$$\vec v_i=\frac{\vec p_{i+1}-\vec p_i}{\Delta t}$$
and the acceleration vector:
$$\vec a_i=\frac{\vec v_{i+1}-\vec v_i}{\Delta t}$$
The linear acceleration is parallel to the velocity vector, while the radial acceleration is orthogonal to the velocity vector. You can use the dot product to determine the parallel component:
$$a_{||}=\frac{\vec a\cdot\vec v}{|\vec v|}$$
The radial acceleration is orthogonal so can be determined using the Pythagorean theorem:
$$a_\perp^2+a_{||}^2=a^2\\a_\perp=\sqrt{a^2-a_{||}^2}$$
edit: your equation for linear acceleration is still correct, but this way you get both the linear and radial acceleration quite easily.
