If your robot can already follow the line, then the track can easily be derived from the movement commands you gave to the motors. There is a matter of filtering and compressing the data, but this is really up to experimentation and depends on particular hardware anyway.