The answersDownload the PDF
Worksheet

U5.7 Project: park it

Feedback control · University · about 45 min

BugBotLab
NameClassDate

What this lesson is about

Three loops at once: x, y and heading, all settling together in a tight box.

Questions 6 marks in all

  1. [1 mark]The angle wrap from the parking controller. What does it print?

    def wrapped(a):
        return (a + 180) % 360 - 180
    
    print(wrapped(90 - 350), wrapped(270), wrapped(-190))
  2. [1 mark]The world-frame velocity is turned into drive commands at heading 90. What does it print?

    import math
    V_MAX, V_LAT = 20.0, 15.0
    wx, wy, h = 13.0, 0.0, 90.0
    a = math.radians(h)
    fwd = 100 * (wx * math.sin(a) + wy * math.cos(a)) / V_MAX
    lat = 100 * (wx * math.cos(a) - wy * math.sin(a)) / V_LAT
    print(round(fwd, 1), round(lat, 1))
  3. [1 mark]The heading is read once, before the loop, and used for all the maths while the heading controller turns the robot 130 degrees. What does the lesson say happens?

    1. AThe robot drives away from the target and into the edge of the mat
    2. BIt curves in slowly but still parks
    3. CThe robot spins on the spot
    4. DNo visible effect, since the position loop corrects it
  4. [1 mark]Why should the position gain and the heading gain not simply be equal?

    1. A90 degrees of heading error and 90 cm of position error are different sizes of problem, and both errors should reach zero together
    2. BHeading is measured in radians inside drive()
    3. CThe heading loop must always be ten times faster
    4. DEqual gains make the loops unstable
  5. [1 mark]The robot steers by odometry() instead of position() and heading(). Over one short park it ends a couple of centimetres further out, and over a long run it drifts much further. What is needed?

    1. AA better state estimate, fusing measurements with dead reckoning
    2. BHigher controller gains
    3. CA wider dead band
    4. DA slower loop
  6. [1 mark]Rotating while translating moves the position errors even when the position controller has done nothing new. What does the lesson call this?

    1. AThe loops interacting, or coupling
    2. BIntegral windup
    3. CDerivative kick
    4. DSteady state error

The task: park it

Stop within 6 cm of the target and within 8 degrees of heading 90, and be settled there by twenty seconds. The target is 80 across and 90 up from where the robot starts.

from bugbot import *
import math
connect()

V_MAX, V_LAT, W_MAX = 20.0, 15.0, 120.0
TX, TY, TH = 80.0, 90.0, 90.0

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

QR code
Do it on the robot
www.bugbotlab.com/learn/u5-7-project-parking/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Plot all three errors and adjust the gains until they reach zero together.
  2. Add a dead band so the robot stops rather than trembling on the spot.
  3. Steer by odometry() instead of position() and heading(). It counts from where the robot started, facing 0, so turn it into the mat's frame first: this robot starts facing 220. How far off is the parking now, and how far would it be after a long run?