# Calculating gyro data from accelerometer, pitch, roll and yaw

I am currently collecting accelerometer and attitude data using smartphone sensors. Data is collected at 100Hz over 2.5 seconds. Of which there are 250 accelerometer points and 250 points representing the attitude of the device. I am looking to convert the attitude/accelerometer data to gyroscope Data. For example, 1 of the 250 segments look like;

For example,

Accelerometer

• AccX = 0.08458628
• AccY = -0.0586758144
• AccZ = 0.273877382

Attitude

• Pitch = 0.111681767
• Roll = -0.8779668
• Yaw = 1.91596484

How can I calculate the corrected gyroscope data from this data?

• Unfortunately you have asked a quite broad question, however you have supplied a tiny bit of specific data which is not helpful if someone would try to utilize them. Please take some time to search the other questions/answers, and then you can ask specific questions of your application. This will be the fastest route to getting the most use of the site. Oct 9, 2017 at 9:45
• And also Robotics SE is better suited for this particular question. Oct 9, 2017 at 9:46

## 1 Answer

Accelerometers are capable of measuring the acceleration they experience relative to free-fall. Accelerometers are used to measure the upwards acceleration that counters gravity when at rest, its a hoax that it measures the acceleration due to gravity. This acceleration is measured as 1 g (g = 9.8 m/s2) on the z-axis, when both pitch and roll angles are zero, but when the sensor is tilted either the x-axis or the y-axis experiences a component of the upward acceleration, whose magnitude depends on the tilt angle. Now, moving to gyroscope, analysing the gyroscope reading means to determine the roll, pitch and yaw axis of a device with respect to its initial position. Now, coming to your question, in your case as we have obtained the acceleration readings from the accelerometer, we can apply the below mentioned formula to obtain gyroscope readings from accelerometer readings.

(Here, $\phi$ = roll and $\theta$ = pitch)

$$\tan \phi_{xyz} = \left(\frac{G_{py}}{G_{pz}}\right)$$

$$\tan \phi_{xyz} = \left(\frac{-G_{px}}{G_{py}\sin \phi + G_{pz} \cos \phi}\right) = \frac{-G_{px}}{\sqrt{G^2_{py}+G^2_{px}}}$$

If you are curious enough to know more about these formulas and the source from which I obtained these formulas you can open the link below and have a look at the document.

Tilt Sensing Using a Three-Axis Accelerometer

Here, Pitch equation is defined always to be positive, so the range of the equation is [-90, 90] and roll equation provides [-180, 180] range. When the pitch angle is 90º, the roll axis is directly aligned with the axis of gravity, thus we cannot measure the roll angle in this case. Also, the roll equation is undefined when both Gx and Gz are equal to zero.

Hope this cleared your doubt. If any further doubts persists, feel free to write.

• This site has a very smart Javascript-based Latex implementation, see how beautiful I've made your post! :-) Feb 22, 2018 at 19:20
• Essentially, put a latex expression between two \$signs and it will be rendered as latex. If you put it between two \$\\$ 's, then it will be a whole-line formula. Feb 22, 2018 at 19:21