Announcement

Collapse
No announcement yet.

Autonomous Help - Encoders and Color Sensors

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

  • Autonomous Help - Encoders and Color Sensors

    Hi teams! We are in desperate need of help. Currently we have two problems:

    1. We cannot get 2 color sensors to work at the same time. We have changed the i2c adress (one is 0x3c and the other 0x4c), we followed Patronum Bots' walkthrough, and still we only get values for one of the two sensors. Also, while both sensors are plugged in neither will activate the LED even when we tell it to.

    2. We are trying to use encoders to get to the beacon as the color sensors won't work together, and a while ago they were working. Now, we have ran the same program 10 times without re-downloading anything and we have had a vastly different result each time. Is this a mechanical issue? We are using the same code that worked 2 weeks ago and still having this problem.

    Does anyone have tips on how to get to the line, follow it, and sense the beacons at the same time? We have also tried Vuforia and it wasn't acting nearly consistent enough either.

    Thanks!
    ~Sammie~
    Team 5026 (I know it says 6932, but we switched teams this year and can't figure out our password from 2 years ago).

  • #2
    To use two color sensors, you need to do two things:
    - physically change one of the color sensor to another non-conflicting I2C address. Change and verify this with the Modern Robotics Core Device Discovery Tool.
    - In your code, you have to tell it the new address of the changed color sensor by doing:
    Code:
    ColorSensor firstColorSensor = hardwareMap.colorSensor.get("FirstColorSensor");
    ColorSensor secondColorSensor = hardwareMap.colorSensor.get("SecondColorSensor");
    secondColorSensor.setI2cAddress(I2cAddr.create8Bit(0x4c));
    firstColorSensor.enableLed(true);
    Did you do both steps?
    Regarding your second issue, there are many reason why your encoder run was not consistent. It could be mechanical issue, it could be a bug in your code. Without addition info, it's hard to tell why. You may want to post your code so people can help to look it over.
    Regarding tips of getting to the beacon, again there are many ways. If you choose to do line following. The first thing is to aim the robot at the line. Drive the robot forward until the sensor detects the line (probably at an angle), then back up and turn to find the line again, follow the line. Then you must have a way to tell if you are close enough to the beacon. That could be done with either an ultrasonic sensor to check the distance to the wall or a touch sensor so it will stop when it hits the wall. Then you need to tell which side has your alliance color. This could be done by another color sensor. Then you push the correct button.
    Like I said, there are many ways to do this depending on your robot's capability (e.g. can your robot move sideways?). Our robot can move sideway so we can do this:
    https://www.youtube.com/watch?v=QHcIzLSJXnw

    Comment


    • #3
      Originally posted by FTC6932 View Post
      2. We are trying to use encoders to get to the beacon as the color sensors won't work together, and a while ago they were working. Now, we have ran the same program 10 times without re-downloading anything and we have had a vastly different result each time. Is this a mechanical issue? We are using the same code that worked 2 weeks ago and still having this problem.
      Son't forget that if you are using encoders, they only get reset automatically when the power goes on.
      If you expect them to start at zero each time you run your opmode you MUST set the mode to STOP_AND_RESET_ENCODER (best done before the start button is pressed)
      and then switch them back to the desired mode when you are ready to do your first move.

      Comment

      Working...
      X