Suppose a bot with wheels is traveling in a a straight line,and we want to measure this linear distance traversed by it as accurately as possible. One of the ways is to use an optical encoder to measure the angle of rotation of the wheels and get the linear distance traveled. Another way could be to use the data from accelerometer and get the linear distance traveled. Which of these two methods would be better ? Or,is there a third method which is more precise than the previous two?
If you measure one of the free running wheels (with no motor connect to it), it depends on the traction of the wheel, but that could be fairly accurate.
If you move horizontally a simple accellerometer (1 axis) would be great. But if you have a vertical component, then you can not distinct between accelleration and weight force (Einstein). If you use a 3 axes accellerometer, you can compute/extract the robots moving speed (subtract the G component = 9.81 m/s²) and thus the distance. You have to use vector arithmetic in this case.
If the ground has enough "structure" you could use an optical sensor (like optical mice have).
If you have a reference object (e.g. a wall, a book) you could use a LIDAR sensor (https://en.wikipedia.org/wiki/Lidar) to measure the absolute distances at time points and compute the relative distance between these time points.
If you use an accelerometer, you have to integrate twice to arrive at distance travelled. These two integrations will also compound errors and noise, so the result won't be very accurate without many corrections.
If a wheel doesn't slip and is undriven, the results of counting wheel rotations should be fairly accurate when the robot is moving in a straight line.
Dragging a cheap computer mouse behind the robot and reading its output could also work, but I haven't tried that one yet.
The most accurate, if you can set up a flat object that reflects well enough at the destination of the robot, is probably LIDAR. Not cheap, but easy enough to do as long as the robot moves in a straight line.
Another option would be to count wheel rotations, and calibrate with LIDAR (or GPS for very long distances) and use the calibrated wheel rotations in the final version, or use two or more methods and do sensor fusion.