I'm currently studying IMU Sensor with 6dof(gyro and accelerometer). My goal is to get Orientation of robot, and i found out that only 6dof imu sensor wouldn't be possible to get a correct Orientation due to noise and gyroscope yaw drift(also roll and pitch).

But, I just want it to try with errors. (Working on the ROS.)

so I managed to get data from my IMU sensor data which gyroscope's R,P,Y and Acceleromter's R,P. The Problem was that i don't know how to get a quaternion for some other library(package), so i just used gyro's yaw value and accelerometer's roll and pitch value to find quaternion.

Other fusion algorithms such as EKF,Complementary Filter ask linear_acc, angular_v, and Quaternion. But I don't feel like my ways to get quaternion is the right ways to do it.

So, Am i doing something wrong? How can i mix(or use) gyroscope's roll, pitch, yaw data and acclerometer's roll,pitch,yaw(?) data to get a quaternion that fusion algorithms ask?

some information : I'm using Microstrain 3dm-cx5-15, using ros, managed to publish sensor_msgs/Imu (with not quite correct quaternion) thx for the replies, any insight will help me sorry for my bad english.


1 Answer 1


First you have to understand that Gyroscope gives angular rates around X,Y,Z axes and Accelerometer gives linear accelerations in X,Y,Z directions. Neither of them gives Roll, Pitch and Yaw values. But you can calculate Roll and Pitch values using the Accelerometer readings.

For your question, in order to calculate the quaternion you need to have a 9 DoF IMU to feed data to both prediction and update step in the Kalman filter. I suggest you to follow the Probabilistic Robotics Book to get a better idea on this.

Using a 6 DoF IMU, you can calculate Roll and Pitch using a Kalman Filter. But the gyro provides data only for the prediction step when calculating the yaw. An external magnetometer or a 9 DoF IMU can provide the absolute yaw for the update step.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.