A robot designed for scanning within a work area, wherein the robot travels inside the work area in successive paths. The robot operates to scan the work area using a first scanning mode and monitors the length of each of the paths traveled by the robot. The robot than switches from the first scanning mode to a second scanning mode when an obstacle is encountered on a minimum number of consecutive said paths each having a length between a first threshold distance and a longer, second threshold distance. The robot switches back to the first scanning mode when the length of one of the paths has increased to more than the second threshold distance.