Your first RoboSoccer bot
First lesson · One file · Drive, turn, watch
1. Get a match running together
Your teacher helps install Python and the kit first. In the unzipped kit folder:
python -m pip install .
robosoccer new my_bot.py
robosoccer check my_bot.pyNo local setup yet? Use My bot → Load starter → Check my bot on the website. Choose one route with your teacher; save installation troubleshooting for the setup session.
2. Copy this chaser into my_bot.py
def act(robot_id, sensors, memory):
balls = [obj for obj in sensors["camera"]
if obj["kind"] == "ball"]
if not balls:
return {"move": (0.0, 1.0)} # Turn to search.
ball = min(balls, key=lambda obj: obj["distance"])
bearing = ball["bearing"]
speed = 0.8 if abs(bearing) < 0.4 else 0.0
return {"move": (speed, 4.0 * bearing), "kick": 0.0}The same function controls robots 0, 1 and 2. It turns toward the ball, drives when roughly facing it, and searches when it cannot see it. Leave memory unused for now. Kicking and team roles come in later lessons.
3. Which way should it turn?
Radian is an angle unit: 0.5 rad ≈ 29°. Use the sensor's bearing directly; you do not need to convert it. 4.0 * bearing sets how quickly to turn. move means (forward metres/second, turn radians/second), not x/y movement.
4. Watch one small experiment
robosoccer check my_bot.py
robosoccer run my_bot.py --vs chaser --perfect-sensors --half-seconds 5 --watchChange only 4.0 * bearing to 1.0 * bearing. Predict: faster or slower turns? Watch both replays. Then remove --perfect-sensors. What changes when the ball is missed? Short matches test behavior; the score alone is not your grade.
Stuck? Check these first
| What happened? | Try this |
|---|---|
| Turns the wrong way | Positive bearing and turn both mean left. Do not use 90 for a turn rate. |
| Crashes when the ball disappears | Keep the if not balls branch before using a ball reading. |
| Nothing moves immediately | Kickoff freezes movement for the first second. Keep watching. |
| Command not found | Try python -m robosoccer check my_bot.py; ask your teacher about the Python setup. |
Next: short lessons and experiments. Keep the full handbook nearby as a reference; you do not need to read it all today.