KIPR · Botball Explorer
Activity Sections

Unit 2 · Big Idea 5

Tuning the Follow

Student Lab · Speed, Precision, and the mav Command

Unit Guiding Question
How can a machine make increasingly intelligent ?
Focus
Precision control, speed ratios, and tuning with data
AI Literacy Thread
Intelligent systems are tuned and optimized using evidence, not guesses.
CS1 Concepts
The mav command · vs. Power · Ratios · Experimental Tuning
Game Context
Optimizing your line-follow from Unit 2
What You Need
Explorer robot · calibrated Tophat ( 0) · taped line · this lab sheet
Before you start: type your PIN in the box at the top of the page. Your teacher gave you this number. When you finish, press Submit & Download to turn in your work and save a copy.

Overview

Your robot already follows a line — but does it follow it well? Does it wobble wildly, or glide smoothly? Today you’ll find out, by treating your line-follow like an engineer treats an engine: you’ll change the speeds in a careful, organized way and measure what happens. Along the way you’ll trade in your old k.motor() command for a more precise one — k.mav() — that gives you far finer control over speed.

Core Insight

There’s no single “right” speed. The best line-follow is found by testing — changing one thing at a time and letting the robot’s behavior tell you what works.

By the end of this activity you will be able to:

  • Use k.mav() to drive motors by velocity ( per second) instead of percent power.
  • Explain why k.mav() gives much finer speed control than k.motor().
  • Run an organized experiment changing total speed and the gap between wheel speeds.
  • Use your results to tune your line-follow to its best performance.

New This Time: The mav Command

mav --- move at velocity

You’ve used k.motor(port, power), where power is a percent from −100 to 100. Now meet its precise cousin:

k.mav(0, 750)   # move motor 0 at 750 ticks per second

mav stands for move at velocity. Instead of a percent, you give it a speed in ticks per second — the same ticks your counts. Its range is −1500 to 1500.

Why mav is 15× more precise

Look at the two ranges side by side:

motor:  -100  ...  100     # 100 steps each direction
mav:   -1500  ... 1500     # 1500 steps each direction

That’s 15 times as many speed values to choose from. With motor, the smallest change you can make is 1 percent. With mav, you can fine-tune speed in much smaller steps — which matters a lot when you’re trying to stop a line-follow from wobbling.

To convert your old motor numbers to mav, multiply by 15: motor 50 becomes mav 750; motor 100 becomes mav 1500 (the top speed).

Swapping motor for mav in line_follow

Your steering logic doesn’t change at all — only the command and the numbers do:

if k.analog(0) > MIDPOINT:    # on black, steer right
    k.mav(0, 750)            # was k.motor(0, 50)
    k.mav(1, 300)            # was k.motor(3, 20)
else:                          # on white, steer left
    k.mav(0, 300)
    k.mav(1, 750)

Phase 1 — Activate: Coarse vs. Fine Control

Imagine a faucet with only 3 settings: off, trickle, blast. Now imagine one with a smooth dial you can turn to any flow you want. Which one lets you fill a cup to exactly the right level without overflowing? The dial — because it gives you finer control. motor is the 3-setting faucet compared to mav’s smooth dial.

Why does having more possible speed values (finer control) help you tune a robot that’s wobbling? Use the faucet idea if it helps.

Phase 2 — Concept: Total Speed and the Gap

Your line-follow has two numbers that matter: the fast wheel speed and the slow wheel speed. Two different things change how the robot behaves:

  • Total speed — how fast both wheels go overall. Faster covers ground quicker, but gives the robot less time to react, so it can and jitter.
  • The gap — the difference between fast and slow. A bigger gap turns harder each correction; a smaller gap turns gently.

The experiment plan

You’ll run two organized series. In Series 1, the gap stays at 30 (×15 = 450 in mav terms) while total speed climbs. In Series 2, the gap widens to 40 (×15 = 600) and total speed climbs again. By changing one thing at a time, you’ll see what each does.

Predict: as total speed goes up, do you think the robot will follow the line better or worse? Why?

