Search code examples
androidgpsaccelerometer

The angle of direction without using GPS


It's possible to calculate direction of movement without using GPS?

My application is used in car and this app is connected to another device via BT. This device tells me 1x for 5sec our coordinates + direction angle.

/*direction angle = */ location.bearingTo(location);

But 1x / 5sec seconds is not enough. So I'd like to calculate the following coordinates :D it is possible to do it?

I have:

1. sec - speed, coordinates, angle
2. sec - speed, ?, ?
3. sec - speed, ?, ?
4. sec - speed, ?, ?
5. sec - speed, coordinates, angle

Coordinates can not be sent more frequently cause the hardware... and also I don't want to use GPS, cause battery...

I was hoping it would be done by using some sensors in android... maybe... (accelerometer or magnetic sensor etc.)

Thanks for your answers.

EDIT:

I have 2 devices

1. android phone with my app (app which i programm) - mobile in my pocket
2. other device writen in ASM by another programmer we can call him "parek" - fixed (static) device - build-in car.

My app is connected to "parek" via BT. "parek" have GPS module and he can tells me the coordinates & direction angle (but just 1x for 5 sec, no more).

"parek" can send me car speed 1x for 1 sec (this is not problem) but coordinates & direction angle he can't, cause hardware is old.

But my app needs coordinates every 1 sec, I can't & i don't want to use GPS in my phone (in my pocket, in car).


Solution

  • If your device is fixed relative to the car, you can extrapolate your coordinates after the last known fix using the previous known speed and input from the magnetometer.

    As you updated your question, if the device is not fixed then it's more difficult. You'd have to use some some sensor fusion algorithm that could adjust the speed calculation based on the accelerometer and gyro inputs, and (have a look at how Kalman filters work for example).

    The information from that algorithm could be correlated with previous GPS fixes in order to estimate the position of the device in relation to the car (think about what the magnetometer would read during, let's say, a right turn on the road if the phone is in the left pocket vs. if it's in the right pocket). Unfortunately, you don't have the comfort of knowing that the phone is always pointing straight forward through the windshield.