Today’s mission 5 min
Run one routine ten times, score how often it works, and fix the step that fails most.
Your robot worked once. Will it work at the competition, on a different table, with a different battery, while you are nervous? Only numbers can answer that. Today you collect them.
Nine out of ten beats fast. A routine that scores every time is worth more than a faster one that scores half the time. Judges do not award points for nearly.
The idea — success rate and the weakest step 10 min
Success rate is hits divided by attempts. Seven hits in ten runs is 7/10, or 70%. Say it that way, never “it mostly works”.
A routine is a chain of steps. If any step fails, the routine fails. So the routine can never be more reliable than its weakest step. That is the step to fix first.
Decide what success means before you start. For example: “the object is fully inside the zone, and the robot is back in base”. Write it down. Do not change it halfway through because a run nearly worked.
The scoresheet. Draw one row per run and one column per step. Tick the steps that worked. Cross the first step that failed, and stop that row there.
| Run | Leave base | Square up | Follow line | Grab | Return | Battery mV | Note |
|---|---|---|---|---|---|---|---|
| 1 | ✓ | ✓ | ✓ | ✗ | 8210 | claw missed by a stud | |
| 2 | ✓ | ✓ | ✓ | ✓ | ✓ | 8190 | |
| … |
After ten rows, count the crosses in each column. The column with the most crosses is your weakest step.
Blocks vs Python 15 min
Both programs repeat a routine ten times and count the successes. You say whether each run worked by pressing a button.
SPIKE word blocks
when program starts :: events hat set [hits v] to (0) :: variables repeat (10) wait until <is [left v] button [pressed v]? :: sensors> my routine :: myblocks wait until <<is [left v] button [pressed v]? :: sensors> or <is [right v] button [pressed v]? :: sensors>> if <is [right v] button [pressed v]? :: sensors> then change [hits v] by (1) :: variables end end write (hits) :: display
Pybricks Python
from pybricks.parameters import Button from pybricks.tools import wait from base import hub, routine def wait_for(buttons): while True: pressed = hub.buttons.pressed() for b in buttons: if b in pressed: while hub.buttons.pressed(): wait(10) return b wait(10) hits = 0 for run in range(10): print("Run", run + 1, ": place robot, press LEFT") wait_for([Button.LEFT]) routine() print("RIGHT = hit, LEFT = miss") if wait_for([Button.LEFT, Button.RIGHT]) == Button.RIGHT: hits += 1 print("Success rate:", hits, "/ 10") hub.display.number(hits)
| Block | Python | Watch out |
|---|---|---|
| repeat 10 | for run in range(10): | run counts 0 to 9, so print run + 1. |
| wait until left button pressed | wait_for([Button.LEFT]) | Pybricks has no wait-until block. You write the loop yourself, once. |
| (nothing) | while hub.buttons.pressed(): wait(10) | Wait for the release too, or one press counts twice. |
| change hits by 1 | hits += 1 | |
| (any button) | Button.LEFT, Button.RIGHT | Avoid CENTER: it is the stop button and ends the program. |
routine is one mission from your library. Replace it with whichever routine you are testing.
Write it from scratch 20 min
Write a program called tenruns, from a blank file. It does everything the comparison above does, and three things more:
- It prints the battery voltage at the start of every run, so the scoresheet column fills itself.
- It times every run with a
StopWatchand keeps the times in a list. - At the end it prints the fastest, the slowest and the success rate.
Keeping the times
times = [] # inside the loop, after the routine: times.append(watch.time()) # after the loop: print("fastest", min(times), "slowest", max(times))
Choose your success rule now and write it at the top of the program as a comment. Both team members must agree with it before the first run.
Test and measure 15 min
Do the ten runs. Fill the paper scoresheet for every run: which step failed, and a few words on how.
- Place the robot the same way every time. Use a jig, a line on the mat or the base wall. If placement varies, you are testing your hands, not your robot.
- Count the crosses in each column. Which step is weakest?
- Is the slowest time much slower than the fastest? A big spread often means a step is close to failing.
- Did failures get more common as the battery voltage fell?
Break it, fix it 10 min
Each harness below has one mistake. Two crash. One runs but counts wrongly, which is worse, because the numbers lie.
Bug 1
hits = 0
for run in range(10):
routine()
if wait_for([Button.LEFT, Button.RIGHT]) == Button.RIGHT:
hits += 1
print("Success rate:", hit, "/ 10")Bug 2
def wait_for(buttons):
while True:
pressed = hub.buttons.pressed()
for b in buttons:
if b in pressed:
return b
wait(10)Bug 3
times = []
for run in range(10):
watch = StopWatch()
routine()
times.append(watch.time())
print("fastest", min(times))Bug 2 has no error message. Run it and watch the count. If a run you marked as a miss was counted, the harness is wrong. Test your test before trusting it.
Solo challenge — no coach 10 min
No coach, no help. At WRO your coach may not touch the robot or the code. Close this page. You may use your own earlier programs and the Pybricks documentation, nothing else.
Fix the weakest step. Take the column with the most crosses. Change one thing about that step: the robot, a speed, a threshold or the order of moves. Then run the ten runs again.
Done means: a second scoresheet with a higher success rate than the first, and one sentence on what you changed and why it helped.
Engineering journal 5 min
Today’s entry:
- your success rule, word for word
- both scoresheets, before and after
- the weakest step, and the one change you made to it
- fastest and slowest times, and the battery voltage of each
- which other routine you will test ten times next