RoboticsEngineer

Mini-Sumo Robot with a Raspberry Pi Pico

Build a small, low, pushing robot that finds its opponent with ultrasound and stays inside the ring using edge sensors.

LevelEngineer
Time4 h
Est. cost~$113
Steps5

Robot sumo is a classic school and club competition: two autonomous robots try to push each other out of a black ring with a white edge. Mini-sumo robots are usually limited to about 10 × 10 cm and 500 g — check your event's rules.

⚠ SAFETY
Keep fingers clear of the wheels during testing and use protected cells. LiPo batteries can catch fire if punctured, overcharged or shorted. Charge in a LiPo bag, never unattended, and always remove propellers while working on the bench.

Mission steps

  1. Design a low wedge

    Print a body with a sloped front plate that slides under the opponent, keeping weight low and over the wheels.

  2. Mount motors and sensors

    Two N20 motors on the TB6612, one line sensor at each front corner looking down, and the ultrasonic sensor facing forward (echo through a voltage divider).

  3. Program the 5-second start

    Competition robots must wait five seconds after the start button before moving.

  4. Write the strategy

    Edge sensors have top priority: back up and turn. Otherwise spin to search, and charge at full power when the opponent is within 40 cm.

  5. Practice

    Paint a ring with a white edge on plywood and tune turn times and speeds against a friend's robot.

Code

from machine import Pin, PWM, time_pulse_us
import time

def motor(pwm, a, b):
    p = PWM(Pin(pwm)); p.freq(1000)
    return p, Pin(a, Pin.OUT), Pin(b, Pin.OUT)
ML, MR = motor(10, 11, 12), motor(15, 14, 13)
Pin(9, Pin.OUT).value(1)                       # TB6612 STBY

def drive(m, s):
    p, a, b = m
    a.value(s > 0); b.value(s < 0); p.duty_u16(int(abs(s) * 65535))

edgeL, edgeR = Pin(6, Pin.IN), Pin(7, Pin.IN)  # 0 = white edge (check your sensor)
trig, echo, start = Pin(16, Pin.OUT), Pin(17, Pin.IN), Pin(20, Pin.IN, Pin.PULL_UP)

def dist():
    trig.value(1); time.sleep_us(10); trig.value(0)
    t = time_pulse_us(echo, 1, 6000)
    return t / 58 if t > 0 else 999

while start.value(): pass
time.sleep(5)                                  # rule: wait 5 s
while True:
    if not edgeL.value() or not edgeR.value():
        drive(ML, -1); drive(MR, -1); time.sleep_ms(250)
        drive(ML, 1); drive(MR, -1); time.sleep_ms(300)
    elif dist() < 40:
        drive(ML, 1); drive(MR, 1)             # charge!
    else:
        drive(ML, 0.5); drive(MR, -0.5)        # search

Tip: test every script on the bench before installing it in a moving machine.

Questions

How do I win more pushes?

Traction and a low wedge matter more than speed. Use soft rubber tyres, keep them clean and put the weight over the drive wheels.