Development of a Real Time Supported Program for Motorbike Drivers Using Smartphone Built-in Sensors

Using mobile phones during traffic progress is one of the main causes traffic accidents because drivers do not focus on driving, they try to listen phone calls or to text some messages... Most of research work has focused to car driving. However, using motorbike is very popular in some developing countries such as Vietnam, India, etc. Up to now, there are just a few works, which focus to motorbike driving with obvious limitations. Thus, in this research, we proposed a complete solution for bikers who own a smartphone. Our work exploits the information from built-in sensors in Android smartphone. A complete scheme for motorbike driving is proposed. In this scheme, the user state is detected by improving the current Google activity recognition API. If the state is “On vehicle”, the phone automatically switches to silent mode and send to the caller an SMS. Our work provides a mechanism to receive the calls from VIP contacts and urgent calls. The phone would switch back to the normal mode if the state is not "On vehicle". Furthermore, it sends the accident location to the relatives when an accident occurs to save their lives automatically. The application was tested carefully and it can be used to protect the lives of motorbike drivers. Keyword-3-DOF Accelerometers, GPS, Accidental Location, Motor Safe

Fig. 1.The total number of traffic accidents, people died and people injured in 2015 and 2016 in Vietnam [1] The private software S-Bike of Samsung was installed in Galaxy J 2017 series products to support for motorbike drivers during the driving process.S-Bike can filt all incoming calls and it also allows to receive the calls from important numbers and to answer the phone when drivers stopped.However, S-Bike also has some limitations that cannot change between silent mode and normal mode automatically, it needs to do manually.Hence, the phones are still in silent mode when drivers stopped, then they can lose calls or messages.Furthermore, S-Bike does not have the function that can send out messages or call relatives and hospital services when the accident occurred.
Based on the above limitations, this paper proposed to develop an efficient application that can be installed in smartphones to protect drivers' lives while driving motorcycle.The application will automatically recognize states of the user, if drivers are detected "On vehicle", the phone will automatically change to silent mode and all incoming calls from unimportant or unknown people will be rejected with a notification message "I'm driving, call me later" except the calls from VIP or urgent calls.If drivers got accident, a message that attached their position will be sent to relatives and hospital services.Total number of traffic accidents The number of people died The number of people injured popular in the number of mobile applications and mobile platform.Google APIs (Application Programming Interfaces) developed by Google allows communicating with Google Services such as Search, Gmail, Translate, Google Maps...The third-party apps can use Google APIs to take advantage or extend the functions of the existing services.Google activity recognition API (GAR_API) used machine learning classifiers to recognize user activities deployed as part of Google Play Services (see Fig. 3).Currently, it can detect 8 states of user include: IN_VEHICLE, ON_BICYCLE, ON_FOOT, RUNNING, STILL, TITLING, UNKNOWN, WALKING.Each state has a constant value as in Table 1.

C. The flowchart of the proposed work
The flowchart of the proposed program is shown in Fig. 7.After installing this application on Android smartphone, the user click on "Start" button, and built-in accelerometers will start to acquire accelerations in the X, Y and Z axes automatically.Consequently, two parallel threads will be executed.
In the first thread, if the driver is detected with the status of "On vehicle", the phone will be changed to silent mode.In this mode: + All normal phone calls will be rejected, and the caller will receive a designed message "I'm driving, call me later".
+ If the caller is in the VIP list, it allows the phone ringing and vibrating.The program will check the current velocity of the motorbike, and the motorbike driver can only answer the call only if he/she stops driving (i.e. the velocity is smaller than a determined threshold).
+ If the caller is not in the VIP list, but it is an emergency situation, the program will recognize it is an emergency call when the number of the phone calls is higher 3 times in 5 minutes.Similar to the scenario of the VIP call, in order to save the lives of drivers, this application requires he/she stop driving before answering the phone.
If the driver stops driving, the program will recognize this status and switches the phone to the normal mode.It means that he/she can hear the ring and the vibration of the phone call as usual.The flexible switching between "On vehicle" and "Not On Vehicle" will maximize the safety and the convenience of the motorbike drivers.
In the second thread, the phone monitors if the accident happens.In the case of an accident, an alert will notify the driver to check if he/she can manage this situation by himself/herself.After a period of time, it will send a message that attached the accident location to their relatives and hospital services.

