Understanding the Magnetometer (Digital compass) Sensor

coultonp | 17 March, 2009 11:46

It seems a long time ago since I blogged about the operation of the accelerometer sensors and made a plea for their inclusion as a standard feature (I am of course assuming the positive outcome was because people actually listened to me rather than me being just prophetic Wink). Anyway I have already discussed in previous blogs about Streetview and other aspects of Point ‘N’ Seek utilising the magnetometer sensor (generally described as the digital compass) so here are some practical details of how it works in practice (I always feel a visualisation helps). As with the accelerometer in its raw form you have three outputs x,y,z which means that you can find directional information ,were your phone is pointing, whatever its orientation. For example the Figure below shows the outputs on the three axis for the phone held with the screen parallel to the users face (i.e. upright) and in the normal portrait orientation and when the phone is held so that the screen is parallel with the ground as you would use a normal compass. The plots start with the phone facing North then rotated through East, South and West and pausing at each alignment for around 5 seconds and you can clearly see the four compass points.

The illustrate the actual rotational change the following figure illustrates the three outputs for a continuous clockwise rotation with the phone held upright going clockwise from North.

The second graph of the figure is after applying some simple signal processing whereby we can combine these outputs along phone orientation from the accelerometer to produce an output that could easily be turned into an angle from North. Indeed the sensor API does provide a range of options one being for an angle from North as shown. 

 

The problem but we have found this appears to be slightly sluggish (as illustrated) and my feeling is that a low pass filter has been applied to give a smooth scrolling of Maps when used for navigation. However, I have other plans for the sensor so will likely create my own algorithms using the raw outputs previously illustrated. Hopefully people will find this blog as useful as the one on accelerometers but judging by the time lag from last time you might want to return to this in about 12 months Laughing.

BTW should have said the data is from a S60 application running on the Nokia 6210 Navigator


RSSComments

Magnetometer data

torsak1 | 01/09/2009, 20:58

Thank you very much for this post, this very useful.
I am currently working on an augmented reality application on a N97, and I would like to get the orientation of the phone. I was wondering if the magnetometer sensor enables to get the full orientation of the cellphone (by this I mean getting the orientation for the three axes).
How do you convert the magnetometer data to angles? My goal is to get a rotation matrix from these 3 channels (or at least the direction at which the cellphone is pointing if the whole information is not available).
Also, can you point me to some documentation about the magnetometer APIs? I did not find anything in the official documentation.

Regards,
Remi

Meaning of magnetometer outputs

torsak1 | 14/09/2009, 05:31

I am having a hard time understanding the meaning of the magnetometers outputs. I thought they were supposed to be the coordinates of the North vector expressed in local coordinates (x, y and z-axis of the cellphone) but that seems not to be the case.

For example if you measure X,Y,Z for one position of the cellphone and you rotate the cellphone 180° around z-axis, I would expect the outputs to be -X,-Y and Z. But this is not the case.

What does these outputs means if this is not the north vector in local coordinates? And also, how can you determine the orientation of the cellphone from these outputs?

Thanks for your reply.

You must login to post comments. Login
 
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved