An automatic cleaner, comprising a distance sensor, a control module and a travelling device, wherein the control module has a gyro and is electrically connected to the distance sensor and the travelling device, the travelling device is used to move the automatic cleaner from a first position to a second position, the distance sensor is used to measure a plurality of pitches (Y(t)) between the automatic cleaner and a wall at a plurality of different time points (t), the control module is used to calculate a plurality of travel distances (X(t)) of the travelling device at the different time points (t) and determine, in the second position, a deviation angle between the traveling direction of the automatic cleaner and the extending direction of the wall on the basis of the pitches (Y(t)) and the travel distances (X(t)), characterized in that the distance sensor comprises a laser device emitting a laser beam to measure the pitches (Y(t)), the control module is further used to calculate an orientation angle and correct the orientation angle according to the deviation angle, the laser device of the automatic cleaner is used to measure the surrounding environment of the automatic cleaner at different time points so that a plurality of local maps (S0-Sq) are obtained, the control module determines a path based on the local maps (S0-Sq) and then controls the automatic cleaner to travel on the path, the control module updates a map database based on the local maps (S0-Sq) and stores the map database in a memory of the automatic cleaner, wherein in the local maps (S0-Sq) obtained by the laser device, a present local map (S0-Sq) contains partial information unknown by a previous local map (S0-Sq) so that the map database is expanded during the cleaning process. the control module has a gyro and is electrically connected to the distance sensor and the travelling device, the travelling device is used to move the automatic cleaner from a first position to a second position, the distance sensor is used to measure a plurality of pitches (Y(t)) between the automatic cleaner and a wall at a plurality of different time points (t), the control module is used to calculate a plurality of travel distances (X(t)) of the travelling device at the different time points (t) and determine, in the second position, a deviation angle between the traveling direction of the automatic cleaner and the extending direction of the wall on the basis of the pitches (Y(t)) and the travel distances (X(t)), characterized in that the distance sensor comprises a laser device emitting a laser beam to measure the pitches (Y(t)), the control module is further used to calculate an orientation angle and correct the orientation angle according to the deviation angle, the laser device of the automatic cleaner is used to measure the surrounding environment of the automatic cleaner at different time points so that a plurality of local maps (S0-Sq) are obtained, the control module determines a path based on the local maps (S0-Sq) and then controls the automatic cleaner to travel on the path, the control module updates a map database based on the local maps (S0-Sq) and stores the map database in a memory of the automatic cleaner, wherein in the local maps (S0-Sq) obtained by the laser device, a present local map (S0-Sq) contains partial information unknown by a previous local map (S0-Sq) so that the map database is expanded during the cleaning process.