I used the rollercoaster as an analogy as it is the same concept.
My first guess was that you were rigging up a camera to take photos of rollercoaster faces at key points along the track. That'd be a fun project.
I have already seen just working with the ACCELEROMETER , it jump all over the place even though the phone is sitting still on a solid surface.
Yeah... accelerometers in phones are good enough for determining orientation from vertical, but as soon as you start integrating for speed and distance... ugh.
Plus it is surprising how few Android phones have gyroscopes, especially in my stomping ground at the cheap end of the market. If you don't have a gyroscope then it is difficult to discern whether horizontal acceleration/force is due to change in speed or change in direction.
Is your use case:
(i) horizontal path? (perpendicular to gravity)
(ii) straight path?
(iii) fixed known path?
(iv) fixed to chassis of a vehicle so that the phone orientation with respect to the path is known?
My first try would be to calculate the nett gravity+acceleration vector length using Pythagorus ie Sqrt(ax * ax + ay * ay + az * az) which should end up being ~9.8 m/s/s when the phone is stationary, or moving at a steady speed, regardless of orientation.
If travel is restricted to horizontal plane, then the nett vector length will only ever be greater than that when the speed or direction changes, ie:
- stationary: nett force
= 9.8 m/s/s
- speed up forwards: nett force
> 9.8 m/s/s
- stop speeding up, continue at steady speed: nett force
= 9.8 m/s/s
- slow down backwards: nett force
> 9.8 m/s/s (not <)
If the phone is fixed to a vehicle chassis and isn't floating about with respect to gravity, then you can also determine direction, esp. just if looking to know whether forwards (speeding up) or backwards (slowing down).
I really just need to trigger the start and end , So I will have to experiment with values to get it right.
If the path and speed profile are known, then you can use the speeding-up and slowing-down acceleration humps to align with that profile. And if the middle segment of the profile is just a constant speed, and acceleration/deceleration only occur at the ends of the paths, then you can probably safely assume that the speed is zero after the deceleration hump. In fact, you might even have a reasonable speed measurement after the acceleration hump, at least for the few seconds until integration of sensor offset spoils the party.
So it is going to be a lot of experimental work
Fun. Not work. ?