EV3 IRsensor range problem in seek mode

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

Integral
Novice
Posts: 28
Joined: Sat Feb 28, 2015 10:11 am
Location: France

EV3 IRsensor range problem in seek mode

Postby Integral » Mon Mar 30, 2015 12:55 pm

Dear All,

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...

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 IRsensor range problem in seek mode

Postby gloomyandy » Mon Mar 30, 2015 7:00 pm

Well you can very easily find out if having two sample providers is causing the problem. What happens if you only have one?

What is your source that indicates that the IR detector in seek mode operates at up to 200cm? Have you tried the same test using the LEGO software?
leJOS news https://lejosnews.wordpress.com/

Integral
Novice
Posts: 28
Joined: Sat Feb 28, 2015 10:11 am
Location: France

Re: EV3 IRsensor range problem in seek mode

Postby Integral » Tue Mar 31, 2015 9:32 am

The source for the 200cm range in seek mode is from Lego: you can get it directly from the Lego Mindstorms EV3 site: "User Guide LEGO MINDSTORMS EV3 10 All ENUS.pdf : "The Infrared Sensor will detect a beacon signal matching the channel that you specify in your program up
to a distance of approximately 200 cm in the direction it is facing"

I removed the "distance" SampleProvider on the IRSensor in leJOS, same problem.

I have tested it with the Lego software... same problem ! ... but: there is an additional value in the Lego software for the IRSensor in seek mode: Detected/Not Detected.

If I put the beacon *behind* the IR sensor, at about 2 meters and turn it on, it is 'Detected' (with angle=0 and dist = 100)
So probably the 200cm in the Lego document is just for this boolean value: Detected or not ...

Back to leJOS, this boolean is indirectly provided: with beacon off, the reading is "0.0 Infinity"
With beacon on (behing the IR sensor, at about 2m), the reading is "0.0 100".

Conclusion: the Lego document is wrong : the beacon is in reality detected provided it is at < 200cm from the sensor, and whatever its position vs the sensor.

Thank you for your help and time.

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 IRsensor range problem in seek mode

Postby gloomyandy » Tue Mar 31, 2015 11:16 am

Hi,
thanks for the update. Useful data for anyone using this sensor!

Andy
leJOS news https://lejosnews.wordpress.com/

MrK
New User
Posts: 2
Joined: Sat Apr 09, 2016 5:29 pm

Re: EV3 IRsensor range problem in seek mode

Postby MrK » Sat Apr 09, 2016 5:43 pm

Strange thay this thread died on the above bombshell...

I also experienced that when the IR beacon is behind the sensor or otherwise out of direct sight, direction 0 and distance 100 is reported, but how can I distinguish this state from the beacon being straight in front of the sensor at more than 40 cm? The result is that my robot keeps heading away in a straight line from the beacon that is behind it, instead of turning around. If I use the reported distance 100 and direction 0 as a trigger to start looking behind, this also happens when facing the beacon correctly... Makes things quite unreliable... Any ideas for a fix or workaround?

Thanks,
K

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 IRsensor range problem in seek mode

Postby gloomyandy » Sat Apr 09, 2016 8:22 pm

So if the beacon is behind the sensor do you ever get any reading less then 100? If you don''t then you may be able to simply ignore readings that are >= 100.

One thing you have to remember is the IR light just like visible light will be reflected from various surfaces so it may well be that in this case the sensor is picking up a reflection. Unfortunately real world sensors have a nasty habit of doing things like this (especially relatively low cost ones). It is always a good idea when using a sensor to spend some time experimenting by looking at the output from the device in various different situations, this can often reveal a lot of things about how the device works in the real world.
leJOS news https://lejosnews.wordpress.com/

MrK
New User
Posts: 2
Joined: Sat Apr 09, 2016 5:29 pm

Re: EV3 IRsensor range problem in seek mode

Postby MrK » Sun Apr 10, 2016 8:29 pm

Well, I've worked around it by assuming that any reading reported as direction 0 and distance 100 is unreliable. So, when getting such a reading, instead of heading straight on, I'll turn a bit. If the beacon was straight ahead, turning will make it go to a side and hence no longer report direction 0, but if it really was out-of-sight, then the next sample will still report direction 0 and distance 100 and I'll keep turning until at some point hopefully seeing the beacon at a non zero direction. First tests seem positive, even when this approach causes a bit of zigzagging instead of heading in a straight line to the beacon.

y_y
New User
Posts: 1
Joined: Thu Nov 02, 2017 12:32 pm

Re: EV3 IRsensor range problem in seek mode

Postby y_y » Thu Nov 02, 2017 12:36 pm

The IR remote must be facing the IR sensor in the position as shown in the picture..

Image


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest