Sumo robot

Lego sumo robot competition

Have you ever asked the question, what is robot sumo? So have we! Robot-sumo, or pepe-sumo, is a sport in which two robots attempt to push each other out of a circle (in a similar fashion to the sport of sumo). The robots used in this competition are called sumobots.

The engineering challenges are for the robot to find its opponent (usually accomplished with infrared or ultrasonic sensors) and to push it out of the flat arena. A robot should also avoid leaving the arena, usually by means of a sensor that detects the edge.

The most common “weapon” used in a sumobot competition is an angled blade at the front of the robot, usually tilted at about a 45-degree angle towards the back of the robot. This blade has an adjustable height for different tactics.

There are also Lego Mindstorms EV3 sumo robots, in which EV3 robots compete. The robots usually have to fit in a one-foot cube.

Classes are further divided into remote-controlled and autonomous robots. Also, there might be a tethered category (varies)

image0

In this module cycle of project [p]:ROBOT you will learn how to program your own real robot that can move around, react and interact with the world, the basic fundamentals of every robot in the world. You will learn how to use touch sensors to detect objects in the world. You will detect colors and light using the color sensor, making it possible to follow lines, and you will beam out different colors to show the world what mode your robot is in. You will measure distances between objects. By combining all of the above you will at the end of the project have the knowledge to build your own robot to do whatever pleases you, be it world domination or a new cuddly friend to your pet. To make this possible you will be using a new generation robotics kit from Lego Mindstorms called EV3, but instead of using the default limited program that ships with it, you will be using programming language Python to program it directly giving you full control over everything.

Prerequisite

What students should know before:

  • lesson: Surveyors Wanted to Explore Mars and its Moons

Time constraints:

  • starting from 90 min - double lesson

Preparing For This Tutorial:

  • The LEGO Mindstorm EV3 Core set

Setting up in 12 easy steps

  1. Obtain a suitable microSD memory card.

  2. Download the latest Linux Debian Stretch ev3dev image.

  3. Download and install Etcher, a free utility that will allow you to flash the ev3dev image to the microSD card.

  4. Use Etcher to flash the image to the card.

  5. Insert the card into the EV3, boot the EV3, do some minor configuring and establishing a connection to the computer via USB, WiFi, Bluetooth or Ethernet.

  6. Download and install Microsoft Visual Studio Code (VS Code). This is a free multi platform code editor, compatible with Windows, Mac OS and Linux.

  7. Write and run some non-EV3 Python scripts.

  8. Download and unzip the starter project.

  9. Open VS Code, open the starter project folder and install two extensions.

  10. Configure VS Code.

  11. Connect VS Code to your EV3.

  12. Write and run your first EV3 Python script!

Video tutorial:

https://youtu.be/TNXqizQTZhs

Link step by step: https://sites.google.com/site/ev3devpython/

setting-up-vs-code

The LEGO Mindstorm EV3 Robot that coincides with this tutorial comes from building specific sections found Building_instruction_sumo.html

Effects

Computer science - These lessons told you how to create the program using a color sensor.

Exercise

GOAL

The goal of Lego Sumo is for a Lego Mindstorms robot (EV3) to push or flip an opponent robot out of the ring within the allotted time frame. We realize that there are many variations to the rules for Lego Robot Sumo; these will be the rules for this tournament and we ask that entrants read and be familiar with this particular rule set at the time of the tournament, in order to avoid surprises.

TEAM