1) Detecting the user's status
Activity Recognition is a Google service that allows android app developers detect activities of the users through the ActivityRecognitionAPI.In order to detect the status of a user, Google Play Services Activity Recognition API gives the ability to detect a number of our physical activities as in table 1.All these activities can be detected simply by using an API to access Google Play Service.Detected Activity is obtained from ActivityRecognitionAPI.Some constant values showed as in the table below: The device is on a user who is walking or running. 2

RUNNING
The device is on a user who is running.This is a sub-activity of ON_FOOT. 3

STILL
The device is still (not moving).4

TITLING
The device angle relative to gravity changed significantly.This often occurs when a device is picked up from a desk or a user who is sitting stands up.

UNKNOWN
Unable to detect the current activity.6

WALKING
The device is on a user who is walking.This is a sub-activity of ON_FOOT.7 The using Google ActivityRecognitionAPI is also exiting some limitations because of traffic conditions and people habits.Then, there are some types of "On vehicle" samples that Google ActivityRecognitionAPI detected the wrong state.
In this paper, we proposed cascade algorithm and threshold value (Th1) to improve the accuracy of Google ActivityRecognitionAPI in detecting "On vehicle" state.Th1 was chosen based on the result of analysis carefully on our recorded data.Hence, threshold Th1 and cascade algorithm play an essential role in distinguishing between "On vehicle" and other states.If after two consecutive times of checking in 1 second, the results are "On vehicle", the final decision will be "On vehicle" and vice versa.Nevertheless, if the results of two consecutive times are different, we propose an algorithm requires to check more times and compares with Th1 to improve the accuracy of the system as in table 2: In the case of detecting user status is driving, the authors had developed a function that called "blockCall()", it will automatically change smartphone to silent mode and send out a message with content: "I'm driving, call me later" to the caller if they receive incoming call while driving except the calls from VIP contacts.This is a very essential function that does not lose focus on driving of the user.

2) Detecting accidents
3-DOF sensor used to get accelerations in 3 axis X, Y and Z (see Fig. 5); the X axis is horizontal and point to right; the Y axis is vertical and points up and the Z axis points toward the outside of the screen.Android allows to specify the sampling frequency using one of four sensor delay: -SENSOR_DELAY_FASTEST: 0 millisecond delay -SENSOR_DELAY_GAME: 20 milliseconds delay -SENSOR_DELAY_NORMAL: 200 milliseconds delay -SENSOR_DELAY_UI: 60 milliseconds delay An acceleration sensor determines the values by measuring the forces that are applied to the sensor as the following relationship: However, the force of gravity is always influencing the measured acceleration according to the following relationship: When the device is located on a table, the accelerometer reads a magnitude of g = 9.81 m/s 2 .Similarly, when the device is in free fall, acceleration magnitude values change rapidly and a low-pass filter was used to isolate the force of gravity.
Figure 6 shows the processing of acceleration to determine accident: After pre-process by using a low -pass filter, the square root (Acc) is calculated: where: A X , A Y , A Z are acceleration value in each axis.The mean obtained by using a moving-average filter, this is represented by the following difference equation: where y(n) is "mean"; windowSize is the size of window in processing.By comparing the mean with threshold Th2=4×g (with g = 9.81 m/s 2 ) [6] to detect an accident.If an accident occurs, an automatic message that includes the address of the accident will be sent to relative members and medical services.
III. RESULTS AND DISCUSSION For the experimental testing, we carried out on 5 smartphones Samsung Galaxy Trend Plus GT S7580 and 17 students (12 males and 5 females) ages: 19-21, height: 1.56 -1.75 m, weight: 46-65 kg who were randomly selected from various students in University of Engineering and Technology, Vietnam National University, Hanoi.

