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

def waypoint_action(pose, target, tolerance_m=0.03):
    x, y, theta = pose
    dx, dy = target[0] - x, target[1] - y
    if hypot(dx, dy) <= tolerance_m:
        return "arrived", 0.0, 0.0
    error = atan2(sin(atan2(dy, dx) - theta), cos(atan2(dy, dx) - theta))
    if abs(error) > radians(8):
        return "turn", 0.0, max(-0.5, min(0.5, 2 * error))
    return "advance", min(0.1, hypot(dx, dy)), max(-0.3, min(0.3, error))

print(waypoint_action((0, 0, radians(170)), (-1, -0.1763)))
print(waypoint_action((0, 0, 0), (0.02, 0)))
