7

I am trying to detect if a car did accelerate or did brake by using the accelerometer of the iPhone.

In the figure below I plotted the collected data. (To collect the data the phone was laying flat in the car facing the top of the phone to the front).

The issue I am having now is that visually I can clearly see where the car accelerated and where it did brake (see below). But can't figure out how to do that programatically.

What I basically want is to know how often a car did brake or accelerate during a certain time window. (Window size around 10-30 seconds).

Any help would be highly appreciated.

Thanks in advance! Acceleration | Braking of a car

riik
  • 171
  • 3
  • What is the unit on the $x-\text{axis}$ ? – Gilles Aug 19 '14 at 22:23
  • The unit of the x axis is time. I sampled with 60 Hz. So the values on the x axis divided by 60 would represent seconds. – riik Aug 20 '14 at 06:56
  • Okay it's the number of samples. One way would be getting a sliding window of the size you're suggesting and putting conditions on the mean and variance of the collected samples , if necessary adding conditions on zero crossing intervals. But if you do the analysis without the short-time windows, can't the number of rising edges of the activity signal (blue signal) give you how many times you've accelerated, and falling edges for breaking ? – Gilles Aug 20 '14 at 08:04
  • The blue line only indicates if the car is moving or is not moving at all (full stop). For example between 4000 and 6000 the car was breaking but didn't come to a full stop. But I also want to register these kind of breaks. Can you maybe give an example of such a condition? – riik Aug 20 '14 at 09:53
  • This will seem pedantic, but in the long run it should help you when you are e.g. using Google to search for relevant material on this subject: it's "brake", not "break" - the verb "to break" means "to make kaput", which is a very different meaning than "to brake", as in to slow a vehicle! ;-) – Paul R Aug 20 '14 at 13:13
  • 1
    @PaulR thanks for the clarification! I just updated the question accordingly. – riik Aug 20 '14 at 13:23
  • Maybe I'm missing something but why can't you use the piecewise constant speed signal? It very clearly shows where the acceleration is positive and where it is negative. – Matt L. Aug 20 '14 at 13:46
  • @MattL. you are right about that. However, the speed signal is just for illustrational purposes (derived form GPS Data). For my project I just want to use the accelerometer data to detect acceleration and braking. – riik Aug 20 '14 at 14:42
  • 2
    OK, if you use the accelerometer data, you could in principle just use the sign of the acceleration (- for braking, + for accelerating). The problem is the noise. Probably you can sufficiently increase the SNR by using a Savitzky Golay filter. – Matt L. Aug 20 '14 at 15:53

3 Answers3

1

You should consider doing an STFT on the accelerometer signal. This will allow you to visualize the frequency of the signal. If you can determine the frequency of the brakes, you should be able to set a threshold for that specific braking frequency and count each time it is exceeded. You would also be able to measure how long the braking occurs.

How are you processing your signal? Matlab and python have the specgram function, which will allow you to see the actual frequency braking. From there you will be able to determine the brake frequency as well as a threshold.

1

When brakes are applied, the acceleration along the direction of motion will reverse sign. For example, if you position your phone such that the z-axis of the accelerator is in the direction of gravity axis(i.e. facing earth), then the acceleration along z-axis is -g. One the other hand if the negative z-axis is aligned with g, then z-axis of accelerometer measures +g. This is analogous to the scenario of a car accelerating and braking, although magnitude of deceleration is a little lower than acceleration. You can start by defining the reference axis as the g-axis and defining the other 2 axes based on direction of least and maximum acceleration, using a rotation matrix. You basically change the reference axis from x,y,z co-ordinates which is based on orientation of the phone to an stationary g,a,s reference system (where g is gravity axis, a is direction of maximum acceleration and s stationary axis). You can also use a gyroscope to achieve this axis rotation as discussed in this page. One you are able to view to the accelerometer daya in the transformed axes, you can easily classify regions of acceleration and deceleration based on signal from just one axis regardless of the orientation of the phone by looking for zero crossings.

Naveen
  • 418
  • 6
  • 21
1

You should know the orientation of the phone because the axis signum must be the same of the car motion. Assuming the axis signum is correct you can filter the accelerometer signal in lowpass, to clean the high frequency noise and then see the signal signum to detect if it is a break $a(t_i)<0$ or an acceleration $a(t_i)>0$.

You should try to filter with a butterworth low pass of the second or third order with a low frequency for example $10Hz$ or also less, you should try some cut frequencies looking the graphic.

Andrea
  • 539
  • 4
  • 12