- #1
Syn
- 2
- 0
Hello everyone!
I am trying to write an app that needs to be able to tell if a vehicle is accelerating or breaking. In this sense I used the accelerometer in the phone. At the moment I managed to isolate and subtract the gravitational pull of the Earth from my readings and I am using a noise variable to ignore minor changes (smaller than 10^-2).
In order to compute the acceleration relative to the ground I am using the following formula sqrt(Lx^2+Ly^2+Lz^2), where Lx represents the linear acceleration along the x-Axis in m/s^2.
My problem is: How do I differentiate between braking and accelerating, as my final acceleration value will always be greater than 0 and the phone can change it's rotation in between measurements (i.e. X and Y axes changing places or anything inbetween). Also I need this to work even if the vehicle accelerates -> maintains speed -> brakes/accelerates some more.
I am guessing this can be solved by using the gyroscope in the phone, which reads the rotation along the 3 axes in rad/s. However I do not know the math and physics behind it and therefor find myself unable to implement it. Is my reasoning wrong? Have I made some false assumptions? Would another way be better?
I am trying to write an app that needs to be able to tell if a vehicle is accelerating or breaking. In this sense I used the accelerometer in the phone. At the moment I managed to isolate and subtract the gravitational pull of the Earth from my readings and I am using a noise variable to ignore minor changes (smaller than 10^-2).
In order to compute the acceleration relative to the ground I am using the following formula sqrt(Lx^2+Ly^2+Lz^2), where Lx represents the linear acceleration along the x-Axis in m/s^2.
My problem is: How do I differentiate between braking and accelerating, as my final acceleration value will always be greater than 0 and the phone can change it's rotation in between measurements (i.e. X and Y axes changing places or anything inbetween). Also I need this to work even if the vehicle accelerates -> maintains speed -> brakes/accelerates some more.
I am guessing this can be solved by using the gyroscope in the phone, which reads the rotation along the 3 axes in rad/s. However I do not know the math and physics behind it and therefor find myself unable to implement it. Is my reasoning wrong? Have I made some false assumptions? Would another way be better?