Can Magnetic Field Sensors Replace Gyroscopes in Wearable Sensing Applications?
Kai Kunze, Gernot Bahle, Paul Lukowicz
Embedded Systems Lab
University Passau, Passau, Germany
first.lastname@uni-passau.de

Abstract
We investigate if and how magnetic sensors can be used
to replace gyroscopes in wearable activity recognition. The
work is motivated by (1) sensor configurations typicallyfound in smart phones where magnetic sensors are used
to complement GPS position with orientation and (2) thefact that gyroscopes are an important source of information
for activity recognition. We propose a method to compute
angular velocity from 3D magnetic sensor data and discuss
its fundamental limitations. We present an elaborate evaluation of the accuracy on 5 previously published data set
with a total of nearly 20 hours of data from 15 users withactivities ranging from bicycle repair, through homemaking
to gym exercise.

1. Introduction
After accelerometers, gyroscopes are the second mostpopular type of wearable motion sensors. To a degree both
sensor types provide similar information. However, there
are some significant differences. The accelerometer signal
reflects a mixture of earth gravity, change in linear motion
speed (linear acceleration) and forces related to rotationalmotions (centripetal acceleration, Coriolis acceleration). The
gyroscope, on the other hand, is insensitive to gravity
and linear acceleration, providing information about angularvelocity only. In general, accelerometers tend to be more
useful when complex motions or motion sequences need tobe recognized with a single sensor type, since their signal
contains information that the gyroscope misses entirely.
This comes at the price of ambiguity since the different
contributions to the signal can not be separated. Gyroscope
are more appropriate whenever exact, non ambiguous information related to rotational motions is relevant. Thus,
they are for example extensively used in gait analysis (limbmotion is essentially a rotation around the corresponding
joint). It has been repeatedly demonstrated that a combination of accelerometers and gyroscopes can lead to bettersystem performance than each sensor on its own [10]. In
previous work, we have also shown that a combination ofan accelerometer and gyroscope is well suited to compensate
for sensor displacement effects [7]. Displacement means asystem is trained with a sensor at a particular body location

Kurt Partridge
Palo Alto Research Center
3333 Coyote Hill Road, Palo Alto, CA 94304
kurt@parc.com

and tested with the sensor shifted (but remaining on the same
body part).
Our work is motivated by the observation that mobile
phones are often equipped with magnetic field sensors,
yet lack gyroscopes. On the other hand, smart phones are
increasing being used as activity recognition and motion
monitoring devices. As phones are more often loosely placedin a pocket or back than firmly fixed to a given body location,
displacement effects can be relevant. Thus, the question
arises, if and how a magnetic field sensor can be used tomeasure angular velocity and enhance activity recognition
and motion monitoring applications just like a gyroscope.
Note that this is relevant not just to compensate for a specificsensor choice currently made in mobile phone design. Being
able to detect absolute orientation, magnetic field sensors arevaluable for many applications. Showing that at the sametime the sensor can be used as a gyroscope replacement
would allow many wearable systems to get ”two sensors forthe price of one”, saving cost, size and energy.
Paper Contributions. Magnetic sensors are mostly used
to determine orientation with respect to magnetic ”North”.
Since angular velocity can be defined as the rate of orientation change with respect to a fixed point, in theory,
magnetic field sensors should be able to replace gyroscopes1 .
Unfortunately, in practice, issues such as inhomogeneity ofthe earth magnetic field, magnetic disturbances (e.g. due toelectrical appliances) and numerical stability issues meanthat it is not obvious if and how magnetic field sensors canbe used in place of gyroscopes. To answer this question, thispaper makes the following contributions:
1) We describe a method for deriving 3D angular velocity
information from a 3-axis magnetic field sensor.
2) We elaborate the sources of error and fundamental
limitations on the approximation of a gyroscope signal
with a magnetic field sensor.
3) We evaluate the estimation accuracy for the angularvelocity on five previously published data sets.
4) On a previously published problem we investigate
how much the accuracy differences affect activity
inference.
1. Except when the axis of rotation is parallel to the field lines, as
explained later on.

