← Back to ROOTS CoachFIELD NOTE 02 · SPEED CONTROL LABV2 EXPERIMENT
FIRST PRINCIPLES · INERTIA

Move quickly.
Arrive gently.

A robot that stops abruptly may drift, tip, or overshoot. Explore the four-stage speed-control idea behind a more repeatable FLL run.

COACH QUESTIONWhy do we slow down before we reach the target?Predict first. Then run the wheel and watch the speed change.
TEACHING PLAN · 4 STAGESPREDICT → TEST → EXPLAIN
01 · SLOW-MOTION SIMULATIONREADY
Speed profilefour stages · speed over distance
MAX 70 / 100
Live position
1
2
3
4
Acceleration
Deceleration
Speed
Distance
drawn speed profile live position
STARTDESTINATION · 1000 mm
1
2
3
4
The wheel follows the same 2-point speed change as the control loop: 2% per step, capped at 70%.
CURRENT STAGE1 · Accelerate
SIMULATED SPEED0 / 100
TRAVELLED0 mm
earlierlater
02 · CONNECT THE IDEASPSEUDOCODE + PYTHON

One control idea,
two ways to write it.

Pseudocode helps you see the decision tree without getting distracted by Python punctuation. Python makes the same logic precise and repeatable inside the loop.

ENCODER CHECKmotor.relative_position(right_motor)reads how far the right drive motor has rotated. When it reaches ro_slow, the program switches from acceleration/cruising to deceleration/finish.
PSEUDOCODEINDENTED DECISION TREE
IF position < ro_slow:
    IF speed < max speed:
        CHANGE speed BY speed change
    ELSE:
        SET speed TO max speed
ELSE:
    IF speed > min speed:
        CHANGE speed BY -speed change
    ELSE:
        SET speed TO min speed
Indentation shows which instructions belong inside each IF or ELSE branch. The outer decision chooses acceleration/cruise or deceleration/finish.
SPIKE PRIME PYTHONTYPE + CHECK
VARIABLES TO USEStart with these exact names. Python treats spelling, capitals, and underscores as different names.
speedthe current motor speed
max_speedthe fastest speed we allow
min_speedthe gentle finishing speed
speed_change2 percentage points added or subtracted each loop
ro_slowthe encoder position where slowing begins
ro_stopthe encoder position where the robot should stop
right_motorthe drive motor used for the convenient encoder reading
left_motorthe other drive motor, if you choose its encoder

Write the control loop from your reasoning. Start with the repeating loop, then add the position split, then the two speed checks. Your code is checked for structure, but the answer is not displayed first.

Live check: no syntax warning yet. Keep building one small branch at a time.
WRITE THIS STAGEWhy add a small change instead of jumping straight to max speed?speed < max_speed
03 · KNOWLEDGE CHECKPOINTQUESTION 1 / 4

Think first.
Then write.

Answer each question before the next one opens. The goal is to understand why the code is shaped this way, not just to memorize the lines.

1234
1 · OPTIONAL ENCODER CHOICE

Do you have to use motor D, the right motor, to track the encoder?

Think about convenience, not a hard rule. Which answer best matches a straight-driving robot?

04 · COACHING PROMPTSCHOOSE A STAGE TO INSPECT
05 · THINK LIKE AN ENGINEERBEFORE YOU CHANGE THE CODE

What would you test first if the robot still drifted?

Choose a hypothesis. Good troubleshooting starts with a measurable question, not a random change.