Ask Your Question

Phidget IMU Magnetic Heading?

asked 2020-10-23 10:07:33 -0600

nabatta gravatar image

Hello! I am new to ROS so please forgive the simplicity of this question. I am trying to get a Phidget IMU to output a magnetic heading (0-360 deg). I currently have the phidgets_imu package installed which reads linear acceleration, angular velocity, and magnetic field. I am also using imu_filter_madgwick which fuses the data to get the orientation. However, I am not sure how to calculate the magnetic heading from this. The literature on the filter says it outputs a quaternion but then the screen displays the orientation in x, y, z, w. Anyone have some experience with this? Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-10-27 15:05:40 -0600

pratman gravatar image

The Madgwick filter fuses raw magnetometer data (by subscribing to /imu/mag) to compute orientation. This orientation happens to be a quaternion instead of roll/pitch/yaw. The easiest way for you to obtain magnetic heading from this, without having to write your own node to do trigonometric calculations, would be to transform the orientation vector from quaternion to Euler angles. In the resulting Euler pose, yaw angle will be the magnetic heading of your robot. The tf2 ROS packagecan do the conversion from quaternion to Euler (Roll/Pitch/Yaw). See below for implementation examples:

edit flag offensive delete link more


Thank you!

nabatta gravatar image nabatta  ( 2020-10-30 10:44:27 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2020-10-23 10:07:33 -0600

Seen: 41 times

Last updated: Oct 27