|
Page 1 of 1
|
[ 9 posts ] |
|
Author |
Message |
cookthebook
Rookie
Joined: Wed Jan 09, 2013 11:48 pm Posts: 46 Location: Saint Paul, MN
|
 NXT Color Sensor 2.0
I recently purchased 2 color sensors since the ambient light sensor has a red light and cant differentiate the blue line with the ground, but I purchased them seeing that the color also has an ambient light sensor. I know how to use the rgb values perfectly well, I just haven't seen any resources showing how to utilize the part of the sensor, and I need that function to tell the difference between the ground and the black platform. Any help is appreciated, thanks!
_________________Head Programmer FTC Team 6699, Tempest
|
Thu Oct 10, 2013 9:30 pm |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: NXT Color Sensor 2.0
How close are you mounting the sensors to the ground? Are these LEGO sensors or HiTechnic sensors?
_________________FTC Team 6424, the 'Oly Cow - Chief programmer. FRC Team 4450, Olympia Robotics Federation (ORF). and also quadrotors. Quadrotors!
|
Thu Oct 10, 2013 9:39 pm |
|
 |
cookthebook
Rookie
Joined: Wed Jan 09, 2013 11:48 pm Posts: 46 Location: Saint Paul, MN
|
 Re: NXT Color Sensor 2.0
They are about an inch off the ground (pointed down of course) and they are lego sensors
_________________Head Programmer FTC Team 6699, Tempest
|
Fri Oct 11, 2013 8:22 am |
|
 |
cookthebook
Rookie
Joined: Wed Jan 09, 2013 11:48 pm Posts: 46 Location: Saint Paul, MN
|
 Re: NXT Color Sensor 2.0
This is from the Lego site itself: "The NXT Color Sensor is able to perform three unique functions. It acts as a color sensor, distinguishing among six colors; it works as a light sensor, detecting light intensities – both reflected light and ambient light; and it works as a color lamp, emitting red, green, or blue light."
So I don't know how RobotC handles those two other functions.
_________________Head Programmer FTC Team 6699, Tempest
|
Fri Oct 11, 2013 6:02 pm |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: NXT Color Sensor 2.0
I see what you mean. You can detect ambient light intensity simply by adding up the RGB values and dividing by 3. As to the "color lamp" functionality, you'll have to find drivers for the sensor. I don't think Xander has written drivers for the NXT color sensor yet (there's one for the light sensor though).
_________________FTC Team 6424, the 'Oly Cow - Chief programmer. FRC Team 4450, Olympia Robotics Federation (ORF). and also quadrotors. Quadrotors!
|
Fri Oct 11, 2013 9:53 pm |
|
 |
cookthebook
Rookie
Joined: Wed Jan 09, 2013 11:48 pm Posts: 46 Location: Saint Paul, MN
|
 Re: NXT Color Sensor 2.0
Thanks, for the RGB values would I use SensorRaw? I can figure out how to use it but I dont know if that is what I would use, I just do SensorValue right now.
_________________Head Programmer FTC Team 6699, Tempest
|
Fri Oct 11, 2013 10:41 pm |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: NXT Color Sensor 2.0
That's what I would think. Having never used it before, I now realize it might be really tricky.  It'd be nice if a dev or Xander could lend some help here.
_________________FTC Team 6424, the 'Oly Cow - Chief programmer. FRC Team 4450, Olympia Robotics Federation (ORF). and also quadrotors. Quadrotors!
|
Fri Oct 11, 2013 10:58 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: NXT Color Sensor 2.0
There's a sample program in the, well, err, sample program folder, called, you guessed it, "ColorSensor.c". It has code that shows you how to get the RGB values from the LEGO Colour Sensor. I've attached it for your convenience and pasted a small snippet, so you know what to look for:  |  |  |  | Code: void displayRGBColorValues() { short nAtoDValues[4]; short nRawValues[4]; short nColorValues[4]; string sTemp;
getColorSensorData(colorPort, colorAtoD, &nAtoDValues[0]); getColorSensorData(colorPort, colorRaw, &nRawValues[0]); getColorSensorData(colorPort, colorValue, &nColorValues[0]);
displayColorIndex();
nxtDisplayTextLine(3, " AtoD Raw %%"); StringFormat(sTemp, "R %4i%5i", nAtoDValues[0], nRawValues[0]); nxtDisplayTextLine(4, "%s%4i", sTemp, nColorValues[0]); StringFormat(sTemp, "G %4i%5i", nAtoDValues[1], nRawValues[1]); nxtDisplayTextLine(5, "%s%4i", sTemp, nColorValues[1]); StringFormat(sTemp, "B %4i%5i", nAtoDValues[2], nRawValues[2]); nxtDisplayTextLine(6, "%s%4i", sTemp, nColorValues[2]); StringFormat(sTemp, "Amb%4i%5i", nAtoDValues[3], nRawValues[3]); nxtDisplayTextLine(7, "%s%4i", sTemp, nColorValues[3]); } |  |  |  |  |
I've never really done a lot with the LEGO colour sensors but hopefully the raw values will be able to help you. There's some RGB to HSV conversion code in my driver suite, I think it might be in the common-light.h file. From what I have gathered is that HSV is much easier to map to actual colour ranges than RGB. = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Sat Oct 12, 2013 2:00 am |
|
 |
cookthebook
Rookie
Joined: Wed Jan 09, 2013 11:48 pm Posts: 46 Location: Saint Paul, MN
|
 Re: NXT Color Sensor 2.0
Thanks so much, got my autonomous working!
_________________Head Programmer FTC Team 6699, Tempest
|
Sat Oct 12, 2013 10:47 pm |
|
|
|
Page 1 of 1
|
[ 9 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|