The worksheetDownload the PDF
Answers

U2.1 Two frames

Kinematics and frames · University · about 20 min

BugBotLab

What this lesson is about

The robot's forward is not the world's forward. Naming the frame is half the work.

Questions 6 marks in all

  1. [1 mark]Which of these speak in the robot's body frame?

    Tick every answer that is true.

    1. Aflow()
    2. BThe commands to drive(fwd, lat, rot)
    3. CThe acceleration from imu()
    4. Dposition()
    5. EThe location of a zone on the mat
    Answer: A, B, C. Anything mounted on the robot or sent to its motors is in the body frame. position(), zones, targets and walls live in the world frame, and connecting the two needs the heading.
  2. [1 mark]A robot is at heading 90. Which way is it facing?

    1. AAlong the world's +x
    2. BAlong the world's +y
    3. CAlong the world's -x
    4. DAlong the world's -y
    Answer: A. Heading 0 faces +y and heading is clockwise positive, so a quarter turn clockwise faces +x, to the right.
  3. [1 mark]Heading 0 means the robot faces along which world axis? Give the axis and its sign.

    Answer: +y. Heading is measured clockwise from +y, the direction away from you across the mat, like a compass bearing from north.
  4. [1 mark]A robot turns left, anticlockwise seen from above. What sign is the change in its heading?

    1. ANegative, because heading is clockwise positive
    2. BPositive, because angles increase anticlockwise
    3. CPositive, because heading always increases while turning
    4. DIt depends on which way the robot was facing to begin with
    Answer: A. This course follows the compass, not the maths textbook. Anticlockwise turns reduce the heading whatever the starting direction.
  5. [1 mark]A robot at heading 90 drives straight forward at 14 cm/s for 2 s. How far does its world x change, in cm?

    Answer: 28. At heading 90 the body's forward is the world's +x, so all 14 × 2 = 28 cm of travel goes into x and none into y.
  6. [1 mark]A program sets command_lat = dx_world, where dx_world = target_x - x_world. What is wrong with it?

    1. AIt sends a world frame displacement as a body frame command without rotating it by the heading
    2. BNothing, as long as the robot is at heading 90
    3. Clat is the robot's forward axis, so it should be the fwd command
    4. Ddx_world needs dividing by 100 to become a percentage, and that is all
    Answer: A. World x and body right only agree at heading 0. At heading 90 the body's right is the world's -y. The variable names make the mix visible, which is why they are worth writing.

The task: name the frame

The robot starts facing along the world's x axis. Drive it forward at least 25 cm, then print two numbers: body: the average sideways speed in the robot's own frame while it drove, and world x: how far it actually moved along the world's x axis.

from bugbot import *
connect()

forward(60)

The hint students can ask for: The robot starts facing along the world's x axis. Drive forward for a few seconds. In the body frame that is forward; in the world frame it is x. Read flow() for one and position() for the other.

A solution

from bugbot import *
connect()

forward(70)
side = []
for i in range(30):
    side.append(flow()[0])
    wait(0.1)
stop()
wait(0.6)
x, y = position()
print("body:", round(sum(side) / len(side), 1))
print("world x:", round(x, 1))

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.