Orientation from magnetometer data

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!

Moderator: phalanx

Post Reply
radirobi97
Posts: 2
Joined: Mon Oct 01, 2018 5:13 am

Orientation from magnetometer data

Post by radirobi97 » Mon Oct 01, 2018 5:22 am

Dear Experts!

I saw lot of topics with the same title but answers are different.
I have a magnetometer in my phone which give me the components of magnetic field in direction of X, Y, Z.

Which of the following angles can be determined using datas of magnetometer? Roll, pitch, yaw? And how?

Thank you, Robert

jremington
Support Volunteer
Posts: 2327
Joined: Fri Jun 15, 2007 9:41 pm
Location: Eugene, Or

Re: Orientation from magnetometer data

Post by jremington » Tue Oct 02, 2018 10:02 am

yaw_angle=atan2(magy,magx); //if magnetometer is held level, with Z straight up or down. angle in radians to magnetic North.

It is essential to calibrate the magnetometer, as described here: https://thecavepearlproject.org/2015/05 ... r-arduino/

radirobi97
Posts: 2
Joined: Mon Oct 01, 2018 5:13 am

Re: Orientation from magnetometer data

Post by radirobi97 » Tue Oct 02, 2018 10:58 am

jremington wrote:
Tue Oct 02, 2018 10:02 am
yaw_angle=atan2(magy,magx); //if magnetometer is held level, with Z straight up or down. angle in radians to magnetic North.

It is essential to calibrate the magnetometer, as described here: https://thecavepearlproject.org/2015/05 ... r-arduino/
Dear Jremington!

Thank you for your reply. Estimation of roll and yaw angle is impossible just from the magnetometer?

jremington
Support Volunteer
Posts: 2327
Joined: Fri Jun 15, 2007 9:41 pm
Location: Eugene, Or

Re: Orientation from magnetometer data

Post by jremington » Tue Oct 02, 2018 4:00 pm

The magnetometer makes three measurements, so you can get two 3D orientation angles, related to the local magnetic field direction (which points into the ground in the Northern hemisphere). Yaw can be one of the angles. What you call the other is up to you.

Using the same method, you can get standard pitch and roll angles from an accelerometer, as described here: https://www.dfrobot.com/wiki/index.php/ ... lt_Sensing

Post Reply