A new programming method has been developed for grinding robots. Instead of using the conventional jog-and-teach method, the workpiece contour is automatically tracked by the robot. During the tracking, the robot position is stored in the robot control system every 8th millisecond. After filtering and reducing this contour data, a robot program is automatically generated. The contour data contain different types of noise due to small vibrations and overshoot when the robot is tracking the workpiece. To remove the noise, a new filtering algorithm is proposed. The Look Ahead filter removes outliers from the data. After that, the data is smoothed by the Nadaraya-Watson estimator. The system is tested out by a Multicraft 560 robot. Experimental results show that the filtering algorithm efficiently removes the noise without reducing the accuracy of the contour data. This makes it easy to automatically restore the contour by a robot program.