IMPROVED MOTION TYPE IDENTIFICATION METHOD USING MOBILE DEVICE SENSORS

This paper presents an application of built-in sensors of a mobile device – a more robust version of authors’ own motion type detection method introduced in previous work. Use of accelerometer and magnetometer for recording acceleration in the World’s coordinate system is explained. The original results and identification criteria are briefly described. New tests and their results are presented. An improved version of the motion type identification method is introduced.


Introduction
Accelerometers are very popular in motion recording and analysis. For example in [1] a method for quantifying gait events is presented. The method is able to detect four fundamental walking events (heel strike, toe strike, heel-off, toe-off). In [3] an application of body worn sensors for clinical gait assessment is shown. Accelerometers, magnetometers and gyroscopes are also found in inertial motion capture systems [4,5,6]. These solutions require custom devices equipped with appropriate sensors and frequently are expensive.
Mobile devices are rapidly gaining in popularity [11]. According to IDC, in the first quarter of 2013 more smartphones were shipped than feature phones [13]. Most smart devices are equipped with a number of built in sensors such as accelerometers, magnetometers, gyroscopes, GPS modules, barometers, thermometers and ambient light sensors. These create possibilities for implementing interesting solutions, especially considering the fact that these devices are powerful mobile computers and are fairly inexpensive (scale-effect). Such an application is presented in [2] where the feasibility of using smartphones for detecting fall portents is studied. This paper presents another application of mobile device sensorsa more robust version of the authors' own motion type detection method introduced in [8]. It is also important to note that the goal of this paper is not recording accurate speed or acceleration value. The goal is to develop a method that produces correct results despite inaccuracies in the data recorded by mobile devices.

Measuring acceleration with mobile devices
Almost all mobile devices are equipped with multiple sensors and allow for measuring the acceleration to which the device is subjected. The coordinate system used by practically all mobile devices is illustrated in figure 1a [10,14,15]. As one can see in this coordinate system the z-axis is perpendicular to and directed away from the screen, the x-axis is parallel to the top/bottom edge and directed left, and the y-axis is parallel to the device's sides and directed towards the top. Considering that during normal use the device may change its orientation constantly this coordinate system is not suitable for reliable measurements.
Using the World's coordinate system depicted in figure 1b is more convenient. In this system the direction of the Z-axis is determined using accelerometer readings (gravity measurement) and is always directed upwards. The direction of the Y-axis is determined using the magnetometer. This axis is always directed to the north. The X-axis is a cross product of the previous two axes and points approximately to the east [7].  (1) where: Rrotation matrix, r aBrotation matrix coefficients, (2) where: a d -acceleration vector in the device's coordinates and where: a w -acceleration vector in the World's coordinates, the conversion between the two coordinate systems is straightforward and is given by the following equation [7]: (4) All popular mobile platforms offer appropriate APIs for easy computation of the rotation matrix R and basic linear algebra [9,16].
In the reminder of this paper only measurements along the Zaxis in the World's coordinates are relevant. It will be simply denoted "the Z-axis".

Mobile application used for measurements
The authors' own mobile application (running on Android operating system) was used for recording acceleration and GPS data (figure 2). The application allows for acceleration and speed measurement. It can record acceleration values in both: the device's and the World's coordinate systems. The sampling rate may custom or chosen from the set predefined in Android (5,15,50,200 Hz). The application is also able to remove offset in the recorded values (some accelerometers embedded in mobile devices register significant non-zero values even if the device remains motionless). The Android operating system offers three types of acceleration measurements: total, gravity, and so-called linear [17]. Gravity measurement is used internally for coordinate system conversion. Total (including gravity) and linear (with gravity removed using high-pass filter) accelerations may be recorded. The application uses standard Android APIs for data acquisition and conversion. Most importantly the getRotationMatrix() [16] is used for computing the rotation matrix R. For determining the speed of motion (from the GPS receiver) the getSpeed() method from the Location class is used [12]. The speed is updated in one second intervals. The most current speed reading is saved with each acceleration value.

Initial results
In [8] the authors propose a set of criteria for motion type recognition (table 2). It is based on measurements recorded using the mobile application described briefly in the previous section. The data is gathered using Nexus 4 phone running unmodified Android 4.4.4. Recorded acceleration vectors are converted from the device's to World's coordinate system. Using Z-axis acceleration five indicators (average, variance, standard deviation, minimum and maximum) are computed. The same indicators are computed for speed. All indicators are computed for 10 second recording fragments (in which motion parameters were stable). Three types of motion are taken into account: driving, walking and running. In the driving experiment the phone is mounted in a rigid holder. During the walking and running experiments the phone is in the inner pocket of the user's jacket. The indicator values are shown in table 1.
Using indicators from table 1 a set of motion type recognition criteria was proposed. The criteria are shown in table 2. The main indicator is the Z-axis acceleration variance. It exhibits the strongest differences for the three motion types considered. Frequently, the variance alone is enough for identification. Two other criteria are proposed in order to improve identification quality. One is the Z-axis acceleration range and its symmetry. The other is speed range (determined using GPS).The speed of walking and running is based on the recorded values. The maximum speed for driving is the maximum driving speed allowed by law in Poland.

