LEARN.PARALLAX.COM
Published on LEARN.PARALLAX.COM (https://learn.parallax.com)
Home > cyber:bot Sumo Contests

cyber:bot Sumo Contests

What it’s about

In this basic version of SumoBot wrestling, students will use micro:bit tilt controllers to make the cyber:bot robots push against each other.  The match winning team will be the one whose cyber:bot pushes the other one out of the ring.  This contest can also be expanded with various customizations, like a 3D printed plow, and adjustments to the wheels to make them grip better.

Before you start

Each Student or Team will need:

(1) cyber:bot Robot Kit – with micro:bit

(1) micro:bit GO Bundle

Complete these tutorials first:

Required

  • Get Started with micro:bit and Python
  • Writing micro:bit programs
  • Add modules to your micro:bit
  • Build your cyber:bot
  • Navigation with the cyber:bot

Recommended

  • Dictionary Primer
  • Exception Handling Primer
  • Strings & Characters Primer
  • Cybersecurity: Radio Basics
  • Cybersecurity: Radio Data
  • Cybersecurity: Navigation Control from a Keyboard
  • Cybersecurity: Radio Tilt Control

After You Finish

You will be able to:

  • Compete in a tilt controlled cyber:bot SumoBot contest.
  • Through practice, become familiar with techniques that might be useful in a fully autonomous SumoBot contest.

Parts

Parts

One set for each student or team of students

(1) cyber:bot Robot Kit – with micro:bit (assembled and tested)

(1) USB A to Micro-B cables (assuming two teams will use two different computers).
The cyber:bot kit comes with a cable that’s much longer than the one in the micro:bit kit.

(1) micro:bit v2 Go Bundle, which contains:

(1) micro:bit Module

(2) AAA battery pack

(2) AAA batteries

 

Instructions

Start by getting the tilt control application running for each cyber:bot robot.

  • Each student or team should take half the parts. That’s 1 cyber:bot, 1 USB A to Micro-B cable, 1 micro:bit, 1 battery pack, and 2 batteries.
  • Each student/team must take a different channel in the 0…83 range.
  • For best results, keep the channels evenly separated in the 0…83 range. For example, if there are 9 robots, they can be separated by 10.  One team gets channel 0, the next channel 10, the next channel 20, and so on through channel 80.
  • Each team will have to update each of their script’s channel= settings to their assigned channel before running the script.
  • Each team will complete these activities:
    • Radio-Receive Tilt
    • Radio-Transmit Tilt
    • Radio Tilt Controlled cyber:bot App
    • Radio Tilt Controlled cyber:bot Code
    • Radio Tilt Controller Code
  • When teams have demonstrated tilt control of their robots, they can disconnect their controller micro:bit modules from USB and connect battery packs instad.
    • Connect the battery pack’s JST plug to the micro:bit module’s JST socket.

Load the batteries into the battery pack making sure to match the +/- diagram inside the battery pack.

Have a Tilt Controlled cyber:bot SumoBot Contest

Using the SumoBot Wrestling page as a reference:

  • Construct a Sumo Ring according to the Sumo Ring and Ring Area instructions.
  • Use your Tilt Controlled cyber:bot robots in place of SumoBot Hardware Rules 1 and 2.

Customizations

The existing wheel and tire can be modified, or a a number of separate SumoBot Wheel & Tire kits can be purchased and/or modified.

If your class has access 3D printer and CAD software, designing a plow can be part of the contest.  Here is an example: A Thingiverse Parallax Shield-Bot Front Scoop that will fit on the cyber:bot.

Overview: Autonomous Sumo with the cyber:bot Robot

What it’s about

The cyber:bot doesn’t need remote control for sumo matches; it can also compete autonomously.  As an autonomous Sumo-cyber:bot, it will use sensors to detect its opponent and the white line that surrounds the sumo ring.  The script will make it:

  • Detect and turn away from the edge of the ring
  • Search the ring for opponents
  • Detect and charge at an opponent
  • Push the opponent out of the ring

]

Before you start

Parts Each Student or Team will need:

(1) cyber:bot Robot Kit – with micro:bit

(0.5) QTI Line Follower AppKit for the Small Robot (One of these kits can be split between two cyber:bot robots.)

Complete these tutorials first:

Required

  • Get Started with micro:bit and Python
  • Writing micro:bit programs
  • Add modules to your micro:bit
  • Build your cyber:bot
  • Navigation with the cyber:bot

Recommended

  • Infrared Light Navigation for the cyber:bot
  • QTI Line Follower for cyber:bot

After You Finish

You will be able to:

  • Compete in an autonomous cyber:bot SumoBot contest.
  • Through practice, become familiar with techniques that might be useful in a standard autonomous SumoBot contest.

Simplify Navigation with a Maneuver Function

Functions with parameters can allow you to set not only wheel speeds but run times.  The can also adjust for making the right wheel turn the opposite direction to give you a more intuitive set of statements.  Here is an example of a function call that makes the cyber:bot roll full speed forward for 3 seconds.  Note that the right wheel speed is no longer negative.  The rule for the maneuver function is that positive values are for forward, for either wheel.  The 3rd argument (3000) is the number of milliseconds to execute the maneuver.

Script: general-maneuver-function

  • Make sure the cyber:bot board’s power switch is set to 1 and the battery pack is plugged into the cyber:bot board.
  • Open cyberbot-template-with-blink with the micro:bit Python Editor at http://python.microbit.org/v/3
  • Replace its default script with individual-maneuver-functions-example shown below.
  • Click the Save button to save a copy of your work.

Tests

  • Click the Send to micro:bit button to flash the script into the micro:bit.
  • Disconnect the programing cable and put the cyber:bot on the floor.
  • Move the switch to position 2 and press/release the reset button on the micro:bit. (Or, set PWR to 0, then back to 2.).
  • Verify that the script makes the cyber:bot roll forward for 3 seconds, then turn in place to the right.
  • Set the PWR switch to 0 when the cyber:bot is not in use, and remember to unplug the battery pack from the cyber:bot board if you are done for the day.

How It Works

On line 5, the maneuver function definition has three parameters: vL (velocity left) vR (velocity right), and t (time, in milliseconds).  The three arguments in the function call on line 12 get passed to those parameters.  Likewise with the function call on line 13.  Line 7 takes the negative of vR, which is how the function takes positive values for forward and negative ones for backward.  The if vR is not None: statement prevents the vR = -vR statement from being executed when vR is None.  vR = -None would cause an exception because None is not a number and does not work with arithmetic operators.

Try This

Allowing the motors to come to a full stop can make maneuvers more predictable.  This next script makes the cyber:bot go forward, left, right, left, backwards, stop.  Between each actual maneuver, there’s a call setting the wheel speeds to None for 0.5 s.  This allows the wheels to come to a full stop before the next maneuver.

  • Try this script as-is first.
  • Then, comment all but the last maneuver(None, None, 500) call by adding a hashtag symbol to its left. Then, re-run the script.
  • What differences did you notice in the cyber:bot robot’s navigation?

Your Turn

While your cyber:bot SumoBot is searching for its opponent, splitting up maneuvers into little pieces will be important.  By checking the sensors between each 26 ms maneuver() call, your bot can keep rolling while searching for an opponent.  Here is an example where the cyber:bot calls the maneuver function 100 times, which takes about 2.6 seconds.  Adding sensor measurements between each call will make it take longer, but your robot will still be able to check for its opponent or the sumo ring’s border many times per second.  More about this in upcoming activities.

Connect and Test QTI Sensors

Since the infrared detectors are busy looking forward for opponents, how can the cyber:bot detect the edge of the SumoBot ring and turn away.  One way is with the QTI line sensors, which can detect the difference between black and white surfaces.

Parts

Two sets of the parts below come with each QTI Line Follower AppKit for the Small Robot kit.

6 jumper wires: 2 each – red, blue, black

2-each of the parts shown in the picture

Assembly

Attach the QTIs to the bottom of the robot as shown.

Schematic

This is the schematic for the left and right QTIs.  You will see how they are connected in the Wiring section.

Wiring

Connect the servo extension cables to the QTIs, making sure that the white wire is plugged into the W pin, the red wire is plugged into the R pin, and the black wire is plugged into the black pin.

Double check this for both QTIs

Run the servo extension cables through the space between the tail ball and chassis.

Connect the extension cables to the 3-pin headers.

Make sure the cables do not cross at any point.  This will ensure the P8 I/O pin is connected to the left QTI and the P7 I/O pin is connected to the right.

