I wish to use the EV3 IRsensor of my robot both in distance mode and in seek/beacon mode.
The EV3 IRsensor is given for a range in seek/beacon mode of about 200 cm (78 inches).
In my tests, the beacon is emitting on channel 0 (see code) and the distance reported by the IRsensor Sample provider in seek mode is 100 at a distance of approx. 40 cm. If I increase the distance of the beacon to the IRSensor, the reported distance remains at 100, so the theoritical limit of 200cm cannot be reached.
the distance values displayed by the 'IRSensorSeek' SampleProvider are:
40 when the beacon is at 10cm from the IRSensor
70 when the beacon is at 20 cm from the IRsensor
90 when the beacon is at 30 cm from the IRsensor
100 when the beacon is at 40cm or more from the IRsensor
Code: Select all
public class Petdog {
// Constants
static final String IRSENSOR_PORT = "S3";
// IRsensor
static EV3IRSensor sensor_IR;
static SampleProvider IRSensorDist; // distance
static float[] IRSensorDistSamples;
static SampleProvider IRSensorSeek; // seek/beacon mode
static float[] IRSensorSeekSamples;
public static void main (String[] args)
{
// setup IR-sensor:
sensor_IR = new EV3IRSensor(LocalEV3.get().getPort(IRSENSOR_PORT));
// setup IRSensor for distance:
IRSensorDist = sensor_IR.getDistanceMode();
IRSensorDistSamples = new float[IRSensorDist.sampleSize()]; // samplesize = 1 (distance)
// setup IRsensor in seek mode:
IRSensorSeek = sensor_IR.getSeekMode();
IRSensorSeekSamples = new float[IRSensorSeek.sampleSize()]; // samplesize = 8 (distance+range for 4 channels)
// test IRsensor in seek mode:
testIRSeek();
cleanup();
}
private static void testIRSeek()
{ // assumes Beacon channel = 0
while (!Button.ENTER.isDown())
{ // reads angle and distance every second
IRSensorSeek.fetchSample(IRSensorSeekSamples, 0);
System.out.println("" + IRSensorSeekSamples[0] + " " + IRSensorSeekSamples[1]); // only need fist 2 values as beacon channel is 0
Delay.msDelay(1000);
}
}
private static void cleanup()
{ // release some ressources:
if (sensor_IR != null) sensor_IR.close();
}
}
Is there an issue with the fact that I create 2 SampleProviders ? (one in distance mode and one in seek mode)
What am I doing wrong ?
Thank you in advance for your help and patience...