2 years, 11 months ago.

Calculating Yaw using accelerometer and gyroscope only

II'm new to IMU sensors. I'm working on a project where I need to calculate Yaw using accelerometer or gyroscope values only.

I'm using LSM6DSL sensor which is having 6DOF.

Magnetometer is not present.

Please advise how to calculate Yaw.

pitch = 180 * atan (accelerationX/sqrt(accelerationY*accelerationY + accelerationZ*accelerationZ))/M_PI;

roll = 180 * atan (accelerationY/sqrt(accelerationX*accelerationX + accelerationZ*accelerationZ))/M_PI;

yaw = 180 * atan (accelerationZ/sqrt(accelerationX*accelerationX + accelerationZ*accelerationZ))/M_PI;

posted by ajay rajan 17 Nov 2019

1 Answer

2 years, 11 months ago.

All you can get is change in yaw, not the absolute value of it so you have to start with an assumed value, typically 0.

Assuming you aren't moving much first find the up direction by using the accelerometers to measure gravity. Then use the gyroscopes to measure rates of turn on each axis. Scale these by the correct amount based on the orientation and that will give you a yaw rate. Integrate the yaw rate over time to give you yaw.

e.g. If you are sitting with 1g on the z axis and 0g on the x and y axis then yaw rate is purely the z gyroscope. If you read that at 10 Hz and get a value of 50 deg/second then your yaw has changed by 5 degrees.

If you know that you are in a fixed orientation then this can be simplified since you already know which way is up.

Note that this is a very simplistic approach, any significant motion will mess things up. Also the gyroscopes will have a different bias on each axis which ideally you would cancel out by sitting stationary for a length of time and measuring the average values. You need to do this every now and then since the bias will drift over time.

Tracking things while under significant motion starts getting complex, far too complex for an answer here. Your best bet would be to find a kalman filter that someone else has already tuned for that sensor.

Accepted Answer

Sorry for the late reply.. Thanks a lot for the reply. Using this logic I'm able to solve my issue. Somehow I was unable to get the update regarding this post.

posted by Avdhoot Kulkarni 01 Jul 2019