Home→Forums→MonoBrick EV3 Firmware→Can the color sensor detect orange?
- This topic has 17 replies, 6 voices, and was last updated 9 years, 10 months ago by Anders Søborg.
-
AuthorPosts
-
September 8, 2014 at 16:06 #4811
Roy TorenParticipantHi,
I need to detect the color orange, and the color mode does not recognise it, it reads orange as red which is problematic.
Is there a way to change it.Thank you,
September 8, 2014 at 16:53 #4812
Tcm0ParticipantYou can try to go by reflected light or the RGB mode (http://www.monobrick.dk/MonoBrickFirmwareDocumentation/class_mono_brick_firmware_1_1_sensors_1_1_r_g_b_color.html).
September 8, 2014 at 17:45 #4814
Anders SøborgKeymasterHi
The page Max is referring to is the NXT color sensor. The EV3 color documentation can be found here
/Anders
September 8, 2014 at 20:28 #4822
Tcm0ParticipantSorry, didn’t know that the NXT had RGB mode. In that case the reflected light or the RGB mode (if it’s avaible for the EV3 color sensor) should be your choice.
September 8, 2014 at 20:35 #4825
Roy TorenParticipantSeptember 8, 2014 at 20:36 #4827
Roy TorenParticipantThe other sensor is this one:
(cant upload more then 512 KB :|)Attachments:
You must be logged in to view attached files.November 16, 2014 at 10:02 #4979
Jacek SParticipantHi,
Any progress? I trying to solve the same problem using the ev3 sensor.
I know it is possible with the new lego firmware 1.06H. Sensor can be switched into RGB mode.Question for Anders: Which version of lego firmware is the base for the monobrick firmware?
Thanks,
JacekNovember 19, 2014 at 08:50 #4981
Anders SøborgKeymasterHi
I will have a look at the raw data from the sensor to see if it has RGB values (to be honest I can’t remember if this is the case), but as you already point out it might not be available since our image is based on an older version of the LeJos image. But do you actually need the RGB values? the raw value should be good enough. You can see more here
/Anders
November 19, 2014 at 09:23 #4982
Jacek SParticipantHi,
I need RGB values to convert to HSV. This is the way that colors can be determined easily.
I have made modification to the firmware, and it is working for me. Now I can easily detect orange and other colors.I added support for uart.mode4 to EV3ColorSensor.cs:
public RGBColor ReadRGB() { if (uartMode != UARTMode.Mode4) Mode = ColorMode.RGB; byte[] rawBytes = ReadBytes(6); return new RGBColor(rawBytes[0], rawBytes[2], rawBytes[4]); }
November 19, 2014 at 09:34 #4983
Anders SøborgKeymasterHi there
Amazing – could you please add a pull request (so you can get credit) so this can be part of the next release. Thanks
/Anders
November 19, 2014 at 09:57 #4987
Jacek SParticipantOk I will add. Thanks
December 8, 2014 at 15:43 #5047
Auctor137ParticipantDecember 8, 2014 at 17:44 #5048
Auctor137ParticipantHi everybody,
I’m a litte bit confused.. the new EV3 Colorsensor is not able to read RGB ? Why would LEGO do that?
I’ve tried this Code out of the new Tutorial from Max Mustermann, but with the EV3 Sensor it doesn’t work.
Red 0
Green 0
Blue 0
all the time.using System; using System.Threading; using MonoBrickFirmware.Sensors; using MonoBrickFirmware.Movement; using MonoBrickFirmware.Display; using MonoBrickFirmware.UserInput; namespace farbsensor { class farbsensor { static void Main(string[] args) { EV3ColorSensor farbsens = new EV3ColorSensor(SensorPort.In1); bool abfrage = true; string rotwert, gruenwert, blauwert; RGBColor RGBFarben = new RGBColor(0, 0, 0); ButtonEvents buts = new ButtonEvents(); buts.EscapePressed += () => { abfrage = false; }; while (abfrage == true) { rotwert = Convert.ToString(RGBFarben.Red); LcdConsole.WriteLine("Rot :" + rotwert); gruenwert = Convert.ToString(RGBFarben.Green); LcdConsole.WriteLine("Gruen :" + gruenwert); blauwert = Convert.ToString(RGBFarben.Blue); LcdConsole.WriteLine("Blau :" + blauwert); Thread.Sleep(2000); } LcdConsole.WriteLine("###############"); LcdConsole.WriteLine("PROGRAMMENDE..."); Thread.Sleep(3000); } } }
#EDIT
I forgot
RGBFarben = farbsens.ReadRGBColor();
infront of the “while-loop”, but farbsens does not have the function ReadRGBColor(), how can i do it?December 9, 2014 at 11:12 #5051
Jacek SParticipantHi Auctor,
You need to compile firmware lib from the master branch. Because I added this functionality a week ago.
Then this should work:EV3ColorSensor colorSensor = new EV3ColorSensor(SensorPort.In2); RGBColor rgbColor = colorSensor.ReadRGB(); Color color = Color.FromArgb(rgbColor.Red, rgbColor.Green, rgbColor.Blue); var hue = (int) color.GetHue(); var bright = (int) (color.GetBrightness()*100);
Then look: http://en.wikipedia.org/wiki/Hue
December 9, 2014 at 16:36 #5053
Auctor137ParticipantHi Jacek,
thanks, looking forward to use this!
But I really don’t know what to do, I’m not a a professional programmer..Could you tell me how to compile the firmwarelib from the master branch and use your solution?
I’m using Visual Studio 2012 C# with Windows 7
- This reply was modified 9 years, 11 months ago by Auctor137.
-
AuthorPosts
You must be logged in to reply to this topic.
Follow