I addition, to calculating the assigned error relative to an arbitrary line segment, not just the y-axis, we also have to detect when the robot steps beyond the end of a line segment and switch over to the next one. 