Inconsistant Color Sensor readings

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

Moderators: roger, gloomyandy, skoehler

Inconsistant Color Sensor readings

Postby lormand » Fri Oct 18, 2013 3:37 pm

We are getting inconsistent results when trying to read colors using the latest/greatest lejos code from soundforge. To verify that the sensor was fine, I fired up LabView and compared color values from both the old NXT RGB sensor, and the new EV3 sensor using different angles and distances, and a fixed positions. In all cases, the new sensor worked as expected.

However, when doing this same test using lejos code, we are getting values that are not stable. Only a few colors like green or blue are consistently detected, but the slightest movement of the sensor will result in unstable values, sometimes outside valid ranges. We are seeing this using the following methods .... getcolorID, getlightvalue, normlightvalue, etc. We also were not successful with the previous code base.

Setup:
EV3 Color sensor as came in off the shelf kit (45506 I think)
Inside cover of EV3 box for color examples
Latest lejos code
lormand
New User
 
Posts: 8
Joined: Sat Sep 21, 2013 8:03 pm

Re: Inconsistant Color Sensor readings

Postby gloomyandy » Fri Oct 18, 2013 4:13 pm

Hi,
I can't see how the results from getColorId can be different as that just reads an value from the actual sensor and then converts the color code from Lego color numbers to the ones leJOS uses. All of the color recognition is performed by the sensor itself. What do you mean by "outside of valid ranges". Please post your test code and examples of what output you get and what output you expect to get.

Are you actually using LabView with the EV3? My understanding is that LabView is not available for the EV3 until next year. Do you mean the standard Lego supplied software (either retail or education)?

I have no idea what the various Lego supplied blocks do with color results. You may need to do some additional processing... sample the color then wait a short while and sample it again and only return a color match if both samples produce the same results. If possible please use the standard Lego software to run your other test as I'm not aware of any of the leJOS devs having a copy of LabView.

What do you mean by "latest lejos code" are you using the very latest version of thing from git or one of the tagged branches? If you are using the latest version are you sure that the ev3class.jar that you are using is the one you have compiled against (you can't use the one on the SD card).

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

Re: Inconsistant Color Sensor readings

Postby lormand » Fri Oct 18, 2013 7:15 pm

Sorry for the 'labview' confusion, but I am referring to the standard Legos Mindstorm EV3 Home edition for PC, which is powered by labview.

Based on your comments, it may be prudent for us to recheck our build env and our overall setup and code.

...don't wanna get yelled at for posting some faulty code :D
lormand
New User
 
Posts: 8
Joined: Sat Sep 21, 2013 8:03 pm

Re: Inconsistant Color Sensor readings

Postby gloomyandy » Fri Oct 18, 2013 7:26 pm

Hi,
I promise we won't shout! If you are still having problems please post the code (or even better a very simple test program) and your results and I'll try and take a look. Note that with leJOS there is no difference between the results returned by getLightValue and get getNormalizedLevel. It is likely that both of these methods will be removed as part of our switch to the new sensor framework (which is currently in progress).

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

Re: Inconsistant Color Sensor readings

Postby lormand » Fri Oct 18, 2013 7:32 pm

I edited this post because my collegue now says he thinks he has it. He says that he had to map the values for each color to know what to expect....or something like that.

Thanks Andy
Last edited by lormand on Fri Oct 18, 2013 8:34 pm, edited 1 time in total.
lormand
New User
 
Posts: 8
Joined: Sat Sep 21, 2013 8:03 pm

Re: Inconsistant Color Sensor readings

Postby gloomyandy » Fri Oct 18, 2013 8:33 pm

Hi,
can you pull out the values you are concerned about and explain why you are concerned about them? You might also want to look at the actual source code for the driver class. Some of the fields you are printing out are not actually valid so for instance getRawColor currently returns nothing of value (due to the sensor crashing when we switch modes) and in particular is documented as always setting the color value to be Color.NONE (which has a value of -1). I've already mentioned that getLightValue and getNormalizedLightValue return the same values. Finally leJOS uses different color ids to those used by Lego. See:
https://sourceforge.net/p/lejos/ev3/ci/ ... Color.java
So in this case the first reading is for Blue and we return 2 (which is Blue), the second is color green and we return color id 1 (which is green) and finally we have red which we return id 0 (which is color red).

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


Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff