Sensing · Robot club · about 15 min
position(), heading(), velocity(), and resetting them.
[1 mark]What do the two numbers in position() mean?
[1 mark]The robot starts at heading 0, runs turn_right(30, angle=45), then turn_left(30, angle=135). What does heading() say? Give a whole number of degrees.
[1 mark]What is velocity() especially useful for?
[1 mark]Roughly what does the last line print?
forward(60, distance=20) turn_right(30, angle=90) reset_position() reset_heading() forward(60, distance=10) print(position())
[1 mark]Which sensors are inside the robot's 9-axis inertial sensor?
Tick every answer that is true.
[1 mark]What does this program print?
import math
x, y = 3, 4
print("from home:", math.sqrt(x*x + y*y), "cm")[1 mark]After driving a square, the robot is not quite back where it started, and a few degrees off. What is the right way to think about that?
Get to the point 30 cm right and 30 cm forward of where you start, and print a line in the shape at (30.1, 29.8) facing 1.2 from position() and heading().
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() # drive forward at 60 for 30 cm, then stop forward(60, distance=30)
Plan your program here, then type it in and press Run.
position() and velocity() every 0.5 s while driving.x*x + y*y under a square root.