Method and device for generating cleaning path of robotTechnical Field
The invention relates to the field of robot control, in particular to a method and a device for generating a cleaning path of a robot.
Background
Along with the development of intelligent hardware and communication technology, unmanned cleaning robots are increasingly applied to large places such as markets, airports, hospitals and the like. In order to realize full coverage of a cleaning area to eliminate sanitary dead corners, unmanned cleaning robots in the market are mostly provided with a welting cleaning mode, for example, a mode of cleaning an area close to a wall, or a wall-sticking cleaning mode.
The invention discloses an automatic cleaning method for unmanned supermarket sanitation, which is disclosed by the invention with the application number of 201710795442.3, and comprises the following steps of S1: after the unmanned supermarket system starts a cleaning task, the unmanned supermarket system sends a cleaning instruction to a sweeping robot located in a waiting area; s2: taking the charging base as an origin of coordinates and establishing a rectangular coordinate system on a working plane of the robot; s3: the sweeping robot leaves the waiting area and enters the unmanned supermarket car through an access passage, the external environment information of the robot is detected, and a grid map is established; s4: dividing an area to be cleaned into unit areas in a grid map; s5: the cleaning is carried out according to the planned cleaning path; s6: in the cleaning process, scanning the roadblock, avoiding the roadblock when the roadblock meets an obstacle, and recording the position information of the obstacle into map data; s7: judging whether the cleaning of all the cleanable grids is finished; s8: and (6) ending. The method improves the automation degree, saves the labor expenditure cost of cleaners and improves the cleaning efficiency.
The inventor finds that in the prior art, when a moving obstacle is encountered in the welting cleaning process, a sensor cannot distinguish the obstacle from a wall, and if the obstacle is identified as the wall when the obstacle is encountered, the robot turns, so that the robot may be separated from the wall and cannot avoid the obstacle in time. Therefore, the technical problem that robot navigation in the welting mode is not accurate enough exists in the prior art.
Disclosure of Invention
The invention aims to provide a method and a device for generating a cleaning path of a robot to improve the accuracy of robot navigation in a welting cleaning mode.
The invention solves the technical problems through the following technical means:
the embodiment of the invention provides a method for generating a cleaning path of a robot, which comprises the following steps:
acquiring a map of an area to be cleaned, and acquiring a binary image of the map;
identifying coordinates of pixel points on the wall outline in the binary image;
acquiring coordinates of the robot corresponding to a map;
and the robot performs cleaning operation by taking the coordinates of the pixel points on the outline as navigation points.
The embodiment of the invention is applied to constructing the navigation path according to the map. The method is irrelevant to moving of the barrier, so compared with a method for navigation through collision detection in the prior art, the method can avoid the influence of the barrier on navigation, and further can enable navigation to be more accurate.
Optionally, the obtaining a binary image of the map includes:
and acquiring a binary image of the map by utilizing an adaptiveThreshold () function of the OpenCV.
Optionally, the identifying coordinates of pixel points on the contour of the wall side in the binary image includes:
performing expansion processing on the binary image, and identifying a wall edge contour in the map by using a cv2.findContours () function;
and acquiring the coordinates of the pixel points on the wall edge contour, and converting the coordinate system of the pixel points from the pixel coordinate system to a new world coordinate system.
Optionally, the acquiring the coordinates of the robot in the map includes:
and acquiring coordinates of the robot corresponding to the map by using an adaptive Monte Carlo positioning method.
Optionally, the robot cleans the operation as the navigation point according to the coordinate of the pixel on the outline, include:
taking the current position of the robot as an origin point, taking a preset radius R as a search radius, and acquiring coordinates of pixel points on a wall edge contour within the search radius;
calculating the distance from the origin to the coordinate of each pixel point on the wall edge contour in the search radius, and taking the point with the minimum distance as the closest point;
and controlling the robot to move from the origin to the closest point, and then performing cleaning operation by using the robot as a navigation point according to the coordinates of the pixel points on the contour.
The embodiment of the invention provides a device for generating a cleaning path of a robot, which comprises:
the first acquisition module is used for acquiring a map of an area to be cleaned and acquiring a binary image of the map;
the identification module is used for identifying the coordinates of the pixel points on the wall outline in the binary image;
the second acquisition module is used for acquiring the coordinates of the robot corresponding to the map;
and the navigation module is used for cleaning by taking the coordinates of the pixel points on the outline as navigation points by the robot.
Optionally, the first obtaining module is configured to:
and acquiring a binary image of the map by utilizing an adaptiveThreshold () function of the OpenCV.
Optionally, the identification module is configured to:
performing expansion processing on the binary image, and identifying a wall edge contour in the map by using a cv2.findContours () function;
and acquiring the coordinates of the pixel points on the wall edge contour, and converting the coordinate system of the pixel points from the pixel coordinate system to a new world coordinate system.
Optionally, the second obtaining module is configured to:
and acquiring coordinates of the robot corresponding to the map by using an adaptive Monte Carlo positioning method.
Optionally, the navigation module is configured to:
taking the current position of the robot as an origin point, taking a preset radius R as a search radius, and acquiring coordinates of pixel points on a wall edge contour within the search radius;
calculating the distance from the origin to the coordinate of each pixel point on the wall edge contour in the search radius, and taking the point with the minimum distance as the closest point;
and controlling the robot to move from the origin to the closest point, and then performing cleaning operation by using the robot as a navigation point according to the coordinates of the pixel points on the contour.
The invention has the advantages that:
the embodiment of the invention is applied to constructing the navigation path according to the map. The method is irrelevant to moving of the barrier, so compared with a method for navigation through collision detection in the prior art, the method can avoid the influence of the barrier on navigation, and further can enable navigation to be more accurate.
Drawings
Fig. 1 is a schematic flow chart of a method for generating a cleaning path of a robot according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a map of an area to be cleaned in a method for generating a cleaning path of a robot according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a binarized map in a method for generating a robot cleaning path according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a robot track in a method for generating a cleaning path of a robot according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a device for generating a cleaning path of a robot according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the embodiments of the present invention, and it is obvious that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1
Fig. 1 is a schematic flow chart of a method for generating a cleaning path of a robot according to an embodiment of the present invention, as shown in fig. 1, the method includes:
s101: obtaining a map of an area to be cleaned, and obtaining a binary image of the map.
For example, a map of an area to be cleaned, which is created by using SLAM (simultaneous localization and mapping) technology, may be acquired. Fig. 2 is a schematic diagram of a map of an area to be cleaned in a method for generating a cleaning path of a robot according to an embodiment of the present invention. Then, thresholding processing is carried out on the map by utilizing an adaptive threshold () function of the OpenCV, and then a binary image of the map can be obtained. Fig. 3 is a schematic diagram of a binarized map in a method for generating a robot cleaning path according to an embodiment of the present invention.
In practical application, corresponding threshold values can be obtained according to different application environments, and the image of the map is subjected to binarization segmentation according to the threshold values.
S102: and identifying the coordinates of the pixel points on the wall outline in the binary image.
Illustratively, the binary image is subjected to expansion processing by using a dilate () function provided in OpenCV, wherein the expansion distance is the radius of a circle circumscribed by the robot outline.
Then, a cv2.findContours () function in an OpenCV-Python interface is used for identifying a wall edge outline in the map, and cv2.drawContors are used for drawing the wall edge outline in the map, as shown by a black line in a white area in FIG. 3, the extracted pixel points on the wall edge outline are stored in an array, and coordinates of the pixel points in the array are converted from a pixel coordinate system to a world coordinate system, so that path points cleaned by the cleaning robot along the wall can be obtained.
S103: and acquiring coordinates of the robot corresponding to the map.
And acquiring coordinates of the robot corresponding to the map by using an adaptive Monte Carlo positioning method.
S104: and the robot performs cleaning operation by taking the coordinates of the pixel points on the outline as navigation points.
Fig. 4 is a schematic diagram of a robot track in the method for generating a robot cleaning path according to the embodiment of the present invention, and as shown in fig. 4, coordinates of a pixel point on a wall contour within a search radius are obtained with a current position of the robot as an origin and a preset radius R as the search radius; the lines inside the wall edge in fig. 4 are the tracks formed by the coordinates of the pixel points. Similarly, the line inside the edge of the wall in fig. 3 is the track formed by the coordinates of the pixel points.
Calculating the distance from the origin to the coordinate of each pixel point on the wall edge contour in the search radius, and taking the point with the minimum distance as the closest point;
and controlling the robot to move from the origin to the closest point, and then performing cleaning operation by using the robot as a navigation point according to the coordinates of the pixel points on the contour.
The embodiment of the invention is applied to constructing the navigation path according to the map. The method is irrelevant to moving of the barrier, so compared with a method for navigation through collision detection in the prior art, the method can avoid the influence of the barrier on navigation, and further can enable navigation to be more accurate.
At present, the existing welting mode is realized based on a sensor, generally, a robot moves to a wall or an obstacle and then collides, a central processing unit of the robot receives a collision signal at the moment, judges that an obstacle exists right ahead and records a coordinate at the moment, then the robot changes an angle to advance, if the robot meets the obstacle again, judges that an obstacle exists right ahead and records a coordinate at the moment, and the robot realizes welting cleaning in such a circulating way. However, the inventor has found that in the existing welt cleaning mode, a plurality of sensors need to be arranged in the advancing direction of the robot, and the sensors are matched to sense the collision direction, so that the number of the sensors is a key problem in determining welt quality, too many sensors increase the complexity of logic judgment such as program steering and obstacle avoidance, and the cost is increased; however, too few sensors may cause the robot to be unable to monitor the surrounding environment in all directions, resulting in incapability of driving along the side or accidental collision.
By applying the embodiment of the invention, the contour of the working area of the robot is obtained based on the image algorithm, so that the coordinates of the pixel points on the contour edge are obtained, and then the coordinates are used for navigation to realize welting cleaning.
In addition, in some complex terrains, such as "back" type terrains, there may be multiple wall boundaries. The traditional welting method cannot realize the conversion between two outlines. The embodiment of the invention can judge which contour the closest point exists in when the closest point is obtained, and the contour path is used as the current navigation path of the robot. After the cleaning of the area to be cleaned corresponding to the current navigation path is completed, the robot moves to the cleaning area corresponding to the next navigation path for cleaning, and then switching between mutually independent cleaning paths is realized.
Example 2
Corresponding to embodiment 1 of the present invention, an embodiment of the present invention further provides a device for generating a cleaning path of a robot, including:
thefirst acquisition module 501 is configured to acquire a map of an area to be cleaned and acquire a binary image of the map;
theidentification module 502 is configured to identify coordinates of pixel points on a wall outline in the binary image;
a second obtainingmodule 503, configured to obtain coordinates of the robot corresponding to the map;
and thenavigation module 504 is used for the robot to perform cleaning operation by taking the coordinates of the pixel points on the outline as navigation points.
The embodiment of the invention is applied to constructing the navigation path according to the map. The method is irrelevant to moving of the barrier, so compared with a method for navigation through collision detection in the prior art, the method can avoid the influence of the barrier on navigation, and further can enable navigation to be more accurate.
In a specific implementation manner of the embodiment of the present invention, the first obtainingmodule 501 is configured to:
and acquiring a binary image of the map by utilizing an adaptiveThreshold () function of the OpenCV.
In a specific implementation manner of the embodiment of the present invention, the identifyingmodule 502 is configured to:
performing expansion processing on the binary image, and identifying a wall edge contour in the map by using a cv2.findContours () function;
and acquiring the coordinates of the pixel points on the wall edge contour, and converting the coordinate system of the pixel points from the pixel coordinate system to a new world coordinate system.
In a specific implementation manner of the embodiment of the present invention, the second obtainingmodule 503 is configured to:
and acquiring coordinates of the robot corresponding to the map by using an adaptive Monte Carlo positioning method.
In a specific implementation manner of the embodiment of the present invention, thenavigation module 504 is configured to:
taking the current position of the robot as an origin point, taking a preset radius R as a search radius, and acquiring coordinates of pixel points on a wall edge contour within the search radius;
calculating the distance from the origin to the coordinate of each pixel point on the wall edge contour in the search radius, and taking the point with the minimum distance as the closest point;
and controlling the robot to move from the origin to the closest point, and then performing cleaning operation by using the robot as a navigation point according to the coordinates of the pixel points on the contour.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.