Try it: quaternions and the wrap trap

angles.py: yaw_from_quaternion and wrap, the two functions you write in Lab 1.

A heading, stored as a quaternion

x
y
z
w
naive goal − current
wrap(goal − current)

Drag the goal or the current heading. At the TurtleBot 4 limit of 1.90 rad/s, the naive error turns the long way; wrap turns the short way.

Python starts when the lecture gets close to this slide.
Python not started yet.
1

The Python behind the demo

angles.py: the two functions from the slides, plus the quaternion for a yaw.

The round trip and the wrap trap, as on your Mac:

$ python3 angles.py

What the slide calls for each change:

2