Phase 3 — Series 1: Hold the Gap, Raise the Speed

Start from your Unit 2 speeds and raise both wheels by 10 (×15 = 150 in mav) each trial, keeping the gap at 30 (×15 = 450). After each run, rate how well the robot followed the line: poor / ok / great. Also note if it jittered.

⚠ Same line, same start

Run every trial on the same line from the same starting spot, so the only thing changing is the speed. That’s what makes it a fair test.

Series 1 — Gap of 30 (mav gap 450)
TrialFast / Slow (mav)Rating (poor/ok/great)Jitter? notes
1750 / 300
2900 / 450
31050 / 600
41200 / 750
51350 / 900
61500 / 1050

As total speed went up (gap held at 450), what happened to how well the robot followed? At what speed did it start to struggle?

Phase 4 — Series 2: Widen the Gap

Now widen the gap to 40 (×15 = 600) — the slow wheel drops, so each correction turns harder. Climb the total speed again and rate each trial the same way.

Series 2 — Gap of 40 (mav gap 600)
TrialFast / Slow (mav)Rating (poor/ok/great)Jitter? notes
1750 / 150
2900 / 300
31050 / 450
41200 / 600
51350 / 750
61500 / 900

Compare Series 2 to Series 1. Did the wider gap (harder turns) help the robot stay on the line, or make it wobble more? At what speed?

Phase 5 — Find Your Best Setting

Now you’re the engineer. Using what your two series showed, pick your own fast and slow mav values and try to get the smoothest, most reliable follow you can. Test, adjust, test again. Your goal: the best line-follow on your robot.

TryYour fast / slow (mav)How well did it follow?
1
2
3
4
5

What was your best fast/slow setting, and why do you think it worked best on your robot?

Your best numbers are probably different from a neighbor’s. Why might the same settings work differently on two robots?

Phase 6 — Connect: The AI Literacy Bridge

AI Literacy Thread

Intelligent systems are tuned and optimized using evidence, not guesses.

You didn’t find your best settings by guessing — you ran an organized experiment, changed one thing at a time, and let the data guide you. This is exactly how real intelligent systems get good. Engineers tuning a self-driving car, or researchers training an AI model, adjust settings (called ), measure the result, and adjust again — thousands of times. The “intelligence” of a system is often the result of careful tuning, not a single lucky setting.

Read each scenario. Think it through, then write your answer.

You changed only one thing at a time (first speed, then the gap). Why would changing both at once make it hard to know what actually helped?

Engineers tuning a real system test settings over and over instead of picking one and hoping. Why is repeated, measured tuning more trustworthy than a single guess?

Phase 7 — Individual Reflection

Complete this section on your own.

1. What does k.mav() do, and how is it different from k.motor()? Why is it more precise?

2. In your experiment, what was the effect of raising the total speed on how well the robot followed the line?

3. What did changing the gap between the fast and slow wheel do to the robot’s turning?

4. Complete this in 2–3 sentences: “Intelligent systems are tuned using evidence, not guesses. This means that to make a robot perform its best, I should…”

Extension Challenges

Finished early? Try one or more of these.

Extension A — Find the Breaking Point

  • Push the total speed as high as it will go and still follow the line. What’s the fastest your robot can reliably go before it loses the line?

Extension B — Tiny Gaps

  • Try a very small gap (like 750 / 700). What does an almost-no-turn correction do? Now a huge gap (1500 / 0). Describe both.

Extension C — Make the Speeds

  • Put your best fast and slow speeds in two variables at the top (like FAST and SLOW). Now you can re-tune by changing two numbers in one place. Why is that better?

Extension D — Looking Ahead: Knowing When to Stop

  • Your follow is smooth now — but it runs for a fixed number of ticks. What if the robot needs to stop when it reaches an object instead? What kind of would tell it something is ahead? (Next lab.)

When you are finished, press the button to turn in your work and save a copy.

KIPR · Botball Explorer · Unit 2 Big Idea 5 — Student Lab