Extended results
For the purpose of this paper additional data is recorded. Since the goal of the research is to make the identification method more robust the data is gathered using a different mobile device, different cars, and the mobile device is placed in different places or carried in different pockets.
Specificallythe cars used in experiments are a Volkswagen Passat B5 (car#1) and a Seat Ibiza II (car#2). The phone is either mounted in a holder (vertically) or placed on the dashboard (horizontally). The driving test takes place on two types of roads: newly renovated (smooth surface) and containing many potholes (uneven road). During walking and running the phone is carried by the user in the inner jacket pocket or in the trousers pocket.
The mobile device used for data collection is Samsung Galaxy S3 Neo running Android 4.4.2, equipped with Qualcomm Snapdragon 400 -4 core CPU, MPU 6500 accelerometer/gyroscope module, YAS532 magnetometer and a GPS module.
The data is processed in the same way as during the initial research. Using selected 10 second fragments five indicators are computed for speed and Z-axis acceleration.
Selected results are presented in graphs below. Figures 3 and 4 show Z-axis acceleration and speed recorded while the user is walking with the phone in the trousers pocket and the jacket pocket. Tables 3 and 4 contain indicator values obtained for this experiment. It is worth noting that while most acceleration values are within the range determined the during initial research, the extreme recorded values are twice as high as the original boundaries (when the phone is in the trousers pocket).        Figure 7 shows data gathered in a car#1 while driving on a smooth road (Bojarczuka street in Krasnystaw). Table 7 shows the corresponding indicator values. The recorded acceleration values are mostly within the range determined in the initial research, however, some values lie outside that range. This means that placement of the phone influences recorded values IAPGOŚ 2/2016 p-ISSN 2083-0157, e-ISSN 2391-6761  The data collected while driving car#1 on an uneven road -Graniczna street in Krasnystaw is shown in Figure 8 (with corresponding indicator in table 8). The street is of low quality and has many potholes. The phone is placed horizontally on the car's dashboard. The Z-axis acceleration values (in terms of range) are very similar to those from the initial research. Different phone placement, different car and phone do not have much impact on the result.  Figure 9 shows a recording fragment collected while driving the car#2 on a smooth road (Bojarczuka street in Krasnystaw). Indicators are shown in table 9. One can notice that (1) the acceleration values fall within the range determined in the initial research, (2) absolute acceleration values are smaller than the values from the same test in the car#1.  Figure 10 shows a fragment of data recorded in car#2 on a bad quality road with many potholes. It can clearly be seen that potholes cause much higher z-axis acceleration values to be registered. Occasionally they are close to 10 m/s 2 which is much higher than the maximum values determined in the initial research. Most values fall within the range determined previously.  Table 11 contains the summary results for four tests conducted using car#1. It contains five indicators calculated for Z-axis acceleration and speed. The tests are: (1) driving on a smooth road with the phone mounted in a holder (vertically), (2) driving on a smooth road with the phone placed horizontally on the dashboard, (3) driving on an uneven road with the phone mounted in the holder and (4) driving on an uneven road with the phone placed on the dashboard. The value written in bold font is used for modifying detection criteria (the value is higher than one from the initial research). Table 12 contains results of the same tests conducted using car#2. In this case more values are used for modifying the criteria (values in bold). The low variance value (from the smooth road/vertical position test) is the lowest in all tests. It is used as a threshold value for detecting when the motion begins. The high variance value (from the uneven road / horizontal position test) is the highest in all conducted experiments. In modified criteria it is used as a boundary value between driving and walking. The minimum value (from the uneven road / vertical position test) influenced the Z-axis acceleration range in the modified criteria. Table 13 contains the summary of running/walking tests. Compared to the initial research the phone is carried in two different pockets (the inner jacket pocket and the trousers pocket). Phone placement can significantly influence the recorded values. In the case of the walking test the variance is much higher when the phone is in the trousers pocket. This value needed to be changed in the modified criteria (originally it was approximately equal to 10). Similarly, the range of values is much wider (minimum and maximum acceleration values in the same test). In the running tests on the other hand the recorded values are lower than in the initial results. The acceleration value range is modified accordingly.

Modified motion detection criteria
Based on the results of additional tests presented above a modified set of motion type detection criteria is proposed (table  14). The first change is that "standstill" is added as a type of motion. In practice a phone may frequently be motionless. The values of variance, speed, minimum and maximum are nonzero. This is because sensors in mobile devices are inaccurate and deliver such values even if the device is at a standstill. Another modification is excluding parts of common ranges in the "Z-axis acceleration ranges" criterion. This means that [-0,25;0,25] the standstill acceleration range is excluded from the [-5,8;7,4] the car acceleration range. For walking and running the acceleration ranges partially overlap. The boundary values are adjusted. For example, the maximal acceleration value for running is lowered from 43 m/s 2 to 15. The last refinement is the change in maximum speeds for walking and running.
The criteria described above can be implemented using voting principle. Each type of motion initially receives zero votes. During motion four indicators are computed: (1) Z-axis acceleration, (2) minimum Z-axis acceleration value, (3) maximum Z-axis acceleration value, (4) maximum speed from the GPS module. The values are constantly updated using the last 10 seconds of data. If one of the above conditions is met the corresponding motion type receives a vote. The result is the type that receives most votes.

Summary
The results presented in this paper prove that the principle of the motion type detection method proposed in [8] is correct. Many of the newly calculated indicator values match those from the original measurements. Some of them are adjusted in order to make the method more robust. The changes are needed for two reasons: (1) values recorded for a different person / car, and using a different phone do not match original values exactly, (2) the new recordings are made with the smartphone placed in more than one typical location (different pockets, car holder, dashboard).
Future work needed to further extend the method's robustness includes: (1) further (preferably simultaneous) tests using different devices, (2) including more types of motion (specifically other types of physical activities such as riding a bicycle).
There are many possible practical applications of the presented method. They include automatic tracking of fleet of company vehicles -the driver's smartphone may begin route recording automatically when car motion is detected. Another application is automatic collision detection. The large value of horizontal (NE) acceleration (unused in this work) may indicate a collision. To avoid false alarms horizontal acceleration would only be examined when the mobile device's user is in a moving car.