Driving Style Recognition System Using Smartphone Sensors Based on Fuzzy Logic

: Every 24 seconds, someone dies on the road due to road accidents and it is the 8th leading cause of death and the first among children aged 15–29 years. 1.35 million people globally die every year due to road traffic crashes. An additional 20–50 million suffer from non-fatal injuries, often resulting in long-term disabilities. This costs around 3% of Gross Domestic Product to most countries, and it is a considerable economic loss. The governments have taken various measures such as better road infrastructures and strict enforcement of motor-vehicle laws to reduce these accidents. However, there is still no remarkable reduction in the number of accidents. To ensure driver safety and achieve vision of zero accidents, there is a great need to monitor drivers’ driving styles. Most of the existing driving behavior monitoring solutions are based on expensive hardware sensors. As most people are using smartphones in the modern era, a system based on mobile application is proposed, which can reduce the cost for developing intelligent transport systems (ITS) to a large extent. In this paper, we utilize the accelerometer sensor data and the global positioning system (GPS) sensor deployed in smartphones to recognize driving and speeding events. A driving style recognition system based on fuzzy logic is designed to classify different driving styles and control reckless driving by taking the longitudinal/lateral acceleration and speed as input parameters. Thus, the proposed system uses fuzzy logic rather than taking the crisp values of the sensors. Results indicate that the proposed system can classify reckless driving based on fuzzy logic and, therefore, reduce the number of accidents.


Introduction
The 2030 agenda for sustainable development formulated by United Nations sets an ambitious target that the number of deaths and injuries caused by road crashes should be decreased by half by 2020. This target hasn't been met yet. Nowadays, vehicular traffic is a vital part of our day-to-day lives. India is a large developing country. In India, for the last 50 years, the number of automobiles has grown by 170 times, while the road infrastructure has grown by only nine times [1,2]. The vehicle population in India is over 55,000,000 and growing by 500,000 per year. In developing countries like India, the road quality tends to be variable, and bumpy roads, as well as potholes, are found in many places, even in the core of cities. The flow of traffic is also chaotic. People drive recklessly without obeying the traffic rules, overtaking others, often honking, etc. Heterogeneous vehicles (i.e., ranging from two-wheelers to four-wheelers) all travel on the same road. Therefore, monitoring these roads and vehicular conditions is of great importance. Studies reveal [3,4] that driver behavior is relatively safe if it is adequately monitored.

Motivation and Our Contribution
Prior work in monitoring driver behavior or road conditions has focused on the developed world, where the road conditions are good, the vehicles travel in an orderly manner, and there are proper lane systems. To monitor traffic, road, and driver behavior, the Intelligent Transportation System (ITS) [5] has been developed. It involves deploying dedicated sensors on roads and vehicles (e.g., GPS-based tracking units, traffic cameras, Doppler radar, etc.). It is less valuable due to its high cost. Our newly developed system is implemented on a smartphone, and it is less expensive compared to the ITS. Second, the proposed system is featured with fuzzy logic to overcome the limitation that strict limits are defined for driving event detection in the system proposed by Kalra et al. [6].

Prior Work
Previously, various researchers have monitored driving style using specialized hardware sensors deployed inside the vehicle or smartphone. Singh et al. [7] developed an Android application to detect driving patterns using the combined data obtained from the accelerometer sensor, GPS sensor, and audio sound of the microphone sensor. They observed various driving patterns, including speed breaker, lane change left/right, left/right turn, sudden braking, and sudden acceleration. Furthermore, they correlated accelerometer and microphone sensor events. One such event is 'if lane change turns are not accompanied by sound, it means rash driving'.
Fazeen et al. [8] designed an application using smartphone sensors deployed inside the vehicle to monitor driver style. They used the X-and Y-axis of the accelerometer to measure driver control on steering and brakes. Johnson et al. [9] designed a Mobile-Sensor-Platform system for Intelligent Recognition of Aggressive Driving (MIROAD). They utilized the data taken from various sensors (accelerometer, gyroscope, magnetometer, GPS, and video) and converted the data into a single value using a dynamic time warping algorithm. Chigrurupati et al. [10] developed an Android application to rate the driver using the accelerometer sensor, GPS sensor, and video. Sharma et al. [11] proposed a novel method to detect driver behavior using multiple unmanned aerial vehicles (UAV) vehicular networks. Ryder et al. [12] designed a system that can warn the driver about accidental hotspots through their journey based on their current location. Papadimitriou et al. [13] exploited machine learning approaches to identify the driver distractions mainly caused by using the mobile phone. Tang et al. [14] proposed a novel lane change detection mechanism called FCMNN, which is based on the combination of Fuzzy C-means clustering algorithm and adaptive neural network.
Kamaruddin et al. [15] detected the driver behavior based on emotions collected from speech using a combination of MFCC and MLP. Hu et al. [16] identified the driver activities such as using a mobile phone, talking with passengers, and smoking from still images using a deep learning multi-stream convolutional neural network approach. Zhao et al. [17] proposed a sensorbased head tracking system for monitoring driver behavior. Kalra et al. [18] conducted a survey on various smartphone sensors and methodologies for monitoring driver behavior. Kalra et al. [6] recognized the patterns of various driving events and road events using the accelerometer sensor of a smartphone. The recognized driving patterns include the left turn, right turn, sudden braking andsudden forward acceleration, and the recognized road events patterns include the potholes, bumps, and rough patches. The major limitation of their work is that they defined strict limits for the detection of events. For example, if the acceleration value of the accelerometer sensor is −1 to −3 g at the Y-axis, they denoted it as an abnormal braking event; otherwise, if the acceleration value of the accelerometer sensor is less than −3 g at the Y-axis, they denoted it as a sudden braking event. The difference of 0.1 g in acceleration value is not sufficient to differentiate between normal and reckless driver behavior. Kalra et al. [19] extended the work of Kalra et al. [6] for recognizing the patterns of various driving events using the accelerometer sensor of a smartphone. As an extension, they used a machine learning model (decision tree) to characterize and classify various driving events, such as the left turn, right turn, sudden braking, and sudden forward acceleration.
The paper is organized as follows. Section 1 describes the need forvarious driving style recognition problems and prior work. Section 2 describes the data collection method. In Section 3, various patterns of driving events are described. Section 4 presents a driving style recognition system based on fuzzy logic, and finally, we conclude in Section 5.

