I would like to read the current angle from my Ev3GyroSensor, however the returned value is always 0. I tested multiple Ports nothing worked. If I test the sensor with the LeJOS integrated Tool, everything works fine.
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();
try using only angle mode, from my experience, angle and rate mode doesn't always work correctly. There is also a possibility that you are reading the rate from the sample, but I'm not really sure.