Electrical – Measuring vehicle’s forward and lateral acceleration using a smartphone

accelerometerautomotivegpssensor

I want to measure the acceleration (forward and lateral separately) using an android smartphone device in order to be able to analyse the driving behavior.

My approach would be as follows:

1. Aligning coordinate systems

Calibration (no motion / first motion):
While the car is stationary, I would calculate the magnitude of gravity using Sensor.TYPE_GRAVITY and rotate it straight to the z-axis (pointing downwards assuming a flat surface). That way, the pitch and roll angles should be near zero and equal to the angles of the car relativ to the world.

After this, I would start moving straight forward with the car to get a first motion indication using Sensor.TYPE_ACCELEROMETER and rotate this magnitude straight to the x-axis (pointing forward). This way, the yaw angle should be equal to the vehicle's heading relativ to the world.

Update Orientation (while driving):
To be able to keep the coordinate systems aligned while driving I am going to use Sensor.TYPE_GRAVITY to maintain the roll and pitch of the system via

enter image description here

enter image description here

where A_x,y,z is the acceleration of gravity.

Usually, the yaw angle would be maintained via Sensor.ROTATION_VECTOR or Sensor.MAGNETIC_FIELD. However, the reason behind not using them is because I am going to use the application also in electrical vehicles. The high amounts of volts and ampere produced by the engine would presumably make the accuracy of those sensor values suffer. Hence, the best alternative that I know (although not optimal) is using the GPS course to maintain the yaw angle.

2. Getting measurements

By applying all aforementioned rotations it should be possible to maintain an alignment between the smartphone's and vehicle's coordinate systems and, hence, giving me the pure forward and lateral acceleration values on the x-axis and y-axis.

Questions:

  • Is this approach applicable or did I miss something crucial?
  • Is there an easier/alternative approach to this?

Best Answer

You don't need to worry about the magnetic sensors in electric vehicles: vehicle chassis will shield your phone from fluctuations in magnetic field due to the current between the battery and the motor. But, there will be bias due to the chassis that is constant and that you will not be able to measure using inertial sensors (meaning accelerometer, gyro, compass). To make things even worse, compass is very noisy and large heading errors are common.

As for the gravity sensor, you cannot use it to observe heading: if you have a vector to the gravity center of earth you can fix two axes (pitch, roll), but not the heading (yaw).

You could use gyroscope to measure pitch, yaw and roll. Gyro measures rate of change of these three angles. Hence by integrating the samples you can, theoretically, get heading. However, this needs correct initial alignment and the errors in the sensor data are unbounded as they will be adding with each new sample. Practically speaking, your heading estimates will be easily shifted by 180 degrees within few seconds. Yes, inertial sensors in our phones are that bad.

What offers solution here is GNSS (GPS, GLONASS or GALILEO). You can use it to periodically correct the heading, but this will work only when the vehicle is moving. It will be useless at slow speeds. The integration of heading from gyroscope and from GNSS can be done optimally using Extended Kalman Filter. If you don't know what that is, trying to understand it might cause you quite a headache.

Another solution is via maps - in the 90's map-matching methods were used to enhance precision of GPS since selective availability was still at use (precision of civilian GPS was artificially degraded). You can do something similar: use map-matching to identify road on which the vehicle is traveling and then use its heading to correct your heading estimates. Note that this will not work around intersections.

Good read about inertial sensors and integrated navigation is by Groves P.D. Principles of GNSS, inertial, and multi-sensor integrated navigation systems (Artech, 2008); ISBN 1580532551