Make sure the servo extension cables are plugged onto the 3-pin headers so that the black wires are plugged onto the pins that share the same row.

Hardware Setup

  • Set the cyber:bot board’s power (PWR) switch to Position 0.
  • Make sure the battery holder is loaded with 5 AA batteries.
  • Make sure the battery holder’s barrel plug is firmly plugged into the cyber:bot board’s barrel jack.
  • Connect your micro:bit module to your computer with a USB cable.

Software Setup

  • In a Google Chrome or Microsoft Edge browser, go to python.microbit.org to open the micro:bit Python Editor.
  • Go to Add modules to your micro:bit and watch the video on how to add modules to a project in the micro:bit Python Editor.  It’s in the section titled: Adding a Module to micro:bit Filesystem.
  • Still on the Add modules to your micro:bit page, follow the instructions below the video to download and unzip the cyberbot-micropython archive and add the cyberbot module to the micro:bit Python Editor’s Project settings.
  • Add two more cyberbot-micropython modules to the project settings: qti.py and intbits.py.
  • If the project settings are not open, click the editor’s project tab.

  • Verify that the Project settings and verify that they resemble this:

Example Script: cyberbot_sumo_test_qtis

  • Set the project’s name to cyberbot_sumo_test_qtis, enter the script below, and then click Save.
    (See Save & Edit Scripts and Flash Scripts with Python Editor.)
  • Click Send to micro:bit.
    (See Flash Scripts with Python Editor.)

Tests

  • Connect the cyber:bot to the computer with the USB cable.
  • Click the Send to micro:bit button to load the script into the micro:bit.
  • Set the PWR switch to 1.
  • Set the cyber:bot on the sumo ring with both QTIs over the black central part, and verify that both indicator lights on the micro:bit are on.
  • Verify that when the cyber:bot is positioned with one QTI over the white border, the light on that side turns off.
  • Test each side separately over the white border, and verify that each light turns off.
  • Test both lights over the white border together and verify that they both turn off.

Troubleshooting

If the lights do not behave as expected, double check all electrical connections and each line of code.

Try This: Robot Avoids the White Border

  • Change the project name from cyberbot_sumo_test_qtis to cyberbot_sumo_avoid_edge.
  • Enter the script below into the micro:bit Python editor, then click Save.

Don’t worry about errors on lines 15 and 16.  The micro:bit module’s MicroPython runtime engine handles it just fine even though the editor’s syntax checker doesn’t recognize it.

  • Click the Send to micro:bit button to load the script into the micro:bit.
  • Set the PWR switch to 2.
  • Verify that the cyber:bot travels across the sumo ring’s black surface and backs up and turns away whenever it reaches the white edge.

Your Turn: Adjust Speeds & Turn Times

Adjust speeds up to +/- 115.

If one QTI sees the line, try tuning so that it turns away by about 120°.

If both QTIs detect in at the same time, it’s best to have the cyber:bot turn closer to 180°.

Add the IR Circuits

Here, you will add the infrared detection circuits to the QTIs.  With this, your cyber:bot SumoBot will have a way to detect and charge an opponent AND detected and avoid the edge of the sumo ring.

Parts List
(2)  IR receivers
(2)  IR LEDs (clear case)
(2)  IR LED shield assemblies
(2)  Resistors, 220 Ω (red-red-brown)
(2)  Resistors, 2 kΩ (red-black-red)
(misc) Jumper wires

Gather the parts in the Parts List, using the drawings below to help identify the infrared receivers, LEDs, and shield assembly parts.

Make sure you are using infrared LEDs and not phototransistors.  The infrared LED has a taller and more rounded plastic dome:

Assemble the IR Headlights

The infrared LEDs are designed to sit in the standoff tubes a certain way.  The flat spot on the LED dome matches a flat ledge inside the tube. Holes on the bottom of the tube are labeled for the anode (+) and cathode (-) leads.

  • Insert the infrared LED into the LED standoff tube, threading the anode and cathode leads through their respective holes in the bottom.  If properly aligned, the LED should drop in place without pushing.
  • Slip the short tube over the IR LED’s clear plastic case, tab end first. The tabs should snap into the standoff, holding the LED in place.

Add the IR Object Detection Circuit

Each IR object detector requires its own IR LED and IR receiver, mounted together on a corner of the breadboard closest to the very front of the cyber:bot.

