Can the color sensor detect orange?

HomeForumsMonoBrick EV3 FirmwareCan the color sensor detect orange?

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #4811
    Author Image
    Roy Toren
    Participant

    Hi,

    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,

    #4812
    Author Image
    Tcm0
    Participant
    #4814
    Author Image
    Anders Søborg
    Keymaster

    Hi

    The page Max is referring to is the NXT color sensor. The EV3 color documentation can be found here

    /Anders

    #4822
    Author Image
    Tcm0
    Participant

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

    #4825
    Author Image
    Roy Toren
    Participant

    I have already tried th reflected light in the color sensor example, it didnt work.

    As for the RGB do I need a different sensor for that?
    I have these two:

    • This reply was modified 10 years, 2 months ago by Author ImageRoy Toren.
    Attachments:
    You must be logged in to view attached files.
    #4827
    Author Image
    Roy Toren
    Participant

    The other sensor is this one:
    (cant upload more then 512 KB :|)

    Attachments:
    You must be logged in to view attached files.
    #4979
    Author Image
    Jacek S
    Participant

    Hi,

    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,
    Jacek

    #4981
    Author Image
    Anders Søborg
    Keymaster

    Hi

    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

    #4982
    Author Image
    Jacek S
    Participant

    Hi,

    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]);
      }
    
    #4983
    Author Image
    Anders Søborg
    Keymaster

    Hi 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

    #4987
    Author Image
    Jacek S
    Participant

    Ok I will add. Thanks

    #5047
    Author Image
    Auctor137
    Participant

    Hello Jacek,

    could you please tell me how to detect orange with your solution ?
    I’m using a EV3 Colorsensor.

    I’ve tried a bit with the code you have posted and checked the library page

    but i don’t know how to write the code properly.

    auctor

    #5048
    Author Image
    Auctor137
    Participant

    Hi 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?

    • This reply was modified 9 years, 11 months ago by Author ImageAuctor137.
    • This reply was modified 9 years, 11 months ago by Author ImageAuctor137.
    #5051
    Author Image
    Jacek S
    Participant

    Hi 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

    #5053
    Author Image
    Auctor137
    Participant

    Hi 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 Author ImageAuctor137.
Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic.

Posted in

Make a donation