Detect and Charge at an Opponent

Now that the IR receivers have passed the tests, it’s time to use them in a program that makes the SumoBot charge at an opponent it detects with its IR.

Program

This program charges straight ahead if an opponent is detected by both IR sensors.  If the opponent is only seen by the left sensor, the SumoBot pivots left.  Likewise, if the opponent is only seen by the right sensor, the SumoBot pivots right.

  • Download SumoBot-Front-IR-Nav.

SumoBot-Front-IR-Nav.svg

  • In BlocklyProp Solo, click the Open button, and open the SumoBot-Front-IR-Nav.svg file you just downloaded.

 

  • If your Terminal IR Distance Measurements had a max distance of 8 for both sensors, skip to Set POWER to 1 step below.  Otherwise, continue here:
    • If one or both of your IR receivers would not report anything above some value like 5 or 6 with no objects in its path, first make sure you have tried everything in the Troubleshooting section.  If you did and the IR still reports a max distance below 8, then:
      • Right-click the IR Front Navigator function block and select Expand Block.  (There’s an example of this in the How It Works section.)
      • Change the 7 values to one less than the no objects detected distance.  For example, if the no objects detected distance was 6, change the 7s to 5s.
  • Set POWER to 1.
  • Click the Load & Run (Save code to EEPROM)  button to load the program into your SumoBot.
  • Set POWER to 0.

Tests

  • Make an 8 ½ inch tall x 3.5 inch wide cylinder out of a sheet of printer or binder paper and some tape.
  • Disconnect USB, make sure batteries are loaded and take it to the sumo ring.
  • Set POWER to 2.
  • Allow the SumoBot to roam the sumo ring, and verify that it still avoids the border with its QTIs.
  • Next, try placing the paper cylinder 6 inches (or 150 cm) in front of one of the sensors.  The SumoBot should turn toward the object and then start pushing it out of the ring.