Estimating Real-Time Vehicle Velocity from low-frequency GPS, accelerometer, gyro and magnetometer in Smartphone I am trying to write a system that would be able to estimate the velocity of a traveling vehicle (usually a car) using a smartphone. Most smartphones have the next sensors:


1Hz Low-Frequency GPS
10-100Hz Accelerometer
10-100Hz Gyroscope
10-100Hz Magnetometer


I would also impose a limitation, that device must be in either portrait or landscape position, relative to vehicle's direction of travel.

Now, the GPS will tell me speed and position once per second, but I would like to estimate the velocity in time between GPS data comes in, up to 10-100 times per second, for which I would like to use other sensors. The speed should be accurately represented, even if the car is decelerating.

For now, I've implemented Kalman filter which fuses together GPS, accelerometer and gyroscope and estimates the velocity. But the biggest problem becomes the deceleration, as in all usual references I could find, only the absolute velocity from all axes is taken into consideration.

How to approach this problem? Am I even correct in using Kalman? How to get correct deceleration? What if vehicle is cornering?

Thank you for your help!
How to approach this problem? Am I even correct in using Kalman? 


Yes, a Kalman filter (or a derivative) is correct.  Rotations are involved, and 3D rotations are highly nonlinear, so you'll pretty much have to use an extended Kalman or an unscented Kalman.

The basic approach is to model the vehicle motion as position, velocity, and angle driven by the IMU output, with the phone position estimate being corrected by the GPS.

You can correct the phone orientation estimate with the magnetometer, but then you need to take into account the various compass offsets.


  How to get correct deceleration? What if vehicle is cornering?


That will pretty much fall out of the Kalman solution.  As a plus, the phone's orientation with respect to the vehicle will only matter to the extent that you need to know where the vehicle is pointing, and that should be a pretty easy, fixed transform.