A “team” consists of one or more students who have built a robot for this event. The robot must be an autonomous robot the team has constructed themselves prior to the tournament to the specifications below. There will be limited time for adjustments and changes to the robots and their programming during the event. (There is a FREE workshop for help building and programming the robots in the prior to the event. Only one team member may enter the outer ring to start the robot; other team members may watch from outside the outer ring. Each team/robot will be assigned a number on check-in and should have a unique name or identity to be easily recognized by spectators and officials when on the field and when scoring.

Lego sumo rules

Robot Construction

The sumo robot may only be built of official Lego parts, which cannot be held together by any means other than the standard Lego construction methods (no tape, glue, stickers, etc.). No homemade sensors, multiplexores, nor modifications to Lego elements are allowed. No modification to Lego parts by gluing, cutting nor melting is allowed. Up to FOUR motors with rotation sensors are allowed, and any other sensors manufactured by Lego may be used. No “made for Lego’’ third party sensors are permitted for this tournament. It may include attachments as tactical or strategic elements that are passive or motorized, but may not include projectiles or other parts that separate from the robot. It is encouraged that robots be decorated or themed with Lego parts. There will be limited time and space for last minute design improvements and adjustments, however, the robots should be completed at the time of registration, and once check-in takes place, the robot design or its programming may no longer be modified. Robot battery should also be sufficiently charged once the robot is checked in.

Example solution

Theory is in O1 Sumo robot lesson.

Answer for Quiz

Color Sensor Quiz

1. How does the LEGO EV3 color sensor work? The light sensor detects the brightness of the light it receives and uses a scale of 0 (very dark) to 100 (very light). Then it sends this signal to the intelligent brick/ computer.

2. Provide an example “stimulus-sensor-coordinator effector-response” framework using the EV3 color sensor. Example: light > EV3 color sensor > (transmission to coordinator) value sent to EV3 brick via wire > brick sends a signal to the EV3 motors > robot moves

3. Give some examples of color sensors in engineering systems. Examples: cameras; sensors that turn lights on when it gets dark; porch lights, streetlights and car headlights that turn on automatically in low light or at night

Short help on programming

#!/usr/bin/env python3

from ev3dev.ev3 import \*

from time import sleep

import os

# MAIN TASK:

"""

When a martian colony is established, it's likely that it's colonists

will have to work a lot, and won't have that many things to do

when they're not working. Sumo robot competitions may be an interesting

form of entertainment that would require design and programming
intuition.

To confirm this, can you write a program for a sumo robot?

In it's most basic form, a sumo robot has to:

\* Move forward

\* Stay in the sumo ring

\* be able to find and move towards the opponent's robot

"""

# BONUS TASK:

"""

\* Find out what happens when you send a command to the flipper motor

\* Use the gained knowledge to your advantage

"""

# set the font for printing onto the screen

os.system('setfont Lat15-TerminusBold14')

print('Initializing...')

# Attach and the motors responsible

# for moving the robot

LeftMotor = LargeMotor('outD')

RightMotor = LargeMotor('outB')

# Attach and configure the flipper motor

Flipper = LargeMotor('outC')

# Initialize the color sensor

# for sensing the boundary

# of the arena (input port 4)

LineSensor = ColorSensor('in4')

LineSensor.mode = 'COL-REFLECT'

# Initialize the ultrasonic sensor

# for measuring the distance

# between the robot and it's opponent (input port 1)

DistSensor = UltrasonicSensor('in1')

DistSensor.mode = 'US-DIST-CM'

# Get the button reader

Buttons = Button()

# Send the user some information

print('Init finished.');

print('Waiting for user input');

print('Press the center button to start.');

# Sumo robots have to wait three seconds before starting

# whatever program they run in order to avoid

# harming the user

while True: # forever

  # if the center or middle button is pressed

  if Buttons.enter == True:

    print('Starting program in')

  print('3..')

  sleep(1)

  print('2..')

  sleep(1)

  print('1..')

  sleep(1)

  print('Program started!')

  break;

# Everything below this comment should be for the students to figure out

SEARCH_RESOLUTION = 15 # the amount of times the ultrasonic sensor is
polled during the turn period

TURN_AMOUNT = 1.25 # the amount of time spent turning when the color
sensor detects a low-light area

FlipperOriginalPos = Flipper.position_sp

while True: # forever

  colorValue = LineSensor.value()

  distanceValue = DistSensor.value()

  # if the color sensor detects an area of low brigtness

  # which in our context means that it has detected the edge of the ring

  if colorValue < 20:

  # stop both movement motors

    LeftMotor.stop()

    RightMotor.stop()

    # move the robot back a bit

    LeftMotor.run_forever(speed_sp = -1000)

    RightMotor.run_forever(speed_sp = -1000)

  sleep(0.5)

# run the left motor forwards but slower

LeftMotor.run_forever(speed_sp = 900)

# run the right motor backwards

RightMotor.run_forever(speed_sp = -1000)

# while the robot is turning

# this loop will run from 0 to 15

for i in range(SEARCH_RESOLUTION):

  distanceValue = DistSensor.value() # read the distance sensor value

  if distanceValue < 700: # if the distance is less than 70 centimeters

    break # break out of the loop

    # otherwise, sleep for the amount of time spent turning

    # divided by the amount of times we're

    # polling the distance sensor

    sleep(TURN_AMOUNT/SEARCH_RESOLUTION)

  continue

  else: # if the robot hasn't run over the border,

  # continue running the motors forward

    LeftMotor.run_forever(speed_sp = 1000)

    RightMotor.run_forever(speed_sp = 1000)

  # if the distance sensor detects something less than 7 cm away

  if distanceValue < 70:

  # move the flipper motor upwards as quick as possible

    Flipper.run_to_abs_pos(position_sp=20, speed_sp=1000, stop_action="hold")

  # else if the flipper motor's position is not at it's original spot

  elif Flipper.position_sp != -FlipperOriginalPos:

  # move the flipper motor to it's resting position

    Flipper.run_to_abs_pos(position_sp=FlipperOriginalPos, speed_sp=1000, stop_action="hold")
Next Section - Surveyors wanted to explore Mars and its Moons