Accurately determining the progress of a wheeled robot can be pretty tricky (and expensive!). Dead reckoning assumes that our motors are perfectly matched, our wheels don't slip and the surface we are running on is perfectly flat: most of these conditions are unattainable and are never guaranteed. Rotary Encoders on the wheels or motors are more accurate, they certainly remove the need for matched motors and can deal with incline changes, however slippage is still an issue. Ultrasonic or Laser range sensors circumvent all of the mechanical issues that plague dead reckoning and encoders but require stationary fixed points of reference, are subject to interference (objects coming between the robot and the reference point) and have issues with regard to range, accuracy and resolution (the more you want, the more it costs!).
Ideally, we want a sensor that can accurately measure positional changes in two dimensions, has a simple interface, has low power requirements, is easily obtainable and cheap into the bargain. The solution: that old optical mouse you have lying around! Computer mice are designed to do just what we want: very accurately track the two dimensional movement of an object in near to real time. They actually have a resolution 1000dpi which means we are able to measure a movement of ~0.03mm in any direction!
We do have to choose our mouse a little carefully however. We need one that either has a PS/2 connector (6 pin mini-DIN) or a USB mouse that is PS/2 compatible (should be stated on the bottom of the mouse somewhere, see picture). This is because the PS/2 protocol is really easy to implement (particularly for microcontrollers) whereas USB is somewhat more difficult!
I happened to have an old Microsoft USB1.1/PS/2 compatible mouse hanging around that I wasn't using, so I decided to sacrifice it to my robotical pursuits in the manner described herein.