A Model Based Vehicle Detection and Classification Using Magnetic Sensor Data JUN XING QI ZENG Department of Signals and Systems Chalmers University of Technology Göteborg, Sweden, 2007 EX075/2007 1 A Model Based Vehicle Detection and  Classification Using Magnetic Sensor Data  MASTER THESIS Jun Xing Qi Zeng Supervisor: Erik Ström Mikael Coldrey Examiner: Erik Ström Chalmers University of Technology Department of Signals and Systems Report EX075/2007 2007-08-28 2 3 Contents   Abstract .......................................................................................................................... 4  1 Introduction ................................................................................................................. 5  2 Experiment Description .............................................................................................. 6  2.1 Sensor ............................................................................................................... 6  2.2 Labview Program ............................................................................................. 6  2.3 Experiment Setup ............................................................................................. 8  3 Noise ......................................................................................................................... 10  3.1 Overview ........................................................................................................ 10  3.2 Comparisons .................................................................................................. 10  3.3 Analysis of distribution .................................................................................. 13  3.3.1 Module ................................................................................................ 13  3.3.2 Grouping ............................................................................................. 13  3.4 Calculating Threshold .................................................................................... 15  4 Model ........................................................................................................................ 18  4.1 Model Overview ............................................................................................ 18  4.2 Estimation ...................................................................................................... 19  4.2.1 Theory ................................................................................................. 19  4.2.2 Velocity Estimation ............................................................................. 21  4.2.3 Model Estimation ................................................................................ 26  4.2.4 Center Point Estimation ...................................................................... 28  4.2.5 Experiment Result ............................................................................... 31  5 Classification............................................................................................................. 35  5.1 Overview ........................................................................................................ 35  5.2 Divide by octants ........................................................................................... 35  5.3 Divide by Z-Axis ........................................................................................... 37  5.3.1 General ................................................................................................ 37  5.3.2 Analysis on Exceptions ....................................................................... 38  5.4 Summary of Classification ............................................................................. 38  6 Conclusion and Suggested Future Work ................................................................... 40  7 References ................................................................................................................. 41  4 Abstract This thesis will describe an algorithm and experimental work for vehicle detection and classification using magnetic sensor data. The ideas are presented in the context of treating vehicle as a combination of magnetic dipoles. The key steps in this project include noise measurement, velocity estimation, model estimation and classification. Algorithms for various tasks are discussed with an emphasis on velocity and model estimation. Results based on experiments with real data are also reported. 5 1 Introduction In the future, making traffic flows more efficient will be of even greater importance. By controlling the traffic (cars, trucks, motorcycles, etc.), both travel time and negative impact on the environment can be reduced. However, efficient control requires cost-efficient and accurate estimation of traffic parameters, such as the number of vehicles passing a certain point per unit time, the current speed of vehicles, and their types. We believe that the estimation can be based on data collected from magnetic sensors placed close to the road. A vehicle is built up of several types of magnetic materials; soft magnetic materials with no residual magnetization but with high magnetic susceptibility and hard magnetic materials with high residual magnetization. All of these materials in the vehicle create a disturbance in the earth magnetic field when the vehicle passes a specific region. When we place a magnetic sensor system with high enough field sensitivity and resolution in this region, it is possible to detect the vehicle. Different types of vehicles create a specific magnetic pattern due to different types of magnetic material, different amounts of magnetic material and of course different dimensions of the vehicles. Then we can figure out different types of vehicles for instance motorcycles, cars and trucks, not individual cars. This report consists of five main parts, Experiment Description, Noise, Velocity Estimation, Classification, and Conclusion. In the part of Experiment Description we will briefly introduce the magnetic sensor we use and how our experiments were performed. In the Noise part we will analyze the background noise of our experiments and decide the vehicle presence rule. The Velocity Estimation part will give an algorithm of estimation of vehicle speed. In the Classification part, a preliminary classification rule will be introduced, on which future work may be based. Finally, the Conclusion is a summary of our work, with some suggested future work in this field. 2 E 2.1 Acc Hon The mag thre to m outp conv 2.2 A L Exper 1 Sensor cording to [ neywell, HM e Honeywe gnetometer ee of Honey measure the puts are co verter. 2 Labvie Labview pro riment r  [1], we hav MR 2300. T Fig ell HMR23 to detect th ywell’s mag e X, Y and onverted to F ew Prog ogram has b t Descr ve decided The features ure2.1 Featu 300 shown he strength gneto-resisti d Z vector 16-bit dig Figure2.2 Ho gram  been written ription to use a th of this sens ures of Hone in figure and directio ive sensors component gital values oneywell HM n by IMEG n hree axis AM sor are show ywell HMR2 e 2.2 is a on of an in are oriente ts of a mag s using an MR2300 senso GO for us to MR magnet wn in figure 2300 three-axis cident mag ed in orthog gnetic field internal de or o use. The tic sensor f e 2.1. s smart di gnetic field. gonal direct d. These se elta-sigma interface of 6 from gital The tions ensor A/D f the 7 program is shown in figure 2.2 and 2.3, on which we can adjust different settings within the capability of HM2300 sensor, such as sample rate, display range and sample gain. Figure 2.3 Labview program interface for HM2300 sensor, setup page When the measurement is started, we first come to setup page and choose sample rate and zero drifting – zero drifting is a function to compensate the influence of the background magnetic field noise – then press “setup HMR”. This is to connect the program with sensor. If connection succeeds, the light on the “setup HMR” will come dark and the text in “setup status” will display the parameters we just set. Then we can come to control panel page to press “start measurement” button to start the measurement. Once the data are obtained by the sensor, the screen will display the wave shapes of the data of different dimensions. When the “Start saving” button is pressed, a text document will be saved with all data gained until “Stop Measurement” is pressed. 8 Figure 2.4 Labview program interface for HM2300 sensor, control panel page 2.3 Experiment Setup  The places we choose to implement our experiment are on Gibraltar Gatan, beside Chalmers main library and Sven Hultins Gatan beside V-Huset. Figure2.5 vehicle and sensor orientations z reverse forward vehicle distance magnetic sensor x y 9 Figure2.6 a picture of doing experiment In our experiment, we set the direction perpendicular to the street, pointing to the vehicle is x axis, the direction along the vehicle driving direction is y axis, and the direction pointing vertically is z axis. Below is an introductive picture of the magnetic changes when a car passes by the sensor from opposite directions [2], [3], [4], in which the speed is slower for the reverse direction. Different peaks come out when the engine passes the sensor. The symmetry of the curve is also noticeable. The sensor here is 30cm above ground and 30cm away from the car. Figure2.7 the magnetic variations of three axes of a car travelling opposite directions 10 3 Noise 3.1 Overview  The purpose of this section is to find a way of defining the threshold of background noise, so as to judge the appearance of vehicles. When measuring the noise, we chose the road in front of the Chalmers library and the road in front of EDIT building, Chalmers. The tests were mostly taken in the evening, when there is seldom any traffic. In the early experiments we were always bothered by the sampling rate, which did not reach our request: 100 records per second (rps for short). After about two months we found out the reason by chance: the Labview software was not able to display 100rps but only about around 35 rps on the screen, which jammed the un-displayed data at the com1 port from transmitting into the software continuously, resulting in the sampling rate falling far behind our expectation. In addition, the jammed data caused a more severe problem: when the data were accumulated to a certain number, they would be released by the software at the same time. This even affected our test results on vehicles: there was often an abnormal peak within the range of the vehicle signal. Eventually we found a way to solve this problem, which was to give up the display function. This way we were mainly using the data recording function of the program, and then the sampling rate became 100rps. After this problem was solved, correct measurements were taken for several times. 3.2 Comparisons  Plots of three typical measurements are shown below. The blue, green and red line represent for x, y and z axis respectively. 11 Figure 3.1 magnetic flux versus time, noise1 Figure 3.2 magnetic flux versus time, noise2 0 1 2 3 4 5 6 x 105 -350 -300 -250 -200 -150 -100 -50 0 50 100 150 time(sec) m ag ne tic fl ux (W b) x axis y axis z axis 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 x 105 -200 -150 -100 -50 0 50 100 150 time(sec) m ag ne tic fl ux (W b) x axis y axis z axis 12 Figure 3.3 magnetic flux versus time, noise3 We took three experiments at different places and in different time, for about one hour for each time. The results of three axes are shown in the table. 1 2 3 meanBx 50.31 38.48 106.5 meanBy -92.38 21.58 90.31 meanBz -176.9 -29.59 -252.0 varBx 847.3 848.0 2802 varBy 440.3 291.2 459.2 varBz 1953 1468 1789 Table 3.1 sample means and variances of three axes, measuring time about 1 hour Besides, we also studied the magnetic flux on three axes when taking shorter time measurements. Below is the table of measurements of one minute’s time, and the measurements were taken randomly in different days at the same place. From the table we can see the magnetic flux of three axes vary irregularly. 1 2 3 4 5 6 7 8 meanBx 17.78 -22.13 41.60 -23.05 61.61 43.67 21.70 23.64 meanBy 91.82 -31.20 117.1 87.57 114.4 77.82 56.31 73.29 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 x 105 -400 -300 -200 -100 0 100 200 300 400 time(sec) m ag ne tic fl ux (W b) x axis y axis z axis 13 meanBz -189.1 -2.048 -145.7 -42.91 -156.6 -137.2 -167.7 -186.4 varBx 174.7 2698 616.0 1255 827.9 419.6 1258 95.52 varBy 201.5 1800 939.7 288.2 485.2 392.8 546.9 61.54 varBz 593.6 5590 3303 4240 3109 1081 1004 458.9 Table 3.2 sample means and variances of three axes, measuring time 1 minute 3.3 Analysis of distribution  3.3.1 Module  The histogram of the module, the squared sum (x, y and z axes), of each point of the noise compared with normal distribution, is depicted in Figure 3.4. Figure 3.4 Module of all data points of noise As is shown in the plot, this module is not well matched with a normal distribution. 3.3.2 Grouping  If grouped with 100 samples adding together, the x, y and z axes’ noises can only poorly fit the normal distribution, the histograms of which are shown below: 0 2 4 6 8 10 12 14 x 10 4 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 x 10 -4 Data D en si ty sqrr data fit 1 14 Figure 3.5 histogram of y-axis grouping plot compared with normal distribution Figure 3.6 histogram of x-axis grouping plot compared with normal distribution Figure 3.7 histogram of z-axis grouping plot compared with normal distribution -14000-12000-10000 -8000 -6000 -4000 -2000 0 2000 4000 6000 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 x 10-4 Data D en si ty sumy data fit 1 -1.5 -1 -0.5 0 0.5 1 x 10 4 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 x 10-4 Data D en si ty sumx data fit 2 -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 x 104 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 x 10-4 Data D en si ty sumz data fit 3 15 When adding the three axes together, we found the distribution of the result fits the normal distribution fairly well, as shown below: Figure 3.8 histogram of three axes grouping plot compared with normal distribution Though figure 3.8 shows a good fit to normal distribution, this way of dealing with the noise data is still unacceptable. The reason is, if we want to find out a vehicle’s presence, we have to group all the data points of the vehicle like what we have done above, and compare it with figure 3.8 to make sure a vehicle appears. But the problem is, when is the vehicle’s starting point? Now we have come back to the initial question: the threshold. The threshold should be a number that can be used directly for the judgment. 3.4 Calculating Threshold  After the unsuccessful analysis above, we decided to focus on the changing rate of the noise. Therefore, we differentiated the noise samples we had, and the density function is shown below. -3 -2.5 -2 -1.5 -1 -0.5 0 0.5 x 104 0 0.5 1 1.5 x 10-4 Data D en si ty sum data fit 4 16 Figure3.9 density function of a noise sample, x axis Figure3.10 density function of a noise sample, y axis -30 -20 -10 0 10 20 30 0 1 2 3 4 5 6 7 8 Data D en si ty -20 -15 -10 -5 0 5 10 15 20 0 1 2 3 4 5 6 7 8 9 10 Data D en si ty n3(:,3) data 17 Figure3.11 density function of a noise sample, y axis Figure 3.12 density function of a noise sample, module From the figures above, we notice from the density function that, nearly 90% of the differentiated data are zero, and the largest result is no more than ±30. Therefore we set our threshold as 30, which means when the changing rate of the magnetic flux is larger than 30, the vehicles is judged to appear. -20 -15 -10 -5 0 5 10 15 20 25 30 0 1 2 3 4 5 6 7 8 9 10 Data D en si ty -1.5 -1 -0.5 0 0.5 1 1.5 x 104 0 1 2 3 4 5 6 7 x 10-3 Data D en si ty 4 M 4.1 The mag whe as c (bot appr mag Let veh mag had the Model 1 Model e magnetic gnetic dipol ere ߤ଴ is th consisting o th in magni roximated gnetic objec us assume icle can be gnetic field informatio vehicle. In l l Overvie field, ܤపሬሬሬԦ le to the fixe he magnetic of N individu tude and di with the s ct. The total that a vehic e pictured in a specifi on on the str this case w ew  from a ma ed sensor co పሬሬሬԦܤ ൌ ଴ߤ ߨ4 c permeabili ual magnet rection) the superpositio magnetic o ሬԦܤ ൌ ଴ߤ ෍ߨ4 ே ௜ୀ Figure 4.1 cle can be tr as built o ic position c rengths and we must also agnetic dip oordinate sy ߨ 3ሺߤపሬሬሬԦ · పሬሬԦݎపሬሬԦሻݎ |పሬሬԦݎ| ity of free s ic objects e e total magn on of the m object is bui ෍ 3ሺߤపሬሬሬԦ · ሬݎపሬሬԦሻݎ ሬݎ| ே ୀଵ 1 sensor-vehi reated in the f magnetic can be calcu d directions o assume th ole, ߤపሬሬሬԦ, at ystem positi െ పሬሬԦ|ଶݎ|పሬሬሬԦߤ ହ pace. If a m each with a netic field at magnetic fi ilt up of, acc పሬሬԦݎ െ పሬሬԦ|ଶݎ|పሬሬሬԦߤ పሬሬԦ|ହݎ icle system e same way c dipole mo ulated using of each of hat the magn a position ion can b e magnetic obj specific ma t a specific fields from cording to: y, i.e., that m oments [1] g the equati f the magne nitude and n, ݎపሬሬԦ, from expressed b ject can be agnetic mom position ca the indivi magnetically , [5], then on above, i etic moment direction of 18 m the by: seen ment an be idual y the n the f we ts of f the 19 magnetic moments with respect to the vehicle is not changing when passing the magnetic sensor system (which is a good assumption). When the vehicle is moving relative to the magnetic sensor system, the position vector, ݎపሬሬԦ, will be time dependent. Probably it will be easier to work with two coordinate systems; one fixed to the sensor system and one fixed to the center point of the moving vehicle. In that case the individual magnetic moments building up the vehicle will be constant both in position and direction relative to moving vehicle coordinate system. Figure 4.1 shows schematically the sensor system and the vehicle with the distribution of individual magnetic moments (only six magnetic moments are shown). 4.2 Estimation  4.2.1 Theory  In this part, we study the widely used three estimation algorithms: Minimum Variance Unbiased Estimation (MVU), Maximum Likelihood Estimation (MLE) and Least Squares (LS), then finally give the most appropriate way solving the model. In all the three methods, we assume the obtained signal,  xሾnሿ ൌ  sሾn, θሿ ൅  wሾnሿ where θ is the unknown parameter vector and w[n] is some unknown noise. Minimum Variance Unbiased Estimation (MVU)[:  The Cramer-Rao Lower Bound (CRLB) gives a lower bound [6] on the error variance of the MVU estimate which is: varሺθሻ ൒ 1 െE ൤∂ ଶ ln pሺx; θሻ ∂θଶ ൨   where it is assumed the PDF pሺx; θሻ satisfies the condition: E ൤ ∂ ln pሺx; θሻ ∂θଶ ൨ ൌ 0 However, this lower bound cannot be reached in most cases, so Rao-Blackwell-Lehmann-Scheffe (RBLS) gives a method using Sufficient Statistic to find the MVU estimator. In statistics, a statistic is sufficient for the parameter θ, which indexes the distribution family of the data, precisely when the data's conditional probability distribution, given the statistic's value, no longer depends on θ. The Neyman-Fisher Factorization theorem shows that if the PDF pሺx; θሻ can be 20 written as pሺx; θሻ ൌ gሺTሺxሻ, θሻhሺxሻ Where g is a function depending on x only through T(x) and h is a function depending only on x, then T(x) is a Sufficient Statistic for θ. Conversely, if T(x) is a sufficient statistic for θ, the PDF can be factored as in the equation above. After deciding the Sufficient Statistic, we can use RBLS to find the MVU estimator. If θෘ is an unbiased estimator of θ  and T(x) is a sufficient statistic for θ, then θ෠ ൌ E൫θෘ|Tሺxሻ൯ is the MVU estimator. Maximum Likelihood Estimation (MLE):  Maximum Likelihood Estimation is an alternative to the MVU estimator, which is desirable in situations where the MVU estimator does not exist or cannot be found even if it exists. This estimator, which is based on the maximum likelihood principle, is overwhelmingly the most popular approach to obtaining practical estimators. Assume ωሾnሿ is WGN with unknown varianceθ pሺx; θሻ ൌ 1 ሺ2πθሻ N ଶ exp ൥െ 1 2θ෍ ሺxሾnሿ െ θሻଶ Nିଵ ୬ୀ଴ ൩ Considering this as a function ofθ, it becomes the likelihood function. Differentiating the log-likelihood function, we have ∂ ln pሺx; θሻ ∂θ ൌ െ N 2θ ൅ 1 θ෍ ሺxሾnሿ െ θሻ ൅ 1 2Aଶ Nିଵ ୬ୀ଴ ෍ሺxሾnሿ െ θሻଶ Nିଵ ୬ୀ଴ And setting it equal to zero produces θ෠ଶ ൅ θ෠ െ 1 N෍ xଶሾnሿ ൌ 0 Nିଵ ୬ୀ଴ Solving for A෡ produces the solution θ෠ ൌ െ 1 2 ൅ 1 N ඩ 1 N෍ xଶሾnሿ ൅ 1 4 Nିଵ ୬ୀ଴ Least Squares (LS):  A salient feature of the method is that no probabilistic assumptions are made about the 21 data, only a signal model is assumed. The advantage, then, is its broader range of possible applications. On the negative side, no claims about optimality can be made, and furthermore, the statistical performance cannot be assessed without some specific assumptions about the probabilistic structure of the data.   In LS approach we attempt to minimize the squared difference between the given data x[n] and the assumed signal or noiseless data. The signal is generated by some model which in turn depends upon our unknown parameter θ. The signal s[n] is purely deterministic. The LS estimator of θ chooses the value that makes s[n] closest to the observed data x[n]. Closeness is measured by LS error criterion: Jሺθሻ ൌ ෍ሺxሾnሿ െ sሾnሿሻଶ Nିଵ ୬ୀ଴ Conclusion:  The Minimum Variance Unbiased Estimation and Maximum Likelihood Estimation give an optimal or nearly optimal estimation by considering the class of unbiased estimators and determining the one exhibiting minimum variance. However, in many cases such as the project we meet here, the pre-knowledge of probability of the noise or parameters can be hardly known. So we choose the Least Squares method to estimate the vehicle model in this paper. 4.2.2 Velocity Estimation  The theoretical model listed above has a high complexity in solving the equation. Each dipole has six unknown parameters, three magnetic parameters  ߤ௫,   ,௬ߤ ,௭ߤ and three position parameters ݎ௫, ݎ௬, ݎ௭, where ݎ௫ ൌ ݒ · To simplify the estimation .ݐ procedure, we investigate the output signal from the sensor and give a novel way to determine the velocity. The proposed method in [7], [8] uses two sensor nodes with six feet apart along the lane. The speed of the vehicle is estimated as the ratio of the distance between the sensor nodes to the difference between the detection in two sensors. The sources of error in this estimation are the synchronization errors and the different sensitivity of the sensors. In this paper, we propose a single sensor based velocity estimation which will further simplify the sensor network system. 22 Theory  V ൌ L T Here, V is the vehicle velocity, L is the sensing length and T represents the duration of a vehicle passing by the sensor. The calculation of Duration T  The output of magnetic sensor Honywell HMR2300 has a data form of four columns represent the three position scalar and a time scalar. Once we determine the appearance and departure of vehicle from the signal, the duration T can be calculated by the time distance between these two points. Basing on the study of noise feature in chapter 3.3, we propose two algorithms listed below: a) Average Detection (AD)  The difference of noise signal (y[n] – y[n-1]) mostly concentrates in the area [-25, 25](Wb), that means once the difference of a signal grows higher than 30(Wb), we can announce a detection of the vehicle. In contrast, an absolute value of difference goes lower than 30(Wb), it means the departure of a vehicle. We also find the phenomenon that the appearance of a vehicle in three axes x, y, z does not happen simultaneously. That makes us calculate the duration in the three axes separately and average them to find a result. 23   Figure 4.2 The received signal for the sensor with velocity 40km/h   Figure 4.3 The result of Average Detection   b) Square Detection (SD)  The square detection algorithm calculates the square of each signal and adds them all together. The threshold of this difference sets as 25000 basing on the noise measurement from figure 3.12. 24   Figure 4.4 the result of Square Detection From the figure above, the Square Detection makes a better view in the cutting off of the origin signal; however, this also contains a period of trash signal in each axis since the algorithm does not take the different appearance in to account which will cause the duration longer then the method above. The Calculation of Sensing Length L  We performed ten experiments with velocity 30, 34, 40 and 60km/h, using the algorithms above, and estimated the Sensing Length by Least Squares. In the figures below, we can see the Average Detection gives a better overall performance in the ten experiments. 25 Figure 4.5 Velocity estimation by Average Detection Figure 4.6 Velocity estimation by Square Detection 26 4.2.3 Model Estimation  As long as we estimate the velocity, the freedom of magnetic model reduces to five parameters, and now, we give the Least Square procedure below in detail. Define: U ൌ ሾµ୶  µ୷  µ୸ሿT   R ൌ ሾ r୶  r୷  r୸ሿT   M ൌ ሾµ୶  µ୷  µ୸  r୷  r୸ሿT   Then the model can be written as B෡ ൌ µ଴ 4π 3RTUR െ URTR ሺRTRሻହ/ଶ Doing the Least Squares estimation for this equation: ∂∑ ൫B෡ െ B൯N ୬ୀିN ଶ ∂M ൌ ෍ ∂൫B෡ െ B൯ଶ ∂M N ୬ୀିN ൌ ෍ ൫B෡ െ B൯T N ୬ୀିN ሾ ∂B෡ ∂µ୶   ∂B෡ ∂µ୷   ∂B෡ ∂µ୸       ∂B෡ ∂r୷   ∂B෡ ∂r୸  ሿT ൌ ෍ ൫B෡ െ B൯T N ୬ୀିN ۏ ێ ێ ێ ێ ێ ێ B୶∂ۍ ෢ ∂µ୶ ∂B୶෢ ∂µ୷ ∂B୶෢ ∂µ୸ ∂B୷෢ ∂µ୶ ∂B୷෢ ∂µ୷ ∂B୷෢ ∂µ୸ ∂B୸෢ ∂µ୶ ∂B୸෢ ∂µ୷ ∂B୸෢ ∂µ୸      ∂B୶෢ ∂r୷ ∂B୶෢ ∂r୸ ∂B୷෢ ∂r୷ ∂B୷෢ ∂r୸ ∂B୸෢ ∂r୷ ∂B୸෢ ∂r୸ ے ۑ ۑ ۑ ۑ ۑ ۑ ې ൌ 0 ֜ ە ۖ ۖ ۖ ۖ ۖ ۔ ۖ ۖ ۖ ۖ ۖ ൫B୶෢ۓ െ B୶൯ ∂B୶෢ ∂µ୶ ൅ ൫B୷෢ െ B୷൯ ∂B୷෢ ∂µ୶ ൅ ൫B୸෢ െ B୸൯ ∂B୸෢ ∂µ୶ ൌ 0 ൫B୶෢ െ B୶൯ ∂B୶෢ ∂µ୷ ൅ ൫B୷෢ െ B୷൯ ∂B୷෢ ∂µ୷ ൅ ൫B୸෢ െ B୸൯ ∂B୸෢ ∂µ୷ ൌ 0 ൫B୶෢ െ B୶൯ ∂B୶෢ ∂µ୸ ൅ ൫B୷෢ െ B୷൯ ∂B୷෢ ∂µ୸ ൅ ൫B୸෢ െ B୸൯ ∂B୸෢ ∂µ୸ ൌ 0 ൫B୶෢ െ B୶൯ ∂B୶෢ ∂r୷ ൅ ൫B୷෢ െ B୷൯ ∂B୷෢ ∂r୷ ൅ ൫B୸෢ െ B୸൯ ∂B୸෢ ∂r୷ ൌ 0 ൫B୶෢ െ B୶൯ ∂B୶෢ ∂r୸ ൅ ൫B୷෢ െ B୷൯ ∂B୷෢ ∂r୸ ൅ ൫B୸෢ െ B୸൯ ∂B୸෢ ∂r୸ ൌ 0 Here, 27 Bన෡ ൌ ଴ߤ ߨ4 3ሺ்ܴ · ܷሻݎ௜ െ ௜்ܴܴߤ ሺRTRሻହ/ଶ     ݅ ൌ ,ݔ ,ݕ ݖ ە ۖ ۖ ۖ ۖ ۖ ۖ ۔ ۖ ۖ ۖ ۖ ۖ ۖ ۓ ∂B୶෢ ∂µ୶ ൌ ଴ߤ ߨ4 ௫ଶݎ3 െ ܴ ܴଶ.ହ ∂B୶෢ ∂µ୷ ൌ ∂B୷෢ ∂µ୶ ൌ ଴ߤ3 ߨ4 ௬ݎ௫ݎ ܴଶ.ହ ∂B୶෢ ∂µ୸ ൌ ∂B୸෢ ∂µ୶ ൌ ଴ߤ3 ߨ4 ௭ݎ௫ݎ ܴଶ.ହ ∂B୷෢ ∂µ୷ ൌ ଴ߤ ߨ4 ௬ଶݎ3 െ ܴ ܴଶ.ହ ∂B୷෢ ∂µ୸ ൌ ∂B୸෢ ∂µ୷ ൌ ଴ߤ3 ߨ4 ௭ݎ௬ݎ ܴଶ.ହ ∂B୸෢ ∂µ୸ ൌ ௭ଶݎ3 െ ܴ ܴଶ.ହ                       ە ۖ ۖ ۖ ۖ ۖ ۔ ۖ ۖ ۖ ۖ ۖ ۓ ∂B୶෢ ∂r୷ ൌ ଴ߤ3 ߨ4 ൫ߤ௬ݎ௫ ൅ ௬൯ܴݎ௫ߤ െ ௬ܳݎ௫ݎ5 ܴଷ.ହ ∂B୶෢ ∂r୸ ൌ ଴ߤ3 ߨ4 ሺߤ௭ݎ௫ ൅ ௭ሻܴݎ௫ߤ െ ௭ܳݎ௫ݎ5 ܴଷ.ହ ∂B୷෢ ∂r୷ ൌ ଴ߤ3 ߨ4 ൫2ߤ௬ݎ௬ ൅ ܳ൯ܴ െ ௬ଶܳݎ5 ܴଷ.ହ ∂B୷෢ ∂r୸ ൌ ∂B୸෢ ∂r୷ ൌ ଴ߤ3 ߨ4 ൫ߤ௭ݎ௬ ൅ ௭൯ܴݎ௬ߤ െ ௭ܳݎ௬ݎ5 ܴଷ.ହ ∂B୸෢ ∂r୸ ൌ ଴ߤ3 ߨ4 ሺ2ߤ௭ݎ௭ ൅ ܳሻܴ െ ௭ଶܳݎ5 ܴଷ.ହ Q ൌ ௫ݎ௫ߤ ൅ ௬ݎ௬ߤ ൅ ௭ݎ௭ߤ B is the measured data from the sensor. The equations can be solved by Matlab, due to the independence among those equations, we can only have three independent answer: µ୶ ൌ K ሺB୶r୶ଶ ൅ 3r୶r୸B୸ ൅ 3r୷B୷r୶ െ 2r୷ଶB୶ െ 2r୸ଶB୶ሻ√S 4π10ି଻  µ୷ ൌ K ሺെ2B୷r୶ଶ ൅ 3r୷B୶r୶ ൅ B୷r୷ଶ ൅ 3r୷r୸B୸ െ 2r୸ଶB୷ሻ√S 4π10ି଻ µ୸ ൌ K ሺ3r୷r୸B୷ െ 2r୷ଶB୸ െ 2r୶ଶB୸ ൅ 3r୸B୶r୶ ൅ B୸r୸ଶሻ√S 4π10ି଻ K = 6.2831853071795864769252867665590 S ൌ   r୶ଶ ൅ r୷ଶ ൅ r୸ଶ For the other 2 unknown parameters in this model, we run a loop procedure in the program searching for the minimum square error ∑ ሺB෡ െ BሻଶN ୬ୀିN 28 4.2.4 Center Point Estimation  The word center point refers to the point when the vehicle passing by the sensor. If the model has a 101 points LS estimation, from N = -50 to N = 50, the center point is set as N = 0. The accuracy of determining the central point will highly affect the estimation of the model. Different from what we might think before, the center point neither gives a peak value in Y or Z-axis, nor a zero cross in X- axis. Investigating the derivative of the model with respect to r୶ . Then set r୶ ൌ 0, we can have the formulas below: ∂ଶB୶ ∂r୶ଶ ൌ 9µ଴ 4π µ୶ ൫r୷ଶ ൅ r୸ଶ൯ ଶ.ହ ∂B୷ ∂r୶ ൌ 3µ଴ 4π µ୶r୷ ൫r୷ଶ ൅ r୸ଶ൯ ଶ.ହ ∂B୸ ∂r୶ ൌ 3µ଴ 4π µ୶r୸ ൫r୷ଶ ൅ r୸ଶ൯ ଶ.ହ Obviously, only if µ୶ ൌ 0 , we can make all the three equations equal to zero which is not possible in most applications. With a further observation of derivative of the model, we provide a theoretical solution for the center point as well as another two suboptimal methods which have good performances as well. Theoretical Solution (TS)  When r୶ ൌ 0, we investigate the three equations above together with the equation below: B୶ ൌ െ 3µ଴ 4π µ୶ ൫r୷ଶ ൅ r୸ଶ൯ ଵ.ହ It is not hard to get a new equation ሺ ∂B୷ ∂r୶ ሻଶ ൅ ሺ ∂B୸ ∂r୶ ሻଶ ൌ െ 1 3B୶ ∂ଶB୶ ∂r୶ଶ ֜ ሺ ∂B୷ ∂t ሻ ଶ ൅ ሺ ∂B୸ ∂t ሻ ଶ ൌ െ 1 3B୶ ∂ଶB୶ ∂tଶ 29 This equation gives a relationship among B୶, the derivative of B୷ B୸, and the second order derivative of B୶ with respect to r୶ in the center point. And the Theoretical Solution is to seek such point where rxሺt଴ሻ ൌ 0. It can be estimated by t଴ ൌ arg min ൝ቆ ∂B୷ ∂t ቇ ଶ ൅ ൬ ∂B୸ ∂t ൰ ଶ ൅ 1 3B୶ ∂ଶB୶ ∂tଶ ൡ Square Detection (SD) and Average Detection (AD)  Although the assumption that the center point presents in the peak of Y, Z axis and the zero crossing of X axis has proven to be wrong in the front of this chapter, it does not stop us making an investigation in the such algorithms which has a motivation to reduce the computing complexity. The following two algorithms are basing on the assumption and give an acceptable performance through the measurement. The idea of SD is to calculate the square summation of the three axes. According to the assumption, the center point will present in the peak of the summation. The procedure can be treated as arg max൛B୶ଶ ൅ B୷ଶ ൅ B୸ଶൟ Different from SD, the AD use only Y and Z axes instead of all the three axes. The center point can be located in the middle of the peaks of Y and Z axis.   Figure4.7 signal of X axis 30   Figure4.8 signal of Y axis   Figure4.9 signal of Z axis   Figure4.10 signal of square summation 31 Result and Conclusion  An experiment of 20 vehicles has been made according to the three methods mentioned above. The comparison is basing on the square error between the measurement signal and the estimated signal from the model. The Square Detection performs as well as the Theoretical Solution and better than Average detection. Due to the lower complexity in calculation, we prefer Square Detection in this project.   Figure4.11 Comparison among the three propose algorithms 4.2.5 Experiment Result    Two experiments are taken place in front of the V-building and behind the Chalmers library. One sensor node was placed aside the lane, 2 meters away from the middle of the lane. A total of 80 vehicles are measured, with 78 detected correctly and missing two motorcycles. 32 Figure4.12 Estimated vehicle magnetic curve, example 1 33 Figure4.13 Estimated vehicle magnetic curve, example 2 Figure4.14 Estimated vehicle magnetic curve, example 3 34 Figure4.15 Estimated vehicle magnetic curve, example 4 5 C 5.1 In t veh Bef set, octa 5.2 In o by t ther Classi 1 Overvi this section icles from t fore analyzin shown bel ants of the a 2 Divide our point of the 8 octan refore we ha ificatio iew  n, we will the data we ng the data low. The d axis set. e by octa f view, the m nts in the 3 ave four fig on try to sugg have got (U a, we first dr different sha Figure ants  most basic a 3-D axis se gures: gest a way Ux, Uy, Uz) raw all the apes and c e5.1 All data and intuition et. The veh of distingu from the pr data points olors in the a points nal way mig hicles are d uishing dif revious sect s out in a 3 e figure in ght be divid distributed i fferent kind tion. dimension ndicate diffe ding all the in four octa 35 ds of axis erent data ants, Figuree5.2 vehicle data points i in different o octants 36 How octa jeep 5.3 5.3 Afte z-ax veh It m from cann How foun also wever, whe ants, we fou ps or trucks. 3 Divide 3.1 Gene er several ti xis. We can icles by the might be qu m the above not find one wever, there nd almost a o some exce en we tried und they hav . So this wa e by Z­Ax ral  imes of tria n get a dire e following uite confusi e figure, bec e type obvio e is still str all big vehi eptions, whi to tell the ve no speci ay turned to xis  ls, we final ect impress figure: Figure5.3 ing to tell t cause some ously differe ructure insid icles’ Uz (je ich we will e difference ial common be not the r ly found ou sion on 2 d big and sma the differen of the point ent from the de. When d eeps or truc discuss belo e between t n features. In right directi ut it’s better different typ all vehicles nces betwee ts are overl e other. digging into cks) are lar ow. the vehicle n all cases t ion. r to classify pes – big en the two apping with o the specif rger than 1. s of these there exist c the vehicle and small types of po h each other fic vehicles .0E11. Ther 37 four cars, es by – of oints r, we , we re’re 38 5.3.2 Analysis on Exceptions  Big vehicles but Uz < 1.0E11  This kind of outliers appears sometimes, and we haven’t found supportive proof for this, but we believe it is due to the lack of our data on big vehicles, and perhaps some errors during processing the raw data. However, most of big vehicles can successfully be classified. Small vehicles but Uz > 1.0E11  This situation appears regularly, only happens when the vehicles are VOLVO cars, and they all looked very old. We can only suppose in early VOLVO cars, perhaps before VOLVO sold its car department to Ford, the engines inside VOLVO cars have some similarities with their truck or bus engines, which leads to our problem today. A picture of this situation is shown below. Figure5.4 an old VOLVO car 5.4 Summary of Classification  From the analysis above, we may draw our conclusion on classification. When doing classification, we should first take out those vehicles which Uz > 1.0E11. Except for the VOLVO cars, we can nearly 100% sure that the vehicles we take out are large vehicles. Then we pay our attentions to the remaining vehicles. According to our research, 80%-90% of the remaining ones are cars. 39 Regarding the error rate, 80%-90% of classification accuracy is acceptable. However, our research has its limited aspect; we can only go as far as the types of car and jeep/truck, no more specific. Maybe if we have the relevant data of all the engines, then we can make a more detailed classification, but that is outside the scope of this master’s thesis. So this can be left for a further study. 40 6 Conclusion and Suggested Future Work We have discussed different ways of analyzing the noise data we gained from experiments using magnetic sensors, and have given a means of defining the presence of vehicles. In the thought of considering the whole vehicle as a magnetic dipole, a model is set up to estimate the changing process of magnetic fields, which are used to represent for different vehicles. In this process, the vehicle velocity is able to be calculated by calculating duration time T and the sensing length L separately. The results of model estimation have been shown in the report and the errors have been kept in an acceptable range. The last part is a rough classification of the vehicles – large and small, by observing the three axes’ magnetic values. One possible continuation of our work might be the one we mentioned above, giving a more precise classification of vehicle types, which will need deeper investigation of the vehicles’ magnetic data and perhaps specific engines’ data. Another possible development of this report is to use multiple dipoles when doing model estimation. As the complexity of calculations will greatly increase when using more dipoles, and the time of doing this project is a limited period, we were unable to do any further research in our thesis work. 41 7 References [1] C. Jonasson, M. Erlandsson and C. Johansson, “Magnetic sensors for traffic detection,” IMEGO, Sweden, Technical Report, 2006. [2] M. J. Caruso, L. S. Withanawasam, “Vehicle detection and compass applications using AMR magnetic sensors,” in Sensors Expo Proceedings, 1999, pp. 477-489. [3] Honeywell Technical Staff, Vehicle Detection Using AMR Sensors, Application Note AN218, Honeywell, 2005. [4] A. Asaoka and S. Ueda, “An experimental study of a magnetic sensor in an automated highway,” in Proceedings of the IEEE Intelligent Vehicles Symposium, 1996, pp. 373-378. [5] T. Phan, B. W. Kwan and L.J. Tung, “Magnetoresistor for vehicle detection and identification,” in IEEE International Conference, 1997, pp. 3839-3843. [6] S. M. Kay, Fundamentals of Statistical Signal Processing: Estimation Theory, New Jersey, Prentice-Hall, 1993. [7] C. Y. Chan, “Magnetic sensing as a position reference system for ground vehicle control,” IEEE Transactions on Instrumentation and Measurement, vol. 51, pp. 43-52, February 2002. [8] S. Y. Cheung et al., “Traffic measurement and vehicle classification with a single magnetic sensor,” in Proceedings of the Annual Meeting of the Transportation Research Board, 2005, pp. 173-181.