Following a trajectory · University · about 25 min
The same geometry with and without a clock attached, and why the clock changes what you can check.
[1 mark]What is the practical reason for keeping the path and the time law separate?
[1 mark]What does this print? It is the lesson's route with a constant speed time law.
import math
WAYPOINTS = [(40, 40), (40, 140), (140, 140), (140, 60)]
CRUISE = 12.0
length = 0.0
for (ax, ay), (bx, by) in zip(WAYPOINTS, WAYPOINTS[1:]):
length += math.hypot(bx - ax, by - ay)
print(round(length, 1), round(length / CRUISE, 1))[1 mark]Where does the reference say the robot should be 10 s into the route?
import math
WAYPOINTS = [(40, 40), (40, 140), (140, 140), (140, 60)]
CRUISE = 12.0
legs, length = [], 0.0
for (ax, ay), (bx, by) in zip(WAYPOINTS, WAYPOINTS[1:]):
d = math.hypot(bx - ax, by - ay)
legs.append((ax, ay, bx, by, d))
length += d
def at(t):
s = max(0.0, min(length, CRUISE * t))
for ax, ay, bx, by, d in legs:
if s <= d:
u = s / d
return ax + (bx - ax) * u, ay + (by - ay) * u
s -= d
return WAYPOINTS[-1]
print(at(10.0))[1 mark]A robot drives at waypoint 1 until it is close, then at waypoint 2, and so on. Why does it stop and start at every waypoint?
[1 mark]Which of these can be checked on a trajectory but not on the path alone?
Tick every answer that is true.
[1 mark]Why does the lesson call the constant speed time law s(t) = v t a lie?
Print length:, the total length of the path through the four waypoints, and duration:, how long it takes at 12 cm/s. Then sample the trajectory every 0.1 s and plot ref x and ref y, with a wait(0.1) between samples so the chart spreads them out in time. The robot does not move in this task.
from bugbot import * import math connect() WAYPOINTS = [(40, 40), (40, 140), (140, 140), (140, 60)] CRUISE = 12.0
Plan your program here, then type it in and press Run.
at(t) still behave?