Android Question Measuring Velocity or Movement

Peter Lewis

Active Member
Licensed User
Longtime User
Hi
I am trying to make an app that will start recording video if the movement of the phone exceeds a specific velocity and then stop recording when the velocity goes below a specific point

I have looked at the Activity Recognition but that takes too long to respond . For example a short rollercoaster ride . You do not want to start before they get up to a certain speed and then at the end of the ride you do not want the last bit. This can be an automated service when combined with Camex2 and an overlay directly to the rider.

If you have any idea how I can determine the velocity I would appreciate it

Thank you
 

Peter Lewis

Active Member
Licensed User
Longtime User
I found this post that solves the problem

 
Upvote 0

emexes

Expert
Licensed User
I found this post that solves the problem
You won't be reliably determining velocity from the accelerometers. Even from GPS could be a bit iffy if the sky is not clearly visible.

But if you are indeed working with a rollercoaster or similar, and the camera is attached to the chassis, and each circuit is the same as the previous, then you can probably pinpoint when the carriage is at key points along the track where the acceleration/g-force changes, and interpolate other positions by time.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
You won't be reliably determining velocity from the accelerometers. Even from GPS could be a bit iffy if the sky is not clearly visible.

But if you are indeed working with a rollercoaster or similar, and the camera is attached to the chassis, and each circuit is the same as the previous, then you can probably pinpoint when the carriage is at key points along the track where the acceleration/g-force changes, and interpolate other positions by time.
I used the rollercoaster as an analogy as it is the same concept. The velocity does not have to be accurate and 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. I really just need to trigger the start and end , So I will have to experiment with values to get it right. The last one here was after the phone was sitting still for about 20 seconds. So it is going to be a lot of experimental work

1642730376798.png
 
Upvote 0

emexes

Expert
Licensed User
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. ?
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
There used to be apps that used accelerometers to measure (estimate?) vehicle quarter-mile runs, time-to-speed, engine power, etc. They might be worth looking at too, if they still exist. I tried a couple early on, but the results were a bit flaky. I suspect they've been superseded by GPS-based measurements, esp. since GPS speed is usually measured "directly" by Doppler rather than by (position_2 - position_1) / (time_2 - time_1).
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
There used to be apps that used accelerometers to measure (estimate?) vehicle quarter-mile runs, time-to-speed, engine power, etc. They might be worth looking at too, if they still exist. I tried a couple early on, but the results were a bit flaky. I suspect they've been superseded by GPS-based measurements, esp. since GPS speed is usually measured "directly" by Doppler rather than by (position_2 - position_1) / (time_2 - time_1).
Firstly , I agree with you , it is a fun project.

To answer your previous questions, The path is a known path. I cannot explain it more without telling you exactly what it is , So here goes.
It is for a 360 degree Photobooth.

Funny enough the rollercoaster analogy would also be fun to do. The phone will be in the upright positions and go around in a circular manner. I will still have to build the unit which I am off now to buy the materials. Seems like the Gyro in my phone might do the job.

The reason why I want to do it this way is I did see one at one of my functions and they used the unit with NO electricity , thy guy just spun the arm manually. What he did was to get the person on the platform , then start the camera spin the arm and after 2-3 rotations, he stopped the arm manually, stopped the video recording. Then this part was was time consuming, he forwarded the video to the persons, whatsapp and in doing that he trimmed off the begin and end.

I want to automate that .


I was playing around with the Gyro earlier and got these results by rotating the phone. But I need to put it into a fixed position and run tests. It looked like it was picking up angles 358 degrees, 356, 351 but was not consistent. What I would use the the Velocity to trigger the record and then allow to spin around 3 times then stop record or if the velocity goes below a certain speed.

Then Post Process with a png overlay or a png gif overlay
 
Upvote 0

emexes

Expert
Licensed User
The phone will be in the upright positions and go around in a circular manner.

Super. So the accelerometer readings should be:

Y: gravity 9.8 m/s/s

X: proportional to speeding up or slowing down of circular motion

Z: proportional to circular speed ie outward acceleration = velocity * velocity / radius, which is zero when velocity is zero ie stationary

So perhaps you can just trigger when Z is above a minimum speed threshold.

And, when stationary, X and Y should be zero, which could be used to guide levelling the phone.
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
1642754830759.png


I was playing around with the Gyro earlier and got these results by rotating the phone. But I need to put it into a fixed position and run tests. It looked like it was picking up angles 358 degrees, 356, 351 but was not consistent.

I think gyro returns angular rate eg degrees/second, rather than angular position. Or are those numbers after you've integrated them?

But you're right, it's odd that it is (seemingly) randomly expressing negative rates -r as sometimes 0 - r and sometimes 360 - r

If you're hand-turning it, then you'd expect r to be bouncing up and down a bit around the average turn rate, but I wouldn't expect readings in the opposite direction to which you're turning it.
 
Upvote 0

Kevin Hartin

Active Member
Licensed User
Hi
I am trying to make an app that will start recording video if the movement of the phone exceeds a specific velocity and then stop recording when the velocity goes below a specific point

I have looked at the Activity Recognition but that takes too long to respond . For example a short rollercoaster ride . You do not want to start before they get up to a certain speed and then at the end of the ride you do not want the last bit. This can be an automated service when combined with Camex2 and an overlay directly to the rider.

If you have any idea how I can determine the velocity I would appreciate it

Thank you
Have you thought about using something like a Bluetooth Beacon to be the trigger points?

The two beacons can be advertising different payloads to determine which action is to be triggered.

The beacons output levels and frequency of advertising can be tuned to the appropriate values to ensure triggering reliability.

Kev
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Have you thought about using something like a Bluetooth Beacon to be the trigger points?

The two beacons can be advertising different payloads to determine which action is to be triggered.

The beacons output levels and frequency of advertising can be tuned to the appropriate values to ensure triggering reliability.

Kev
The whole concept would be to do this easily with minimal setup, I could also put in a proximity sensor or similar (LDR) in the base with an esp8266 sending data to the phone when it passes those points. but the phone has got sensors built in , I would rather use those then adding more hardware. Thank you for the idea
 
Upvote 0
Top