我想从我的 Ev3GyroSensor 读取当前角度,但返回值始终为 0。我测试了多个端口,但没有任何效果。如果我使用 LeJOS 集成工具测试传感器,一切正常。
EV3GyroSensor ev3GyroSensor = new EV3GyroSensor(SensorPort.S4);
SampleProvider sampleProvider = ev3GyroSensor.getAngleAndRateMode();
float[] sample = new float[sampleProvider.sampleSize()];
sampleProvider.fetchSample(sample, 0);
System.out.println(sample[0]);
//I move the robot with my hand
Delay.msDelay(3000);
sampleProvider.fetchSample(sample, 0);
System.out.println(sample[0]);
ev3GyroSensor.close();