For the actual measurement of tram speeds we used two methods:

  • Use the accelerometer data and integrate
  • Use the GPS on the phone and get the speed from that measurement

To get an acceptable result we needed to combine these two measurements, as sometimes the GPS is quite inaccurate, and sometimes the integration from the accelerometer drifts off.

For the accelerometer we then also made a couple of assumptions (based on measurements of data on the tram and testing the App in progress):

  • The tram mainly moves forward, so we only take into account one axis of acceleration for the integration. This ensures that we don’t get additional noise from three different axes, but of course limits the way in which you can mount the phone.
  • When the tram moves, the “sideways axis” and the gravity axis of acceleration shakes quite a bit, when the tram is standing still, this vibration is not present. We can use this to detect whether or not the tram is moving or not. When the tram is not moving, we can make sure that the calculated speed goes to zero, and thus reset the integration constant
  • When the tram is standing still, we also reset the offset of acceleration, to account for any kind of drift of the sensor itself over time.
  • When the tram is on an incline or decline (a hill, a bridge, or going down into a tunnel), we get a bit of an offset so we need to compensate for this.

This added to a couple of other things like calculating means and standard deviations over a certain time window, taking a moving average, resulted in the final App, which can be downloaded from github:

Settings which worked best with the Samsung Galaxy S2 phones:

Sensor: accelero
Forward axis: Y
Sideways axis: Z
Gravity axis: X
Window size: 200 Delta time: 10
Gravity Tresh: 0.05 Gravity MA: 0.8
Still forward: 0.06 Still side: 0.06
Motion forward: 0.1 Motion side: 0.06
Accel std: 0.2 Accel mean: 0.1
Decel std: 0.3 Decel mean: -0.1
Mean weight: 0.95 Raw weight: 0.05
Offset MA: 0.999 Speed decay: 0.99
Mean MA: 0.99 Prec. MA: 0.2


For the City Velocities – Body Speeds project, we needed to measure the speed of trams that move through the city.

Because a smart phone has a couple of sensors built-in and is capable of uploading data to a remote server, we chose Android as a base platform to work with. However, we needed to find out which phone had the best sensors to do this, i.e. which phones had sensors that were most accurate.

By making a call for help where we asked people to run a program on their phones and send us back the information on the sensors in the phone that the program reported, we got a reasonable overview of which sensors are in which phone, and their accuracy.

The results are listed in the two pdf’s down here:

Overview Android Sensors

Accelerometer characterics

© 2012 STEIM R&D Suffusion theme by Sayontan Sinha