🤖 Robot Programming Lab: Commands, Sensors and Odometry Drift

What you are seeing

Type a program on the right: F n drives n metres, L/R turn 90 degrees, REPEAT n ... END loops and IFWALL L|R turns only if the distance sensor sees a wall 0.75 m ahead. The blue dashed line is what the program means; the orange line is what a real robot does when its wheels differ by a few percent. Reach the green goal without bumping a wall, then see why real robots need sensors and feedback.

Controls

Live readouts

Numerical checks

Square closes exactly with a perfect robot; arc formula is compared with 300 000 numerical steps.
The science

Differential drive with wheel base b = 0.3 m: wheel speeds vl, vr give forward speed v = (vl+vr)/2 and turn rate ω = (vr−vl)/b. If the right wheel is faster by a fraction ε, then ω = 2vε/b and a "straight" run follows a circular arc of radius R = v/ω: x = (v/ω)(sin θ1 − sin θ0), y = −(v/ω)(cos θ1 − cos θ0). The simulator uses this exact solution, not a step approximation.

Turn commands are open-loop: a scale error in the turn angle adds directly to heading, and heading error turns into position error as you drive on (error grows roughly linearly with distance). That is dead reckoning; real robots fix it with encoders, gyros, vision and closed-loop control.

Simplifications: deterministic mismatch (no random slip noise), instantaneous start/stop, the robot is a point for wall collisions, and the IFWALL sensor is a single 0.75 m ray.