The answersDownload the PDF
Worksheet

3.2 Proportional control

Control · Robot club · about 15 min

BugBotLab
NameClassDate

What this lesson is about

Correct in proportion to the error. Gain, sign, feedback.

Questions 6 marks in all

  1. [1 mark]What does a proportional controller do?

    1. APushes in proportion to the error: hard when far off, gently when close
    2. BGoes at one fixed speed until the error is zero
    3. CTurns a set amount every loop
    4. DWaits until the error is big before doing anything
  2. [1 mark]The gain is 4 and the heading error is 7.5 degrees. What rotation does drive(70, 0, error * 4) ask for?

  3. [1 mark]What does this program print?

    def wrapped(h):
        return (h + 180) % 360 - 180
    
    for heading in [10, 350]:
        error = wrapped(0 - heading)
        print(heading, error * 4)
  4. [1 mark]You write drive(70, 0, -error * 4) by mistake. What happens?

    1. AThe controller runs away and the error grows
    2. BThe robot holds the heading more gently
    3. CNothing, the sign does not matter
    4. DThe robot drives backwards
  5. [1 mark]Why is it called a feedback loop?

    1. AThe heading comes out of the robot and goes back to the motors as a correction
    2. BThe robot prints its heading every loop
    3. CIt uses a for loop
    4. DThe robot drives in a circle
  6. [1 mark]Why does the P controller not need bursts and settling like the crude fix?

    1. ASmall errors give small rotations, so the correction fades away with no overshoot
    2. BIt always drives at a low speed
    3. CIt stops after every loop
    4. DIt only runs once

The task: hold the heading

Drive into the green zone and finish still facing 0, within 6 degrees, on the curving robot.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

# drive forward at 70 for 70 cm, then stop
forward(70, distance=70)

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/3-2-proportional-control/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Print the error every tick and watch it shrink.
  2. Hold a heading of 20 instead of 0, so the robot drives a straight diagonal.
  3. Replace wait(0.1) with wait(0.5). What happens, and why?