Design and Implementation of Driving Behavior Analysis System
Yi Han, Yuan Yao, and Haiyang Liu
School of Automobile, Chang'an University, Xi'an, Shaan Xi, China Email: [email protected]
Abstract—It is widely realized that drivers’ driving behavior has a huge influence on road traffic safety. In order to better understand the characteristics of driving behavior and to improve the road safety, the system which could acquire and analyze drivers’ driving behavior is needed. In this paper, we present the technological means and analytical methods of an analysis system used for researching drivers’ behavior in detail. The hardware system is made up of two computers and a Driving Force Pro. The software system includes Speed Dreams engine, the Monitor program and the Data Analysis program. The Speed Dreams engine is used to create driving scenarios, the Monitor program is used to high-speed record driving behavior, and the Data Analysis program is used to real-time analyze the characteristics of driving behavior.
Inter-process message communication technology and multi-thread programming are adapted to synchronous acquire, record and analyze all the driving behavior data as well, which ensure the continuity and equal time interval.
What’s more, smoothing, noise reduction, derivation and other data processing methods are used to analyze and obtain the characteristics of driving behavior, such as response time, braking speed, steering speed and so on. The test results show that the established driving behavior analysis system not only could real-time acquire the data of driving behavior, but also could analyze the characteristics of driving behavior accurately. Therefore, the driving behavior analysis system will provide reliable support for further research on driving behavior, which aims to improve the driving safety.
Index Terms—Driving Behavior; Inter-Process Communication; Multi-Thread Programming; Data Processing; Driving Safety
I. INTRODUCTION
Driving behavior is a kind of external manifestation of drivers’ cognitive process. The research on driving behavior could be useful for the prediction and intervention of risky behavior of drivers, the design of road facilities and in-vehicle equipment, and the improvement of traffic safety [1]. Considering the risk of using real vehicle, many researchers at home and abroad usually use driving simulator to study driving behavior.
Driving simulators are an integrated application of computer technology, control technology and electronic technology since 1980s. Driving simulators have the advantages of real person-car interactive interface, repeated and controlled test condition, safety and reliability limited working condition [2]. Therefore, using
driving simulators to record and analyze driving behavior is one of the ideal methods in the field of driving safety research [3]. Driving simulators will provide a safe and replicable experimental environment and research platforms for studying driving behavior.
The capabilities of driving simulators are varied greatly, ranging from low-level desktop-mounted systems [4] to mid-level fixed-based simulators with real cab and immersive display [5], and to high-level multi-million dollar installations capable of replicating large amplitude driving motions with a moving base. In China, development and application of driving simulators started from late 1990s and a majority of driving simulators are developed mainly for training and improving drivers’
driving skills, such as driving simulators of Sanlian company in Anhui, driving simulators of Toronto company in Nanjing. What is more, the above driving simulators don’t have the characteristic of secondary development [6]. Therefore, there are some difficulty to meet a series of requirements on driving behavior research, such as dynamic creating specific driving scenarios, real-time collecting and recording driving data, real-time analyzing and calculating collected data .etc [7].
At present, the domestic application of driving simulators on research and analysis driving behavior are still insufficient. Many researchers usually deal with mass raw driving behavior data manually, which is time-consuming and inefficient. What is more, physically handling will generate a lot of errors.
In order to better understand drivers’ driving behavior, the system in which behavior data collecting synchronize with behavior data analyzing is needed. In this paper, a new driving behavior analysis system used to research driving safety is built. The hardware system combines two computers with a Driving Force Pro. The software system includes open source 3D engine-Speed Dreams, the Monitor program and the Data Analysis program.
When drivers drive on this system, not only can the driving data be real-time collected and recorded, but also can the driving data be analyzed and the drivers’
operation characteristics be given out. The driving data is analyzed by using some data processing algorithms, such as smoothing, noise reduction, derivation, and the analyzed results include response time, braking speed, steering speed, .etc.
In order to ensure the continuity and equal time interval of behavior data, inter-process message
communication technology and multi-thread programming between two computers are adapted to acquire, record and analyze all the driving behavior data synchronously. In this way, the Data Analysis program will not account for so much CPU to slow the speed of simulation and to lag driving scenarios. The problem occurred in former driving simulators, in which the simulating driving scenarios and data processing program were housed on the same computer, is solved.
The driving behavior analysis system would provide a good platform and important support for further better research on drivers’ driving safety. what is more, the system also could work together with other data acquire equipments, such as eye tracker, physiological signal processor and so on. Thus, the characteristics of drivers’
driving behavior could be studied comprehensively by integrating with parameters of physiology, psychology and operating.
II. SYSTEM STRUCTURE
The drivers’ behavior analysis system consists of a
Driving Force Pro, a display and two computers (named computer I computer II). The whole system structure is shown in Fig. 1.
The functions of Driving Force Pro include two aspects: one is to provide a simulating driving platform for drivers; the other is to real-time record the change signals of steering wheel, throttle, clutch, brake and so on during drivers driving and send to the Monitor program through the USB. The display is needed to display 3D driving scenarios to drivers when they driving.
The computer I also has three functions: the one is to drive Speed Dreams engine to generate 3D driving scenarios corresponding with drivers’ behavior and to send environment data to the Monitor program [8]; the two is to run the Monitor program to high-speed collect braking, steering, accelerating and other operating data sent from Driving Force Pro; and the last is to make the Monitor program real-time transmit analyzed results to Speed Dreams engine and transmit the operating data and environment data to the computer II through the network.
TABLE I. THE FILE OF COLLECTED DATA
Time Driver Number Scenario Number Event Mark Accelerate Brake Steering Angle Speed Mileage
44.54 1 10 0 8 0 512 26.18 775.69
44.57 1 10 0 8 0 512 26.18 776.97
44.63 1 10 1 8 0 512 26.18 778.31
44.66 1 10 1 8 0 512 26.18 779.67
44.72 1 10 1 8 0 512 26.18 781.03
44.75 1 10 1 8 0 512 26.18 782.44
44.81 1 10 1 8 0 511 26.19 783.78
44.84 1 10 1 8 0 511 26.19 785.32
44.90 1 10 1 8 0 511 26.19 786.74
44.93 1 10 1 8 0 511 26.19 788.18
44.99 1 10 1 8 0 511 26.19 789.65
45.02 1 10 1 8 0 511 26.19 790.98
45.08 1 10 1 8 0 510 26.19 792.39
45.11 1 10 1 5 0 509 26.19 793.18
45.17 1 10 1 0 0 507 17.07 794.62
45.20 1 10 1 0 0 506 9.78 795.44
45.26 1 10 1 0 0 505 5.56 795.92
45.29 1 10 1 0 0 504 2.72 796.15
45.35 1 10 1 0 0 504 1.02 796.26
45.38 1 10 1 0 0 504 0.41 796.31
45.44 1 10 1 0 1 504 0.07 796.33
45.47 1 10 1 0 7 504 0.02 796.33
45.53 1 10 1 0 9 504 0.00 796.33
45.56 1 10 2 0 10 504 0.02 796.33
45.62 1 10 2 0 10 505 0.02 796.33
Computer Ⅱ
Analyzed Result Driving Force Pro
Operating Data
Environment Data
Data Analysis program Speed Dreams Engine
Monitor program
Environment Data Computer Ⅰ
Creating Driving Scenarios
Analyzed Result Display
Operating Data
Driving Behavior Database
Figure 1. The whole system structure
The computer II has two functions as well: the one is to run the Data Analysis program to synthesize record, analyze and handle the environment data and operating data,; and the other is to save analyzed results to the driving behavior database and to send them to the computer I through the network as well, based on which the computer I updates driving scenarios.
There are some advantages of using two computers in one system. Previously, the simulating driving scenarios and data processing program were usually housed on the same computer [9]. However, running the data processing program will account for a majority of CPU which would slow the speed of simulation, so that sometimes there may lag driving scenarios. By separating the data processing program on computer II, the simulation runs closer to real-time, therefore, it is more realistic, which means the data collected also reflects real-time driving scenarios and is more reliable.
III. DATA ACQUISITION AND NETWORK
COMMUNICATION
As mentioned above, one of the main functions of driving behavior analysis system is to record drivers’
operating data in real time. And then assess drivers’
driving ability after analyzing their behavior characteristics in different driving scenarios. Therefore, the collected data should include steering wheel angle, pedal travel of throttle, brake and clutch, gear, mileage, speed, scenario number .etc [10]. The above mentioned information comes from the Driving Force Pro and the Speed Dreams engine. The file of collected data is shown in Table I.
A. Operating Data High-speed Acquisition
The Driving Force Pro with USB interface could provides different types of operating data for the Speed Dreams engine in real time. However, the refresh rate of 3D driving scenarios is limited, and the sampling frequency of the simulator is low (generally less than 50Hz), thus the sampling frequency of operating data directly acquired from the simulator and Speed Dreams is too low to meet the requirement of accurate calculation.
The Monitor program could acquire operating data directly from the interface of the simulator without affecting the operation of Speed Dreams engine. In other words, the Monitor program and Speed Dreams engine are totally independent on acquiring operating data.
Using DirectInput technology in DirectX can high-speed acquire operating data [11]. The DirectInput provides a large number of interface functions, but it is still not very convenient to use it. In order to conveniently call interface functions and meet design concepts of software engineering, the paper uses Joystick class-CDI Joystick to acquire operating data, the second package of DirectInput.
Functions in CDI Joystick class can easily obtain and initialize interface pointers of DirectInput. It also can be automatically connected to the joystick and collect operating data without affecting other programs running whenever.
The main functions used in the CDI Joystick are as follows [12]:
LPCDIDEVICEINSTANCE GetFirstJoystickID (void);
void SetPreferredDevice(&myguid);
bool PollDevice(void);
In the Monitor program, timing call the Poll Device function with 1Khz by using high-precision timer to meet the requirement of high-precision data acquisition.
The codes of high-precision timer are as follows:
TIMECAPS tc;
UINT wTimerRes;
if(timeGetDevCaps(&tc,sizeof(TIMECAPS))!=TIMERR_NOERRO R)
return false;
wTimerRes=min(max(tc.wPeriodMin,1),tc.wPeriodMax);
timeBeginPeriod(wTimerRes);
g_wTimerID=timeSetEvent(1,1,(LPTIMECALLBACK)TimerFunc,(
DWORD)this,TIME_PERIODIC);
The codes of collecting driving data within timer program are as follows:
myJoystick1.PollDevice();
LPDIJOYSTATE2 joy=myJoystick1.GetJoystickStateInfo();
B. Data Communication between Monitor Program and Speed Dreams Engine
When drivers driving on the simulator, some environment information, such as driver ID, mileage, speed, vehicle location, scenario ID .etc, must be real-time sent from Speed Dreams engine to the Monitor program with the minimized impact on the driving simulation system. Thus, the paper uses MFC message transfer function-Post Message to send above environment information to the Monitor program. The Post Message is a asynchronous non-blocking messaging functions, which puts a message into a queue, and then returns back regardless of whether the message is dealt or not. With properties of low CPU utilization and non-blocking, Post Message ensure the independence and real-time of Speed Dreams engine at the maximum range.
The Monitor program uses message map mechanism-On Message to receive environment data sent from Speed Dreams engine. After combining environment data with operating data, they are sent to the computer II through network.
The data communication flow between the Monitor program and Speed Dreams engine is shown in Fig. 2.
Speed Dreams engine
PostMessage Function Environment Data
The Monitor Program OnMessage Function
Figure 2. The data communication flow
C. Network Communication between Monitor and Processing Program
The Monitor program combines operating data with environment data and acquisition time, then packages and sends them to the Data Analysis by UDP protocol of LAN.
UDP (User Datagram Protocol) is an oriented connectionless protocol, which doesn’t need to establish connection. Thus, it has advantages of high efficient communication and less CPU occupancy. The reliability of communication is a little poorer than TCP/IP, but the data loss rate is less than 0.01% when two computers are directly connected with one cable. Because each group of data includes acquisition time, the continuity of data collection process will not be affected even if one group of data lost. Therefore, using UDP protocol to send acquired data is a good solution of network communications.
The format of UDP packet is shown in Table II.
TABLE II. THE FORMAT OF UDP PACKET
UDP packet index time Information driver Information Driving information Scene information
The main codes of UDP sending in the monitor program are as follows:
WSADATA wsaData;
WSAStartup(MAKEWORD(2,2),&wsaData);
SOCKET ServerSocket;
ServerSocket=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
SOCKADDR_IN addr_in;
addr_in.sin_family=AF_INET;
addr_in.sin_port=htons(1);
addr_in.sin_addr.S_un.S_addr=inet_addr("192.168.0.33");
UDPDATA mm;
sendto(ServerSocket, (char *)
&mm,sizeof(DATAHEAD), 0, (sockaddr*) &addr_in, sizeof(addr_in));
The main codes of UDP receiving in the Data Analysis program are as follows:
SOCKADDR_IN addrSrv;
UDPDATA mm;
recvfrom(ServerSocket,(char*)&mm,sizeof(DATAHEAD),0,(socka ddr *)&addrSrv, sizeof(addrSrv));
data acquisition
thread
data sending
thread buffer B
buffer A
Figure 3. Communication mode between two threads
In order to fully ensure that Monitor program can send acquired data to Data Analysis program timely and accurately, multi-thread communication technology is used within the Monitor program. Data acquisition and sending can be done by different threads and will not affect each other. At the same time, communication between two threads needs to use double buffering mode.
First, data acquisition thread put acquired data into A buffer, which will inform data sending thread after being filled. Subsequently, data acquisition thread put acquired data into buffer B, which also will inform data sending thread after being filled. Simultaneously, data acquisition thread put acquired data into buffer A again. Thus A-B-A-B can make two threads completely independent
and run at full speed. The communication mode between two threads is shown in Fig. 3.
D. 3D Driving Scenarios Design
3D driving scenarios are the basis of simulating driving and their quality has important influence on the driver's driving behavior [13]. In the paper, Vehicles, pedestrians, buildings and roads designed in the 3D driving scenarios are refined modeling based on the line types and control parameters of actual road. The visual effects between the virtual and real scenarios are strived to make consistency. By combining with real-time rendering technology of professional 3D simulation engine, 3D driving scenarios are shown to drivers realistically. Certain designed driving scenario is shown in Fig. 4.
Figure 4. The designed driving scenario
In order to study driving behavior comprehensively, the traffic environment of designed 3D driving scenarios include highway, urban road, suburban road, mountain road, tunnel, sunny day, rainy day, fog day and night.
IV. DRIVING BEHAVIOR ANALYSIS
After the computer II receiving driving behavior data, Data Analysis program is required to analyze these data and give out analysis results such as whether drivers’
driving behavior is correct or not, how long their response time is .etc. Drivers’ characteristics then can be analyzed based on analysis results.
A. Data Smoothing
Since acquired data are discrete, equal time intervals and containing noise. If changing velocity, changing acceleration and changing jerk are calculated directly from data, they also contain noise which would interfere with finding the maximum value of angular jerk. Hence acquired data should be smoothed and denoised before differential [14].
The specific three points smoothing algorithm are as follows:
(1) (1)
(2) ( (1) (2) (3)) / 3
(3) ( (1) (2) (3) (4) (5)) / 5 (4) ( (2) (3) (4) (5) (6)) / 5 ...
( 2) ( ( 4) ( 3) ( 2) ( 1) ( )) / 5
( 1) ( ( 2) ( 1) ( )) / 3 ( ) ( )
sp p
sp p p p
sp p p p p p
sp p p p p p
sp n p n p n p n p n p n
sp n p n p n p n
sp n p n
(1)
where:
(1) ( )
p p n —the collected data;
(1) ( )
sp sp n —the smoothed data.
Using the smoothing algorithm, the smoothed angle of steering wheel of certain driver is shown in Fig. 5.
Figure 5. The acquired data and smoothed data
B. Drivers’ Response Time Calculation
Response time is a time span from the moment of dangerous appearing to drivers starting to take action.
The force on brake pedal or steering wheel usually changes the most drastically when drivers are under critical situation. Therefore, we can consider that drivers start to take action approximately at the moment when the rate of force changes the fastest [15].
As we know, the relationship between torque imposed on brake pedal or steering wheel and their angular acceleration is as follows:
M J (2)
where:
M—torque;
J—rotational inertia, which is a constant;
—angular acceleration.
The relationship between torque and force imposed on brake pedal or steering wheel is as follows:
M F r (3)
where:
F—force
r— rotation radius ,which is a constant.
Combining formula (2) and (3), we know that the force on brake pedal or steering wheel is proportional to their angular acceleration.
After derivation calculus to above formulas, we get:
( ) ( )
J d r d F (4) From above formula, we can know that the rate of force changing is proportional to angular jerk. So, if we want to know the response time T of some driver, we just need to know the moment of dangerous appearingT , 1 the moment of angular jerk of brake pedal reaching largest absolute value T and the moment of angular 2 jerk of steering wheel reaching largest absolute value T . 3 Thus
2 3 1
min( , )
T T T T (5)
where:
T—response time;
T1—the moment of dangerous appearing;
2, 3
T T —the moment of absolute value reaching largest.
What is more, whether drivers’ response behavior is correct or not can be judged by the direction change of brake pedal, steering wheel or accelerator pedal angle.
C. Operation Data Calculation
In order to analyze the characteristics of drivers’
driving behavior, the velocity, the acceleration and the jerk of baking, accelerating or steering are also needed to calculation. As we all know, the first derivative of a variable is the velocity of the variable change, the second derivative is the acceleration of the variable change, and the third derivative is the jerk of the variable change, thus as follows:
' '' '''
( ) ( ) ( ) v f x
f x f x
(6)
where:
x—some variable;
v—changing velocity;
—changing acceleration;
— changing jerk.
In the paper, the algorithm used to do derivative is as follows:
' 3 ( ) 4 ( 1) ( 2)
( ) 2
f x f x f x
f x T
(7)
where:
T—interval time of data sampling.
Therefore, after smoothing and filtering the collected data by the above smoothing algorithm, the velocity of steering or braking could be obtained through first derivative. The obtained velocity data may still have noise, so it should be smoothed again to eliminate noise before doing next derivative to obtain the acceleration of steering or braking. Similarly, the jerk of steering or braking could be obtained from the acceleration data after derivative.
The whole process of calculating the drivers’ operating data is shown in Fig. 6. Some steering angle curve, steering velocity curve, steering acceleration curve and steering jerk curve of steering are shown in Fig. 7.
original data smooth
derivative changing velocity
smooth
derivative
changing acceleration smooth
derivative changing jerk
Figure 6. The process of calculating the jerk
As mentioned above, the drivers’ response time is the moment corresponding to the maximum absolute value of
TABLE III. THE TEST RESULTS
ID Response Time (s)
Average Speed (km.h-1)
Brake Depth (scale)
Brake Velocity (mm.s-1)
Steering Range (°)
Steering Velocity (°.s-1)
1 0.567 43.4 5 66.7 93.7 177.7
2 0.536 42.6 3 133.4 60.9 104.2
3 0.668 47.3 2 182.4 177.1 193.2
4 0.603 45.1 4 175.5 114.5 171.9
5 0.622 46.6 6 149.5 78.9 133.3
6 0.667 45.5 4 142.6 74.4 125.0
changing jerk. Certain angular jerk of steering wheel is shown in Fig. 8. Point A is the maximum absolute value (the red point on Fig. 8), which means the driver starts to operate steering wheel at the moment corresponding to A after danger signals appearing. From the Fig. 8. we can see the driver’s response time to steering wheel is about 0.38 seconds, based on which driver’s driving response ability could be evaluated and analyzed.
Figure 7. The data processing
Figure 8. The driver response time of steering
What is more, the calculation method of driver response time of braking or accelerating is the same as the way of calculating steering.
V. ACTUAL TESTING
With the above solution of hardware system and software system, the built driving behavior analysis system is shown in Fig. 9.
Figure 9. The driving behavior analysis system
In order to verify the effectiveness of the system, 6 people (male 4 and female 2) are tested. The test driving scenario is as follows:
Daytime, sunny, driver is driving on a 4-lane urban road with the speed of 45km/h. When driving nearby one cyclist, the cyclist suddenly falls from the bike.
The test results are shown in Table III.
From the above test results, the response time, average speed, brake depth, brake velocity, steering range, steering velocity could be calculated correctly.
VI. CONCLUSION
The paper studies principle, composition and implementation of the drivers’ driving behavior analysis system based on Speed Dreams engine and Driving Force Pro. The software and hardware system have been designed based on the above method. Several typical driving scenarios have been designed and data acquisition and analysis program have been completed. In the end, a method of data analysis and response time calculation is presented.
The results prove that the method is fully applicable to analyzing properties of drivers’ driving ability. It also has advantages of high accuracy of acquired data and low-cost of equipment. At present, the system has been used for research and has access to a large number of experimental data which provides a foundation for carrying out deeper data analysis in the further.
ACKNOWLEDGEMENTS
The project is supported by the special fund for basic scientific research of central colleges of Chang’an university (No.CHD2011TJ02, No.CHD2011TD006) and by the Shaanxi province natural science foundation research project (No. 20110476).
REFERENCES
[1] DUAN Ji-yang, LI Zhi-zhong, “A Review on Driving Behavior Models,” China Safety Science Journal, vol. 22, pp. 30-36, February 2012.
[2] XIANG Wang, YAN Xue-dong, WANG Jiang-feng,
“Driving simulator application on research factors affecting driving behavior and the psychological,”
Shandong Science, vol. 6, pp. 125-132, Decemeber 2013.
[3] HU Ding-jun, ZHANG Qian, “The Control System Design of Vehicle Driving Simulator,” Journal of Microcomputer Information, vol. 2, pp. 233~234, February 2008.
[4] HE Ning, ZHAO Zhi-guo, ZHU Yang, “The Development of Simulation System for Prototype Vehicle based on TORCS Platform,” Journal of Manufacture Information Engineering of China, vol. 4, pp. 37-41, April 2010.
[5] ZHANG Jun-you, JIAO Xue-jian, CHAI Shan, “Design and Implementation of Vehicle Driving Simulator based on Virtual Reality,” Journal of Machinery Design&Manufacture, vol. 4, pp. 39-41, April 2013.
[6] WEI Chun-yu, “Joint Simulation Technology Research on Vehicle Dynamics and Six Degree of Freedom Platform,”
Zhejiang University, 2013.
[7] Onieva, E. Pelta, D. A. Alonso, J. Milanes, “A Modular Parametric Architecture for the TORCS Racing Engine,”
Journal of Computational Intelligence and Games, vol. 6, pp. 256-262., June 2009.
[8] Sarah Omar Al-Humoud, Lewis M. Mackenzie, “The Dynamic Counting Broadcast in Vehicular Networks”
Journal of Computers, vol. 8, pp. 3298-3304, December 2013.
[9] CHEN Xiu-feng, QU Da-yi, LIU Zun-min, “Study on Fog Driving Characteristics based on the Driving Simulator,”
Journal of Wuhan University of Technology (Transportation Science & Engineering), vol. 4, pp.
763-766, April 2013.
[10] Yating Yuan, Yi Zhuang, Ying Huo, “Research and Application of Data Integration in Aircraft Designing Based on SDO,” Journal of Software, vol. 9, pp. 689-696, March 2014.
[11] DaveCrolla, “Vehicle Dynamics and Control,” China Communications Press, 2013.
[12] FANG Ze-ping, DUAN Jian-min, “Research on Cyborg X Rocker Flying Data Acquisition Based on VB,” Journal of Zhongyuan University of Technology, vol. 1, pp.
326-331, January 2014.
[13] WANG Ying, LIAO Ke-bing, ZHANG Wei,
“Application of Driving Simulation System on Testing Driver’s Reaction to Road Hazards,” Journal of System Simulation, vol. 23, pp. 1251-1277, June 2012
[14] Stephen J. Chapman, “MATLAB Programming,” Science Press, 2007
[15] YU Zeng-liang, “Study on the Driver Critical Reaction Capability upon Simulative Environment,” Jilin University, 2005.
Yi Han, Shaanxi, 01/04/1975, Doctor degree of Aerospace Manufacturing Engineering, Northwestern Polytechnical University, Shaanxi, China, 2003. The main research directions are Intelligent Vehicles, Vehicle Electronic Control System and Image Processing.
He has been working in Chang’an University since graduated from Dr. Now, the title of technical post is associate professor.
Yuan Yao, Gansu, 06/02/1988, the Master graduate student of Chang’an University, the major is vehicle engineering.
Hai-yang Liu, Shandong, 10/06/1989, the Master graduate student of Chang’an University, the major is vehicle engineering.