Data Collection
In this section, the data collection mechanism using asmartphone as the platform is introduced. Meanwhile, the accelerometer sensor and GPS sensor are used for the data collection.
i. Accelerometer: An accelerometer is a sensor used in mobile phones for measuring the tilting and orientation motion of the mobile phone. It is also used to measure the turning events (left turn and right turn) and acceleration events (acceleration and braking). It is an energyefficient sensor that consumes 1/10 the energy of other sensors in the mobile phone. It is an electromechanical device for measuring acceleration forces. Acceleration forces can be static or dynamic [20]. Static acceleration forces can be measured by Z-axis, like a constant gravitational force. In contrast, dynamic acceleration forces are measured by X-and Y-axis, which are caused by moving or vibrating the accelerometer [21]. Its unit is m/s 2 . Data is collected from the accelerometer sensor using the Android application "Accelerometer analyzer" in smartphone (shown in Fig. 1). All the values (x, y, and z) of the accelerometer sensor are obtained from the smartphone's internal hardware sensor. The sampling rate of data collection is five readings per second, i.e., a time interval of 200 ms.
To collect data, the smartphone is placed at a fixed location at the dashboard of a car in portrait mode. The orientation of the X-axis (points toward the right along the smaller side), Y-axis (points up along longer edge), and Z-axis (points towards the sky perpendicular to the plane of the front face of the screen) are shown in Fig. 2. The raw values of the X-, Y-and Z-axis collected from the accelerometer sensorare stored in the smartphone memory in .txt format.  ii. Global positioning system (GPS): It is a satellite-based navigation tracking sensor [23]. GPS sensor gives us the value of longitude and latitude for determining the exact location on the map. It is also used in smartphones to determine the location, route to the destination, and speed of the vehicle. In the proposed driving style recognition model, only speed is taken as an input parameter of the GPS, and other parameters are determined by other sensors deployed in the mobile phone. GPS sensor data is collected from the Android application named "Speedometer GPS" [24], as shown in Fig. 3.

Figure 3:
The user interface of data collection application "Speedometer GPS" [24]

Pattern Analysis of Driving Events
In this section, the pattern of various driving events such as left turn, right turn, forward acceleration, and braking are analyzed.
i. Left Turn: It is determined by the X-axis of the accelerometer deployed in a smartphone. If there is a quick decrease in the magnitude of the X-axis in the negative direction, it indicates the occurrence of left-turn [6]. The pattern observed in the accelerometer application for the left turn is shown in Fig. 4. ii. Right Turn: It is also determined by the X-axis of the accelerometer deployed in a smartphone. If there is a quick increase in the magnitude of the X-axis in the positive direction, it indicates the occurrence of right-turn [6]. The pattern observed in the accelerometer application for right-turn is shown in Fig. 5. iii. Forward Acceleration: It is determined by the Y-axis of the accelerometer deployed in a smartphone. If there is aquick increase in the magnitude of the Y-axis in the positive direction, and correspondingly there is a little deflection in the X-and Z-axis, it indicates the occurrence of forward acceleration [6]. The pattern observed in the accelerometer application is shown in Fig. 6. iv. Braking: It is determined by the Y-axis of the accelerometer present in a smartphone. If there is a quick decrease in the magnitude of the Y-axis in the negative direction, and correspondingly there is a little deflection in the X-and Z-axis, it indicates the occurrence of braking events [6]. The pattern observed in the accelerometer application is shown in Fig. 7.

Fuzzy Logic Based Driving Style Recognition System
In this section, a system for categorizing driving style using fuzzy logic is designed. The driving style can be divided into four categories: below mild, mild, reckless, and very reckless drivers.

