# Desktop Python teaching example. Numerical inputs are illustrative.
from math import cos, sin

def update(pose, left_m, right_m, track_m):
    if track_m <= 0:
        raise ValueError("track_m must be positive")
    x, y, heading = pose
    ds = (left_m + right_m) / 2
    turn = (right_m - left_m) / track_m
    return (x + ds * cos(heading + turn / 2),
            y + ds * sin(heading + turn / 2), heading + turn)

pose = (0.0, 0.0, 0.0)
for left, right in [(0.1, 0.1), (0.09, 0.11), (0.1, 0.1)]:
    pose = update(pose, left, right, 0.1)
    print(pose)
