Stepper motors actually measure the number of revolutions of the gear, respectively, will error accumulated in the reducer (which is their main source, in addition to looseness of the joints and deformation of the whole structure under physical stress, inertia, self weight and temperature changes).
So it is necessary to measure the angle of rotation of the last joint in the gearbox (or the penultimate, then it is possible to combine the measurement of the angle with the number of revolutions) or even the distance that moves the tool itself.
To change the angle it is easier to use a disk with lots of cuts from glass/cracks have opaque/just strips and to consider them the usual photocell (pair to determine the direction of rotation). Now look, Wikipedia has a reasonable article about the encoders: ru.wikipedia.org/wiki/Датчик_угла_поворота
If we are talking about 'DIY' and low budgets, in this case, the larger the radius of the disk, the easier it is to make yourself, even stripes can be printed on the printer. It is also possible to develop the idea, and instead drive and fotoelemente can put a mirror/flashlight and catch the light Bunny webcam bon
Lichem distance — it is not getting coordinates in real time, and about the constant automatic compensation of measurement errors (yet this light rabbit will be recognized....)