Fuzzy Logic System
The fuzzy logic system maps the input to the output through combination rules, which is not possible through classical binary logic. When there are no extreme boundaries, the need for representation through fuzzy logic arises. With fuzzy logic, it is possible to implement the rules of the form: if (A&B) ⇒ C, where A, B, and C can be represented in natural language [25]. The following are the basic three steps in fuzzy logic [25]: • Fuzzification: In fuzzification, all input variables are converted into linguistic variables.
Various functions, such as the triangular and trapezoidal membership functions,are used for fuzzification. • Fuzzy inference: In fuzzy inference, various inference rules are used to calculate the fuzzy output. • Defuzzification: It is a process for converting fuzzy output to crisp output.

Fuzzy Logic Based System for Driving Style Recognition
To ensure the safety of drivers, we designed a driving recognition system based on fuzzy logic. The selection of inputs and outputs is determined by performing various real-life experiments. The fuzzy-based driving style inference system is shown in Fig. 8. Accelerometer sensor and GPS sensor data are used as inputs. The sampling rate of data is five readings per second, i.e., atime interval of 200 ms. It is found that 800 ms is large enough to capture the inherent characteristics of aleft turn, right turn, braking detection, and forward acceleration detection because these events last only for a short period of time. From each of the 800 ms windows, the extracted pattern is used as input to the fuzzy inference system. The average acceleration value is taken as input for four windows, i.e., 800 ms, and we use the average value as a single data point.
The accelerometer sensor provides the first input "acceleration" value. This value is used to determine straight driving, turns (left or right), and acceleration events (forward acceleration or braking). The lateral acceleration is used to determine turning events, and longitudinal acceleration is used to determine acceleration events. The corresponding membership values of acceleration events are defined as {straight, mild, reckless}. The value of lateral and longitudinal acceleration ranges from −1.5 to +6 g on X-axis and Y-axis. Fig. 9 plots the acceleration events using the triangular membership function.  The output "Driving Style" is categorized into four classes defined as: {below mild driver, mild driver, reckless driver, very reckless driver}. The driving style rating ranges from 1 to 10, where 1 indicates the below mild driver and 10 indicates the very reckless driver. Fig. 11 plots the driver's driving style using the triangular membership function. The fuzzy inference rules for predicting a driver's driving style are described in Tab. 1. In this model, all rules have been assigned the weight of 1. The whole mapping process for determining driving style by taking longitudinal/lateral acceleration and speed as input parameters after defuzzification is shown in Figs. 12a and 12b.   Fig. 12a shows the driving style map, taking the longitudinal/lateral acceleration and speed as input parameters after defuzzification. The number of rows in Fig. 12a shows the number of inference rules described in Tab. 1. The first row of Fig. 12a corresponds to the first row describing the inference rule in Tab. 1. Similarly, the second row of Fig. 12b corresponds to the second row describing the inference rule in Tab. 1, and so on. The output variable DRIVERSTYLE shows how the rules are applied to the output variable. The bottom plot of the output variable DRIVERSTYLE shows how each rule's output is combined to obtain the aggregate output of the defuzzified value. The red line in the bottom right plot defines the defuzzified value. In the MATLAB fuzzy toolbox, we can alter the red lines of the first two columns to change the input values and generate a new output response. Fig. 12a shows that if the accelerometer value is 2.38 and the GPS speed is 80, then the driver style value is 6.5, which indicates the driver is reckless. Fig. 12b describes the driving style's surface map, taking the longitudinal/lateral acceleration and speed as input parameters to output the DRIVERSTYLE after defuzzification. Fig. 12b shows a very high value for the DRIVERSTYLE output parameter if the acceleration values and GPS speed sensor values are very high (i.e., it depicts that the driver's driving style is very reckless). If the acceleration values and GPS speed sensor values are high, it indicates that the driver's driving style is reckless. Fig. 12b shows the average value for the DRIVERSTYLE output parameter if the acceleration values and GPS speed sensor values are averaged (i.e., it corresponds to a mild driving style). If both parameters acceleration values and GPS speed sensor values are very low, it indicates that the driving style is below mild.  Figure 12: (a) The mapping process for determining driving style by taking longitudinal/lateral acceleration and speed as input parameter after defuzzification. (b) The mapping process for determining driving style by taking longitudinal/lateral acceleration and speed as input parameter after defuzzification

Conclusion
In this paper, we exploit the data obtained from the accelerometer sensor and GPS sensor deployed in a smartphone for recognizing the driving and speeding events. Various driving event patterns have been analyzed, such as the left turn, right turn, acceleration, and braking. We have classified various driving styles and designed a driving style recognition system based on fuzzy logic, taking the longitudinal/lateral acceleration and speed as input parameters. The proposed model is implemented in MATLAB [26] and fuzzy logic is exploited to recognize the driving style. In contrast to previous research on driving style recognition, our system is implemented entirely on a mobile device without using external hardware. Our proposed system is also a system based on fuzzy logic rather than the one using crisp values. The experimental results show that our system can recognize various types of driving styles, including reckless driving.
The limitation of our proposed approach is that this approach only works when the phone is placed at a fixed location on the dashboard of a vehicle in portrait mode. In the future, we will try to conduct a virtual reorientation of the mobile phone to matchthe phone's axis. Future researches can also incorporate other sensors of mobile phones for better results.