A. Detecting the user's status
Google Activity Recognition API is used to detect if the driver's status is "On Vehicle" or not.The Fig. 7 and Fig. 8 show the result of training "Walking" (i.e. the user was actually walking in the street).In Fig. 7, it can be seen that the device is successful to determine the status of "Walking" with the percentage varied from 92% to 100 %.Also in this test, Fig. 8 shows that the percentage of "On Vehicle" is very small (from 0% to 8%).The device is successful to determine the status of the users with the percentage of "On vehicle" (i.e. from 38% to 100%) is always larger than that of "Walking" (i.e. from 0% to 23%).Nevertheless, most of values in "On vehicle" are bigger than 60%.Hence, the threshold chosen to detect "On vehicle" is Th1 = 60%.Figure 12 shows that the phone automatically detected the status of users and change the phone to silent mode when the users was driving.Figure 14 shows the data obtained from accelerometer for testing on vehicle with a stable speed, the value of acceleration in three axes have been changing fast between samples.As can be seen in Fig. 15, when the accident occurred, the values of acceleration changed suddenly.Figure 16 shows the Acc, which is calculated by Equ. 3 and its average that is computed by using a movingaverage filter that is shown in Equ. 4. As can be seen in Fig. 16, when an accident occurs, both values of total acceleration and its mean increase suddenly.In order to confirm about the accident, an alert notification will appear on screen as shown in Fig. 17.If the user press on "No" button, there is no message will be send.If the user presses on "Confirm" button, a message will be sent to the user's relative person immediately.Without the confirmation, a message will sent to the user's relative person after 10 seconds.IV.CONCLUSION In this paper, we have been successfully developed an application that can be installed on Android smartphones with important features such as: automatically detect the status of users and change the phone to silent mode if the users are driving; reject all unimportant and unknown calls with an SMS message except VIP contacts; provide a mechanism to receive emergency calls (even the caller is not in the VIP list), switch the phone to normal mode if the user stops using the motorbike.Furthermore, our application can detect an accident and automatically sends a message notification attached address location to the relatives and hospital services.This application is also installed and tested on many other Android phones.Through the app, the users can focus on driving safely.For the future research, we will make this application more friendly and improve the algorithm to increase the accuracy of our application.

Fig. 2 .
Fig. 2. Drivers are using a mobile phone while driving[3][4] II.METHODS A. Hardware Components The prototype uses a computer with Microsoft® Windows® 10, 64 bit; Intel Core i5 Haswell 4200U 1.60 GHz; 8Gb of RAM and NVIDIA Geforce 720M as well.It also uses smartphone Samsung Galaxy Trend Plus GT S7580 for experiment testing with specifications as: -CPU: Dual core 1.2GHz; -RAM: 768 MB; -Android OS: Android 4.2.2 (Jelly Bean); -ChipSet: Broadcom BCM21664; -MicroUSB 2.0; -Sensor: Accelerometer (BOSCH BMC150), Proximity (GP2A), Magnetic (BOSCH BMC150).B. Software ComponentsAndroid is an open source nature, which developed by Google based on the Linux kernel.It attracted a large community of developers with primarily designed for touchscreen mobile devices such as smartphones and tablet with specialized user interfaces for Android TV, Android Auto and Android Wear... Therefore, it is very

Fig. 3 .
Fig.3.Google activity recognition API deployed as part of Google Play Services[19]

Fig. 4 .
Fig. 4. The algorithm of the proposed system

Fig. 8 .
Fig. 8.The percentage of detecting "On vehicle" in training "Walking" Figures 9 and 10 show the result of training "On vehicle" with the speed which varied from 20 km/h to 40 km/h in the distance of 2 km.The device is successful to determine the status of the users with the percentage of "On vehicle" (i.e. from 38% to 100%) is always larger than that of "Walking" (i.e. from 0% to 23%).Nevertheless, most of values in "On vehicle" are bigger than 60%.Hence, the threshold chosen to detect "On vehicle" is Th1 = 60%.

Figure 12 .
Figure 12.Change to silent mode while on vehicleB.Detecting accidentsFigure13shows acceleration values in three axes for testing of the walking activity, the acceleration values in each axis change in short time intervals and between the moving statues.

Fig. 13 .
Fig. 13.Accelerometer data for the training of the walking activity

Fig. 14 .
Fig. 14.Accelerometer data for training on the vehicle when no accident occurs

Figure 17 .
Figure 17.Notification when accident or free fallingFigure18shows the message send to the user' relative person.After receiving this message, the relative person just simply clicks to the link to see the accident location in the map.

Fig. 18 .
Fig. 18.Message notification and address of the accident

TABLE II .
The final decision of recognition process using Cascade algorithm