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.
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.
motor.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.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 speedspeedthe current motor speedmax_speedthe fastest speed we allowmin_speedthe gentle finishing speedspeed_change2 percentage points added or subtracted each loopro_slowthe encoder position where slowing beginsro_stopthe encoder position where the robot should stopright_motorthe drive motor used for the convenient encoder readingleft_motorthe other drive motor, if you choose its encoderWrite 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.
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.
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?
What would you test first if the robot still drifted?
Choose a hypothesis. Good troubleshooting starts with a measurable question, not a random change.