안드로이드 센서 _delay_fastest는 충분히 빠르지 않습니다
문제
저는 센서를 사용하여 로봇의 균형을 유지하지만 SENSOR_DELAY_FASTEST
는 단순히 충분히 빠르지 않는 10Hz 샘플링 속도 만 제공합니다.샘플링이 더 빨리 샘플링하는 방법이 있습니까?
SensorEvent
를 기다리지 않고 센서를 폴링하는 방법이 있습니까?
해결책
Is there a way of sampling even faster?
SENSOR_DELAY_FASTEST
is a 0ms delay. You cannot have negative time, at least as far as physicists have determined. Hence, there is no "faster" delay than SENSOR_DELAY_FASTEST
.
Use Traceview to determine where your time is being taken up. It is possible that it is your code that is slowing down your processing.
a way of polling the sensors rather than waiting for a SensorEvent ?
No, sorry.
다른 팁
I would check to optimize code as well, but why do you need faster than 10Hz? In my opinion you could just write a better 'balance' algorithm to reduce the need for a faster sample.
For instance when your robot is say 5 degrees to the right you'll try to correct for 4 degrees instead and reduce the need for a re-correction. Maybe I'm mistaken, but I'm open to suggestions too!
Since Android version 2.3, the sensors can be queried through the NDK, which will allow much faster polling.