Related Work. So far, we are unaware of other work using
a 3D magnetic field sensor to estimate angular velocity for
activity recognition. Quite a number of researchers combine
gyroscopes, accelerometers and magnetic field sensors todeduce context in a variety of situations (e.g. [8], [5], [1]).
Some work specifically deals with placement-indifferent,
more robust inferences: Blanke et. al. deduce the locationof a person using a gyro in a pocket [2], and Förster et. al.
show how to use a clustering approach to gain robustness
against displacement for motion sensor based systems [4].

2. Approach
In this section we describe an approach to estimating
angular velocity using only magnetometer data.
Magnetic Sensor Signals and Rotation. A naive notion ofa magnetic field sensor’s functionality is that, like an analog
compass, it points straight north. However, what the needleof an analog compass really does, is to orient itself parallelto the tangential of the magnetic field line at the specificlocation. Similarly, the three field strength components that~ thata 3D magnetic field sensor outputs represent a vector B
is tangential to the magnetic field line at sensor location. This
vector is given in the local coordinate system of the sensor
with the vector length representing the scalar field strength(norm of the field vector at the location). Thus, if we orient
the sensor in such a way that one sensor axis (e.g. x-axis)
points in the direction of the magnetic field (is tangential~ =to the field line) then the sensor reading will be B(t)~(b, 0, 0) with b = kB(t)k being the magnetic field strength
at the location. If we orient the sensor with the (x, y) plane
being tangential to the field line than the output will be (b ∗cos(ϕ), b∗(sin(ϕ), 0). Generalizing to arbitrary orientationsof the sensor with respect to the field line we have:2 Bi (t) =~~kB(t)k· cos(ϕi ) The angle ϕi (B(t))
between the i-th axis~
and the magnetic field strength vector B(t)measured at timei (t)~where Bi (t) is
t is then given by ϕi (B(t))= arccos kBB(t)k~~
the i-th component of B(t).
Angular velocity then equals the first derivative of the angle:~~ 0 = f · (B(t~ + 1) − B(t~ − 1))
B(t)
2

(2)

Problems and Limits. An obvious concern is that magnetic
disturbances caused by electrical appliances and metallic
objects in the environment. Such disturbances are known
to cause significant problems whenever the magnetic field isused to estimate orientation (e.g. for inertial navigation orin MARG motion tracking systems). Interestingly they havea much smaller effect on the estimation of angular velocity
from magnetic sensor signals. This is because, as describedabove, the estimation does not involve absolute orientation.
Instead it relies on the orientation of the sensor with respect
to the local magnetic field lines. Thus, for the angularspeed calculation, it does not matter whether the local
magnetic field corresponds to the true earth field. However,this assumes that the direction of the local magnetic lines
remains constant between the two field measurements thatare used to compute the angular velocity. Unfortunately, thisis not always the case. First of all, many disturbances are notconstant (e.g. fields caused by electric motors). In addition,
we have to take into account the fact that magnetic fieldlines are curved. Thus, linear displacement of the sensor(with no rotational components) can lead to a change ofthe angle between the sensor and the field lines, since at
different locations the magnetic field lines point in different
directions. As long as we are dealing only with the earthmagnetic field this effect can be neglected due to extremely
small curvature of the field lines. However in the presenceof environmental fields with stronger curvatures, significant
errors can be caused by this effect.
A second source of problems stems from the fact thatrotations around an axis parallel to the field line will notlead to a change of angle between the sensor and the fieldline. Furthermore, rotations around axes that are close toparallel to the field line will lead to small angle changes
only and are likely to produce noisy estimations.

3. Signal Level Evaluation

0

B(t)k
Bi (t)0 + Bi (t)·k
~
k
B(t)k
~
ϕi (B(t))=−q2 − B (t)2~kB(t)ki0completely uniform, then the difference in timestamps canbe shortened to f1 , where f denotes the sampling frequency:(1)

Since measurements happen at discrete points in time, acontinuous differential is not available. Instead, differentials~~of B(t)and kB(t)khave to be approximated by difference
quotients. One possible definition is given by taking the
average of the differences between measurements at times(t + 1, t) and (t, t − 1), divided by the actual time thatelapsed between those measurements. If the sample rate is
2. This assumes the magnetic sensor delivers data in a standard basis
coordinate system; it is, however, possible to perform a basis transformation
if that is not the case for a given device.

DataSets. The above discussion shows that the ability toaccurately estimate angular velocity from 3D magnetic fieldsensors depends on a broad range of environmental factors
as well as on the types of motion that are being performed.
To better understand the practical implications for wearable
systems we have thus evaluated our computation method on
five previously published data sets that span different application domains and activity types. Overall, the evaluation set
contains nearly 20 hours of data from 15 users and activities
ranging from bicycle repair, car inspection, homemaking,having breakfast, video gaming, and gym exercises. All data
sets were based on XSENSE MTX inertial sensor modules
containing both a gyroscope and a magnetic field sensor.

Description
office and home setting, 3 subjects, 9 hours
food intake and desk work, 4 subjects, 3 hours
bicycle repair 4 subjects, 3 hours
opportunity project data set, 4 subjects, 5 hours
gym exercises, 2 subjects, 3 hours

Placement
head, wrist, torso, lower leg
upper arm, wrist
upper arm, wrist
upper arm, wrist, back.
upper arm, wrist, lower leg

Citation
[6]
[3]
[10]
[9]
[7]

10
8
6
4
2

Table 1. The data sets used for the signal level evaluation.

0−2

Table 2. The effectiveness of gyroscopes and magnetic
sensors in compensating sensor shift with the method [7].

−4

0

2

4

6

8
10
samples

12

14

16

18
4

x 10

Figure 1. Example traces of signal level estimation of angularvelocity using the magnetic field sensor.

100
90
80
percentage of samples

locomotion exercises
8 classes: walk, run, run uphill, bike, rowing, stairs, ski, crosstrain
ModalitySame
Trained on 1
Trained on 2
Acceleration
100 %
63%
65%
Gyro
80 %
72%
75%
Magnetic
79%
68%
71%
Gyro + Acceleration
78%
90%
Magnetic + Acceleration
72%
79%
gym arm exercises
8 classes: lat, pectorial, shoulder press, upper back, arm extension/curl, pull down, chest press
ModalitySame
Trained on 1
Trained on 2
Acceleration
97 %
24%
31%
Gyro
79 %
55%
61%
Magnetic
66%
41%
53%
Gyro + Acceleration
74%
82%
Magnetic + Acceleration
57%
69%

70
60
50
40
30
torso
wrist
leg

20

The sets include a variety of different body positions suchas upper leg, arm, wrist, torso, head, back. The sampling
rates used are either 50 or 100 Hz. An overview of the sets
is given in Table 1. For details see the cited publications.
Evaluation. For the evaluation we first band-pass filter (125 Hz) the magnetic field signal. Then, we calculate theangular velocity based on the formula given in Equation 1.
As error measure we use the mean of the absolute percentage
difference between the true gyro signal and our estimation. It
is calculated over a 1.5 second sliding window. We smooththe error to account for differences arising from temporal
jitter between the two measurements.
Results. The results are summarized in Figure 2. The vast
majority of data points have error below 20%, and there are
only few with an error of more than 40%. The mean, medianand standard deviation of the error is given by body locationof the sensor in Table 3. It can be shown that statisticallysignificant differences in the error distribution exist in three
distinct groups of locations: (1) the back, torso and head,(2) upper armand lower leg, and (3) the wrist (p-values
between 0.02 and 0.04). These differences can be explainedby the way the respective body parts are moved and theprobability of coming near metallic objects (or other sourcesof disturbance). The head, torso and back all move slowly,
and are less likely to come very close to objects and devices.
In contrast, errors can arise through the wrist’s frequent andrapid displacement through motion within curved magnetic
Placement
Head
Torso
Back
Wrist
Lower leg
Upper arm

Mean Error
17%
20.1%
23.5%
53.2%
34%
32.0%

Median Error
11%
12.5%
19.5%
44.2%
23.4%
25%

Standard Deviation
90%
110%
150%
214%
162%
173%

Table 3. Mean, median error and standard deviation fordifferent placements.

10
0

0

20

40
60
mean error

80

100

Figure 2. Cumulative distribution of errors. The x-axis gives
the percent error between true and estimated angular velocity,and the y-axis gives the percentage of measurements withthat error or less.

field lines, as described in the previous section. Errors fromsensors on the arm and the leg lie in between.
There are also variances between data sets, however they
are not statistically significant.

4. Implications on context recognition
Clearly, deviations in the range of 20%-40% are unacceptable for precise tracking. However, for activity recognition
and applications that perform more qualitative analysis (e.g.
recognizing general motion types) the accuracy requirements
are less strict. To investigate to how well a magnetic fieldsensor can replace a gyroscope in such systems, we consider
the gym exercise data set from [7]. We choose this data set
because it was originally used to demonstrate how adding
a gyroscope to an acceleration sensor can help compensate
for sensor displacements3 . This is an important application
3. The type of displacement considered was within body part shift. Thus,
for example a sensor originally placed close to the wrist may be shifted up
towards the elbow. Another common example would be a mobile phone ina trousers pocket which can be anywhere from deep down on one side tojust barely in the pocket on the other side. In general, for non negligible
shifts, a motion sensor based system that was trained on one location will
perform poorly if tested on the other (see results below). In [7] we had
shown how a adding a gyroscope to an acceleration sensor based system
can make recognition more robust against such displacements. The generalidea is based on the observations that for motions dominated by translations,the acceleration signal is actually insensitive to within body part shifts. It isonly during rotations that shifted accelerometers produce different signals.
The gyroscope signal, on the other hand, is insensitive to such shifts. In
short, we use the ratio of acceleration to rotation to determine if a motion istranslation or rotation dominated, and dynamically select either acceleration
or gyroscope features.

Modality
Gyroscope
Magnetic
Modality
Gyroscope
Magnetic

locomotion exercises
Trained on Gyro (normalized)
78%
71%
gym arm exercises
Trained only on Gyro Trained on Gyro (normalized)
79%
68%
15%
21%
Trained only on Gyro
80%
42%

Individually Trained
80%
79%
Individually Trained
79%
66%

Table 4. Classification for the gym leg and arm exercises.
that is particularly relevant to mobile phones, which are oftenloosely placed in pockets where they can shift around.
The Data Set. The data set consists of two groups of
exercises: leg related and arm related. For both groups
we had two test subjects each executing each locomotion
activity for around 10 min. and each arm exercise for 20-25
repetitions. Both locomotion and gym arm exercises have 8
distinct activities (Table 4). For the leg exercises the subjects
upper leg is equipped with 6 MTx Sensors: three mounted
on the front and two on the back. For the arm exercises,
there are four sensors placed on the forearm. We use thefeatures and classifiers described in [7].
Results. The results are summarized in Tables 2 and 4. In
Table 4 the recognition rates are compared for a gyro and amagnetic sensor based system. We differentiate three cases.
First, the system is trained on features derived the raw gyrosignals and tested with the magnetic field sensor derived
angular velocities. This leads to a significant performancedrop (from 80% to 41% for leg and 68% to 21% forarm exercises). Second we consider a system trained on
normalized gyro signals. Normalize in this context means to
map the gyro and magnetic field sensor values are mapped ina value space between -1 and 1. It can be seen that the gyro
has system nearly the same accuracy (78%). At the sametime, the magnetic sensor based recognition dramatically
improves for the leg (to 71%) and somewhat improves
for the arm. Finally it can be seen that if we train thesystem directly with the magnetic field derived values, theperformance is nearly identical (79%) to the gyro case forthe leg and close (66% vs. 79%) for the arm. This confirms
the suspicion that the method works much better for thelegs than for the arms, although when directly training on
the magnetic field the arms results are still reasonable.
Table shows the results of using the magnetic field sensor to compensate for sensor shifts. The results for Gyro
and accelerometer are taken from [7]. For the magnetic
field we have used the same algorithms, substituting the
gyroscope signal for angular velocity values computed fromthe magnetic sensor using our method. In most cases, themagnetic sensor performs about 10% to 15% worse than
the gyro. Nonetheless, when it comes to compensating forsensor shifts, it is still useful and achieves improvements of
up to over 100% (from 24% to 57%).

5. Conclusion
The results presented in this paper indicate that in manycases angular velocity information derived from magnetic
field sensors can approximate and replace gyroscope signals.

Two observations are particularly noteworthy. First, themagnetic field sensor can be used to compensate sensor
shifts using the same method that has been developed
for gyroscopes. This is particularly interesting for mobile
phone based applications where the device is loosely carriedin a pocket where it can shift around. Second, in somerecognition tasks we can feed data produced by the magnetic
sensor into a system that has been trained on gyroscope data.
This is relevant e.g. for increasing system robustness againstchanging sensor configurations and sensor failures.
While our approximation method does not require thelocal magnetic field to reliably point north, fast linear
motions in close proximity to strong magnetic disturbances
can lead to significant errors. As a consequence the method
works much better on the torso then on arms and wrists.
We are currently investigating whether combining an
accelerometer and magnetometer can improve the angularvelocity estimations. In particular, the estimated gravity
vector is subject to different errors (translation instead ofmagnetic interference), and generally points in a different
direction than magnetic north, thereby allowing estimationof angular velocity around the magnetic north vector.

References[1] A. Benbasat and J. Paradiso. An inertial measurement
framework for gesture recognition and applications. Gestureand Sign Language in Human- . . . , Jan 2002.
[2] U. Blanke and B. Schiele. Sensing location in the pocket.
Ubicomp Poser Session, page 2, Aug 2008.
[3] J. Cheng, O. Amft, and P. Lukowicz. Active capacitive
sensing: Exploring a new wearable sensing modality for
activity recognition. Pervasive Computing, Jan 2010.
[4] K. Förster, D. Roggen, and G. Tröster. Unsupervised classifier self-calibration through repeated context occurences: isthere robustness against sensor displacement to gain? 2009
International Symposium on . . . , Jan 2009.
[5] H. Junker, O. Amft, P. Lukowicz, and G. Tröster. Gesture
spotting with body-worn inertial sensors to detect user activities. Pattern Recognition, Jan 2008.
[6] K. Kunze and P. Lukowicz. Using acceleration signaturesfrom everyday activities for on-body device location. Wearable Computers, 2007 11th IEEE International Symposiumon, pages 115 – 116, Sep 2007.
[7] K. Kunze and P. Lukowicz. Dealing with sensor displacement
in motion-based onbody activity recognition systems. UbiComp ’08: Proceedings of the 10th international conference
on Ubiquitous computing, Sep 2008.
[8] J. Lester, T. Choudhury, and G. Borriello. A practical
approach to recognizing physical activities. Proceedings ofPervasive, Jan 2006.
[9] P. Lukowicz, G. Pirkl, D. Bannach, and F. Wagner. Recording
a complex, multi modal activity data set for context recogntion. Workshop on Context . . . , Jan 2010.
[10] T. Stiefmeier, G. Ogris, H. Junker, P. Lukowicz, and
G. Troster. Combining motion sensors and ultrasonic hands
tracking for continuous activity recognition in a maintenancescenario. Wearable Computers, IEEE International Symposium, 0:97–104, 2006.