Drawing Robot

A basic robot with accurate self localization capabilities is programmed to follow predetermined waypoints while holding a marker.

LegoDrawingBot

Robot Platform
A simple skid/steer robot built using the Lego NXT kit. The robot uses a third motor to maneuver a marker that when lowered touches the floor directly between the two wheels (or center of rotation).

The Drawing Program
The draw.nxc program is used to read the path waypoints from a text file (drawing.log). A drawing is defined by a series of strokes containing at least two points. The number of waypoints in the stroke is determined by the first number and is than followed by the stroke coordinates, for example:

N
X11 Y11
X12 Y12
… …
X1N Y1N

Drawings will most likely have more than a single stroke. Strokes can be added as needed. The program ends when it finds a stroke with a single waypoint instruction, which the program interprets as the robot’s final location. A common final location is the origin:

1
0 0

The Basic Algorithm
The program commands the robot to move to the first waypoint. Once it reaches its destination, the robot lowers the marker until it touches the floor. From this point, the robot will follow each waypoint that forms the stroke by stopping on the waypoint, facing the next one, and moving straight. When the program reaches the last waypoint of the current stroke, it lifts the marker and the sequence is repeated until all the strokes have been drawn.
It is possible to make the robot follow the waypoints in a smoother manner without having to stop. However, this would require a more sophisticated control system, such as the one demonstrated at https://www.youtube.com/watch?v=7QBITaxeytc.