Note that the anode lead of each IR LED connects to a 2 kΩ resistor (red-black-red).  Also note that each IR LED and each IR receiver has its own ground connection wire.  In the diagram, the IR LED ground wires are shown in blue to help tell them apart.

  • Put the cyber:bot board’s power switch in position 0 — standard practice before building or modifying circuits.
  • Build the circuit in the schematic below, using the wiring diagram as a reference for parts placement.

Watch your IR LED anodes and cathodes!  
The anode lead is the longer lead on an IR LED by convention. The cathode lead is shorter and mounted in the plastic case closer to its flat spot.  These are the same conventions as the red LEDs in the kit.

Test IR Circuits and Charge at the Opponent

In this activity, you will build and test IR object detection circuits and then write a script to make the cyber:bot charge an opponent based in object detection.

Example Script: cyberbot_sumo_ir_test

  • Open cyberbot_sumo_avoid_edge with the micro:bit Python Editor.
  • Change the project name to cyberbot_sumo_ir_test.
  • Enter the script below into the micro:bit Python editor, then click Save.

Tests

  • Connect the cyber:bot to the computer with the USB cable.
  • Click the Send to micro:bit button to load the script into the micro:bit.
  • (The cyber:bot can be left connected OR disconnected from USB at this point.)
  • Set the PWR switch to 1.
  • Set the cyber:bot on the sumo ring with both infrared detectors pointing away from any nearby objects.
  • Verify that both IR indicator lights are on.
  • Place an object in front of the right IR detector and verify that the right IR indicator light turns off.
  • Place an object in front of the left IR detector, and verify that the left IR indicator light turns off.
  • Place an object in front of the left IR detector, and verify that the left IR indicator light turns off.
  • Place an object in front of both IR detectors, and verify that the both indicator lights turns off.

Troubleshooting

If the lights do not behave as expected, double check all electrical connections and each line of code.

Test for Infrared Interference

Follow the instructions in the Check for IR Interference page.

Sensitivity (Distance) Adjustments

This will be important

Follow the instructions in the Series Resistance and Range page.  Return here when you are done.

Try Other Infrared Navigation Examples

Here are some general infrared navigation examples:

Navigate and Avoid Obstacles

Faster IR Navigation

Drop-off Detector

Simulate a Drop-off with Poster Board

Avoid Drop-offs

Return here when you are done.

Adjust IR LEDs to Point Straight Ahead

For best results against a competitor, adjust the IR LEDs and receivers so that they point straight ahead.

Try This: Infrared Charger Mode

  • If it’s not already open, click the Open button and reopen cyberbot_sumo_ir_test
  • Set the project name to to cyberbot_sumo_ir_charger.
  • Enter the script below into the micro:bit Python editor, then click Save.
  • Disconnect the cyber:bot from USB, set it on the floor, and set PWR to 2.
  • Verify that the cyber:bot chases your hand:
    • If neither or both IR detectors see an object, the cyber:bot should roll straight forward.
    • If one IR detector sees an object, it should turn toward that detector.

Basic Autonomous Sumo

This script combines these two functionalities:

  • cyberbot_sumo_avoid_edge from Connect and Test QTI Sensors
  • cyberbot_sumo_ir_charger from Test IR Circuits and Charge at the Opponent

It is good for basic autonomous sumo with the cyber:bot if the basic rules are used where the match starts with the robots start by facing each other.

Scanning for the Opponent

This is not a competition script, it just demonstrates how using a scan function to “look around” for an opponent could work.

The scan function checks for an opponent every 30 ms as it executes a list of maneuvers.  Each maneuver is a list that you can use to set the left and right wheel speeds and the number of 30 ms time increments each maneuver should last.

On the sumo ring, this script will just cause the SumoBot to alter its direction slightly when it “sees” an object.  It also turns away from the white borders.

Autonomous Sumo with Scanning

This script integrates the scan function into cyberbot_sumo_autonomous_basic from the Basic Autonomous Sumo page.  Adjust the scan function to give your cyber:bot SumoBot an advantage in the ring.  This is especially useful for more advanced contest rules where the orientation of the cyber:bot SumoBot robots are drawn at random.

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024


Source URL:https://learn.parallax.com/courses/cyberbot-sumo-contests/
Links