문제

I'm trying to measure the force applied to the device along the x axis.
If you push the device to the left (so the phone moves to the right) at constant speed,
measuring the acceleration (using TYPE_LINEAR_ACCELERATION) along the x axis will return positive number at the beginning, but very fast the acceleration will be equal to zero (again, pushing at a constant speed).
As explained in the API Ad = - ∑Fs / Mass , so I thought to achieve the force by multiplying the acceleration sensor result (event.values[0]) with the mass,
but multiplying acceleration equals to zero won't help.
The reason I'm trying to measure the force, and not the acceleration is I want to detect a long (in matter of time) gesture of moving the phone in constant speed, contradiction to shake for example.
The goal is to move a ball according to the movement of the phone.
Pushing the phone from the user:
enter image description here
enter image description here
Will move the ball upwards from it current position:
enter image description here
enter image description here

도움이 되었습니까?

해결책

I'm no physicist, but I don't think you can do that. If an object is moving at a constant speed, it has no net force acting on it. Force is defined by acceleration and mass.

However, you can tell if the phone is still moving. If you see a rise in acceleration followed by a drop to zero, it's still moving. When the phone stops moving, you'll get an acceleration in the opposite direction equal to the starting acceleration.

So, if you move your ball up when you see an acceleration in that direction, don't just move it up by the current value. Sum the accelerations you've seen so far(weighted by time between sensor readings?). That way when it drops to zero, it will stay put. When it starts to accelerate the other way (slowing down), it will subtract from the position until it's roughly centered again.

Of course, the accelerometer is prone to drift, etc, so it's hard to get this perfect.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top