Announcement

Collapse
No announcement yet.

Mr color sensor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mr color sensor

    We are running into a problem with our MR Color Sensor. We have a program that enables the color sensor so we can use it to help find the beacon, we have an ODS, GYRO, and a Range Sensor (all Modern Robotics) also to help us locate the beacon. This part works fine. At the end of the program we set the colorSensor.enableLed(false); then return if we had found the beacon. The logic in the main program then calls our button pusher program that tries to determine which button to push. However the LED does not go off all the time!!! We have used sever color sensors and changed out some of the wires. There is NOT a way to test for LED true or false at this point (We need this functionality). Could this be part of the USB issue? If so how long of sleep() might I need. Every second count if you are trying to get 2 beacons.

    Thanks.

  • #2
    I've also had trouble turning the MR color sensor LED on and off.

    It seems to work OK with a test program, but as part of my main control loop it doesn't always respond.

    Now... in my case I'm also enabling and disabling the reading of the color sensor for improved performance, and I don't know this impacts the LED command.

    I don't have an answer at this time, but I thought I'd ask to see if you were also enabling/disabling the sensor based on the previously proposed manual strategy.

    Comment


    • #3
      I recall reading something about initial state of the LED, and elimination of duplicate messages to the devices. It was something along the lines of...
      If the LED command is the same as the previous command, don't send it out. The initial state may have been assumed to be off, and if a command to turn off the LED was received by the SDK, it would not get sent. This can be overcome by sending a cycle of on/off in init. Sorry about the vague details.
      So something like...
      colorSensor.enableLed(false);
      sleep(10);
      colorSensor.enableLed(true);
      sleep(10);
      colorSensor.enableLed(false);

      Comment


      • #4
        I just found where I had seen this. It is the ftc github issues...
        https://github.com/ftctechnh/ftc_app/issues/310

        Comment


        • #5
          MR Color Sensor - LED State

          Originally posted by Philbot View Post
          I've also had trouble turning the MR color sensor LED on and off.

          It seems to work OK with a test program, but as part of my main control loop it doesn't always respond.

          Now... in my case I'm also enabling and disabling the reading of the color sensor for improved performance, and I don't know this impacts the LED command.

          I don't have an answer at this time, but I thought I'd ask to see if you were also enabling/disabling the sensor based on the previously proposed manual strategy.
          Thank you for you help. When we turn the power module to the ON position the LED on the MR Color Sensor turn On. When we Initialize our hardware, we turn the LED to off (false). My find Beacon Program turns the LED to on (true) colorSensor.enableLed(true); and sleep(50); (I would like to get rid of the sleep(50) if possible. At the end of find Beacon Program I set colorSensor.enableLed(false); and have another sleep(50); Again I would like to get rid of sleep(5) but I did this because of the USB issues people were talking about on the Forum. DO I NEED THESE????? After that I return to my main calling program and and the telemetry let me know if I found it or not. Then it call the Push Beacon Button Program in which I want the LED OFF so I can see what side to press. I DO NOT TURN THE LED OFF AGAIN IN THIS PROGRAM. Again I need every second.

          SO WHAT ARE YOU REALLY TELLING ME TO TRY. Thank you for your help. I really appreciate it but and not clear on a solution.

          Comment


          • #6
            If you are turning the LED off in your init, then you are probably okay.
            We turn off then on the off the LED in init - just to be sure.
            We also unregister the color sensor in init. This reduces its impact on the bus. Most notably - this means improved gyro update rate.
            When we get to the segments where we need to find the line, we reregister the color sensor and turn the light on. After the segment we turn off the LED and deregister again.
            We do have a sleep of 50ms after register and before deregister. Not really sure we need these, but it only totals 0.1s.

            Comment


            • #7
              MR Color Sensor - LED STATE

              Originally posted by FTC7253 View Post
              If you are turning the LED off in your init, then you are probably okay.
              We turn off then on the off the LED in init - just to be sure.
              We also unregister the color sensor in init. This reduces its impact on the bus. Most notably - this means improved gyro update rate.
              When we get to the segments where we need to find the line, we reregister the color sensor and turn the light on. After the segment we turn off the LED and deregister again.
              We do have a sleep of 50ms after register and before deregister. Not really sure we need these, but it only totals 0.1s.
              I don't know how to deregister and register sensors. Can you share a code fragment? I do turn the LED off in the INIT. I will test more later but if you could help with the deregister/register it would help. Thanks again.

              Comment


              • #8
                colorSensor.getI2cController().deregisterForPortRe adyCallback(getColorPort());
                colorSensor.getI2cController().registerForI2cPortR eadyCallback(colorSensor, getColorPort());

                Comment


                • #9
                  Are you using the color sensor to find the white line? Why do you ever need to turn the LED off?

                  Comment


                  • #10
                    MR Color Sensor

                    Originally posted by FTC12090 View Post
                    Are you using the color sensor to find the white line? Why do you ever need to turn the LED off?
                    Because the MR Color Sensor has 2 modes. One is good for reading amount of light reflective and one is good for reading amount of light given off by the light inside of the Beacon.

                    Comment


                    • #11
                      Thank you for your help.

                      Comment


                      • #12
                        I cant get to the robot to this until tonight but am I on the right track with the following

                        / In your Robot class:
                        public class Robot
                        {
                        public LinearOpMode opmode;
                        public ElapsedTime matchTimer;
                        private HardwareMap hardwareMap;
                        private Telemetry telemetry;
                        ...
                        public Robot(LinearOpMode opmode)
                        {
                        this.opmode = opmode;
                        this.hardwareMap = opmode.hardwareMap;
                        matchTimer = new ElapsedTime();
                        ...
                        }

                        public void gyroDrive( double speed, double distance, double angle)
                        {
                        .
                        .
                        .
                        while (leftMoter.isbusy() && this.opmode.OpModeIsActive())
                        {
                        .
                        .
                        }
                        }
                        }
                        //In your LinearOpMode:
                        public class MyAutonomous extends LinearOpMode
                        {
                        ...
                        @Override
                        public void runOpMode()
                        {
                        ...
                        Robot robot = new Robot(this);
                        ...
                        waitForStart();
                        robot.matchTimer.reset();
                        while (isOpmodeActive())
                        {
                        gyroDrive(.05,24,90) // Half speed 24 inches, 90 degree heading...
                        }
                        }
                        }

                        Comment


                        • #13
                          Wrong thread? You posted this in another thread. It doesn't seem to have anything to do with the color sensor.

                          Comment


                          • #14
                            Originally posted by FTC5024 View Post
                            Because the MR Color Sensor has 2 modes. One is good for reading amount of light reflective and one is good for reading amount of light given off by the light inside of the Beacon.
                            Yeah, but if you are looking for the line, the color sensor would be mounted one way, and the beacon would be mounted in a much different way. So I am surprised you would be using the same color sensor to look for the line and to look at the beacon.

                            Comment


                            • #15
                              Originally posted by FTC12090 View Post
                              Yeah, but if you are looking for the line, the color sensor would be mounted one way, and the beacon would be mounted in a much different way. So I am surprised you would be using the same color sensor to look for the line and to look at the beacon.
                              Yes wrong post, I was working on two issues. We use the ODS for finding and following the line. We use the MR Color Sensor to let us know if we have found the Beacon (Light on) and then we turn the LED off to read the color so we know what side to press. You have to wait (sleep) for awhile before reading the color. We also set the LED off again in that program and sleep just to make sure. if we don't we don't get good results all the time.

                              Thanks

                              Comment

                              Working...
                              X