Android Sensor_delay_fastest并不够快
题
我正在使用传感器来平衡机器人,但是世纪odicetagcode只提供10Hz采样率,这根本不够快。有没有一种方法可以更快地抽样?
是否有一种轮询传感器的方法,而不是等待世代族代码?
解决方案
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.