# 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}$$

1. Is my approach correct or are the equations wrong

2. How can I calculate the linear velocity $$a_y(i)$$ which is orthogonal to the vehicle trajectory

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}$$
• Ah thank you! This is what I was looking for. The $2 \cdot \Delta t$ should've been just $\Delta t$. Mar 8, 2020 at 20:43
• I think there are two things you should add to your solution. 1. $a = |\vec a|$ 2. to get the direction of $a_\perp$ you could maybe use $sign(a^2 - a^2_\perp)$ (not sure about that) Mar 8, 2020 at 22:06
• @RobinW If you want $a_\perp$ as a vector you can use $\vec a_{||}=\frac{\vec a\cdot \vec v}{|\vec v|^2}\vec v$ (also called the projection of $\vec a$ onto $\vec v$) and then use $\vec a_\perp=\vec a-\vec a_{||}$. Mar 8, 2020 at 22:15