Grid map optimization method
By performing outline search of the raster map obtained by the robot and linear fusion of independent region boundaries, the problem of discontinuity of the raster map contour boundaries in the prior art is solved, and the display quality of the raster map is improved.
Patent Information
- Application Number
- CN202311194202.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2025-03-18
AI Technical Summary
After existing robots build raster maps through lidar, the outline boundary of the raster map will occur, which will affect the display quality of the raster map.
The robot obtains the raster map of the environment, performs outline search and linear fusion of independent region boundaries, and optimizes the obtained raster map.
It effectively improves the display quality of raster maps and solves the problem of discontinuous outline boundaries.
Smart Images

Figure CN119648726A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of intelligent robots, and in particular to a grid map optimization method. Background Art
[0002] With the rapid development of modern science and technology, more and more robots are involved in our daily life and industrial activities. In order for mobile robots to reach the designated location accurately and quickly, their navigation performance plays a vital role. The accuracy of map construction is the key to ensuring the navigation accuracy of mobile robots. During the navigation process, an accurate grid map can enable the mobile robot to more clearly understand its current location and the designated location to be reached, so as to reasonably plan the subsequent path. Due to the advantages of high measurement accuracy, stable measurement performance, and low computer computing power requirements of laser radar, robots often obtain data through laser radar to construct raster maps. After the existing robot constructs a raster map through laser radar, when the robot obtains the contour boundary of the raster map from the raster map, the contour boundary of the raster map will be discontinuous, which affects the display quality of the raster map. Summary of the invention
[0003] To solve the above problems, the present invention provides a method for optimizing a grid map. The specific technical solution of the present invention is as follows: A method for optimizing a grid map comprises the following steps: S1: a robot obtains a grid map of an environment, and then searches for contours on the grid map; S2: the robot obtains an independent area according to the contours of the grid map, and then traverses the boundaries of the independent area; S3: during the process of traversing the boundaries of the independent area, the robot performs straight line fusion to obtain an optimized grid map.
[0004] Furthermore, in step S1, after the robot obtains the raster map of the environment, the following steps are included: the robot obtains laser data of the environment through a laser sensor, and constructs a raster map through the obtained laser data; the robot performs ternary processing on the obtained raster map to obtain a ternary raster map; the robot performs an open operation on the ternary raster map to obtain a raster map after removing boundary noise.
[0005] Furthermore, the robot searches for the contour of the raster map, including the following steps: the robot binarizes the raster map and then traverses the binarized raster map; during the traversal process, if the eight adjacent pixels of any black pixel in the binarized raster map are all black pixels, the black pixel is deleted; the robot uses the retained black pixels as the contour of the raster map.
[0006] Furthermore, the robot obtains independent areas according to the outline of the grid map, including the following steps: the robot traverses the outline of the grid map to obtain closed outlines in the grid map; the robot calculates the area of the closed outlines in the grid map; the robot sets the outlines with an area greater than or equal to the set area as independent areas.
[0007] Furthermore, the robot obtains a closed contour in the grid map, including the following steps: the robot traverses the contour of the grid map, and if any pixel point on the contour of the grid map has two or more pixel points adjacent to it, the contour is determined to be a closed contour.
[0008] Furthermore, the robot calculates the area of a closed contour, including the following steps: the robot obtains the number of pixel points constituting the closed contour, and obtains the pixel coordinates of each pixel point on the grid map; the robot calculates the area of the closed contour based on the number of pixel points constituting the closed contour and the pixel coordinates of each pixel point on the grid map.
[0009] Furthermore, after acquiring the independent area, the robot generates a seed point of the independent area, and then the robot screens the independent area according to the seed point, including the following steps: the robot converts the grid map of the screened independent area into a three-valued grid map; the robot selects a grid from the free grids of the independent area in the three-valued grid map; the robot uses the selected grid as the seed point, and then clusters the grids of the grid map according to the seed point to screen out the target independent area; the robot removes the independent area except the target independent area to obtain a denoised grid map.
[0010] Furthermore, the robot traverses the boundary of the independent area, including the following steps: the robot selects N rows of pixels to construct a pixel area, and then the robot traverses the grid map from top to bottom through the pixel area; then, the robot selects N columns of pixels to construct a pixel area, and then the robot traverses the grid map from left to right through the pixel area; in the process of traversing the grid map, the robot performs linear fusion on the boundary of the independent area of the grid map in the pixel area; wherein, N is a natural number greater than 1.
[0011] Furthermore, the robot performs straight line fusion in the pixel area, including the following steps: the robot detects the straight lines in the pixel area, and then obtains the distance threshold and length threshold of the straight lines in the pixel area; the robot determines whether the length threshold of the straight lines in each column or each row in the pixel area is greater than or equal to the set length threshold; if the length threshold of the straight lines in any column or any row in the pixel area is greater than or equal to the set length threshold, the robot retains the straight lines in the column or row with the largest length threshold in the pixel area, and removes the straight lines in other columns or rows in the pixel area; the robot determines whether the distance threshold of the straight lines in the column or row with the largest length threshold in the pixel area is less than or equal to the set distance threshold; if the distance threshold of the straight lines in the column or row with the largest length threshold in the pixel area is less than or equal to the set distance threshold, the robot connects the straight lines in the column or row; if the length threshold of the straight lines in any column or any row in the pixel area is less than the set length threshold, the robot does not fuse the straight lines in the pixel area; wherein, the distance threshold is the distance between the two nearest endpoints of the straight lines in the same column or row; and the length threshold is the total length of the straight lines in the same column or row.
[0012] Furthermore, the robot detects a straight line in a pixel area, including the following steps: when the robot traverses the grid map from top to bottom through the pixel area, if there are two or more boundary points of independent areas adjacent in the pixel row of the pixel area, these adjacent boundary points are set as straight lines; when the robot traverses the grid map from left to right through the pixel area, if there are two or more boundary points of independent areas adjacent in the pixel column of the pixel area, these adjacent boundary points are set as straight lines.
[0013] Compared with the existing technology, the advantage of the present application lies in that: the robot described in the present application first searches for the contour of the raster map to obtain the contour in the raster map, then uses the contour of the raster map as the boundary to construct an independent area, and then performs straight line fusion on the boundary of the independent area to straighten the boundary of the independent area, thereby obtaining an optimized raster map, which effectively improves the display quality of the raster map. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 The figure is a flow chart of a method for optimizing a grid map in one embodiment of the present invention.
[0015] Figure 2 In one embodiment of the present invention, the grid Figure 3 Schematic diagram of the structure after value conversion.
[0016] Figure 3 In one embodiment of the present invention, the grid Figure 2 Schematic diagram of the structure after value conversion.
[0017] Figure 4It is a schematic diagram of the structure of clustering independent regions in an embodiment of the present invention.
[0018] Figure 5 It is a schematic diagram of the structure of linear fusion of pixel areas in one embodiment of the present invention. Implementation
[0019] Embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions.
[0020] The following is a further description of the specific embodiments of the present invention in conjunction with the drawings of the specification, so that the technical solution and its beneficial effects of the present invention are clearer and more explicit. The following description of the embodiments with reference to the drawings is exemplary and intended to explain the present invention, but cannot be understood as limiting the present invention.
[0021] like Figure 1 As shown, a method for optimizing a grid map comprises the following steps: S1: The robot obtains a grid map of the environment. The robot can obtain laser data of the environment through a laser sensor to construct a grid map, or read a grid map pre-saved by the robot, and then the robot searches for the contour of the grid map through a contour extraction algorithm. S2: The robot obtains an independent area according to the contour of the grid map, and then the robot traverses the boundary of the independent area, that is, the robot selects the contour of the grid map as the boundary to construct the independent area, and then the robot traverses the contour as the boundary of the independent area. S3: During the robot traversal of the boundary of the independent area, the straight lines formed by the boundary points of the independent area are linearly fused, which plays the role of straightening the straight lines to obtain an optimized grid map. The robot described in the present application first searches for the contour of the grid map to obtain the contour in the grid map, and then uses the contour of the grid map as the boundary to construct the independent area, and then linearly fuses the boundary of the independent area to straighten the boundary of the independent area to obtain an optimized grid map, which effectively improves the display quality of the grid map.
[0022] As one example, Figure 2As shown, in step S1, after the robot obtains the grid map of the environment, the following steps are included: the robot obtains the laser data of the environment through the laser sensor, and constructs the grid map through the obtained laser data. After the robot obtains the laser data of the environment, according to its current position and the obtained laser data, the laser data is placed on the map one by one to obtain the grid map, wherein the grids that the robot can pass are idle grids, the grids where obstacles are located are grids occupied by obstacles, and the grids outside the working environment are set as unknown grids. The robot performs ternary processing on the obtained grid map to obtain a ternary grid map, that is, the robot sets the grid value of the idle grid of the grid map to 255, the grid value of the unknown grid of the grid map to 128, and the grid value of the grid occupied by obstacles in the grid map to 0. The robot performs an open operation on the ternary grid map, that is, the grid map is first corroded, and then expanded to obtain a grid map after removing the boundary noise. The robot performs preliminary denoising on the grid map by corrosion and expansion to improve the accuracy of the grid map.
[0023] As one example, Figure 3 As shown, the robot searches for the contour of the grid map, including the following steps: the robot performs binarization on the grid map, and then traverses the binarized grid map, that is, the grid values of the unknown grids of the ternary grid map are set to 0, and the binary grid map can be obtained. During the traversal process, if the eight adjacent pixels of any black pixel in the binarized grid map are all black pixels, the black pixel will be deleted; the robot will retain the black pixel as the contour of the grid map. Figure 3 As shown in the figure, the outline of the binary grid map is the boundary of the black and white area, and the eight adjacent pixels of these boundary points are connected to the white pixels. As long as the black pixels that do not meet the requirements are removed, the outline of the grid map can be obtained. The robot obtains the outline of the grid map through the internal hollowing method, which has high accuracy and simple calculation.
[0024] As one embodiment, the robot obtains an independent area according to the outline of a grid map, including the following steps: the robot traverses the outline of the grid map to obtain closed outlines in the grid map; the robot calculates the area of the closed outlines in the grid map; the robot sets the outlines with an area greater than or equal to a set area as independent areas. The robot selects the independent area according to the size of the area of the closed outline, removes the noise in the grid map, and facilitates subsequent calculations.
[0025] As one embodiment, a robot obtains a closed contour in a grid map, including the following steps: the robot traverses the contour of the grid map, and if any pixel point on the contour of the grid map has two or more pixel points adjacent to it, the contour is determined to be a closed contour.
[0026] As one embodiment, the robot calculates the area of a closed contour, including the following steps: the robot obtains the number of pixels constituting the closed contour and obtains the pixel coordinates of each pixel on the grid map; the robot calculates the area of the closed contour according to the number of pixels constituting the closed contour and the pixel coordinates of each pixel on the grid map. The calculation formula is: ; Where n is the number of contour points that constitute the closed contour, and x and y are the pixel coordinates of the contour points.
[0027] As one example, Figure 4 As shown, after the robot obtains the independent area, it generates the seed point of the independent area, and then the robot selects the independent area according to the seed point, including the following steps: the robot converts the grid map of the selected independent area into a three-valued grid map; the robot selects a grid from the free grids of the independent area in the three-valued grid map; the robot uses the selected grid as the seed point, and then clusters the grids of the grid map according to the seed point to select the target independent area; the robot removes the independent area except the target independent area to obtain the denoised grid map. The robot selects a free grid in the independent area as the seed point, and then the robot traverses the eight grids surrounding the seed point, and uses the free grids in the eight grids as the seed point to traverse the adjacent grids of the new seed point again. If the robot traverses to the grid occupied by the obstacle or the unknown grid in the eight grids, the robot stops traversing in this direction and continues traversing in other directions. The robot clusters the grids by setting the seed point to remove the isolated discrete independent areas in the grid map.
[0028] As one embodiment, the robot traverses the boundary of the independent area, including the following steps: the robot selects N rows of pixels to construct a pixel area, and then the robot traverses the grid map from top to bottom through the pixel area; then, the robot selects N columns of pixels to construct a pixel area, and then the robot traverses the grid map from left to right through the pixel area; in the process of traversing the grid map, the robot performs linear fusion on the boundary of the independent area of the grid map in the pixel area; wherein, N is a natural number greater than 1.
[0029] As one example, Figure 5As shown, N is 3, the robot uses 3 rows of pixels to construct a pixel area, and the robot performs straight line fusion in the pixel area, including the following steps: the robot detects the straight lines in the pixel area, and then obtains the distance threshold and length threshold of the straight lines in the pixel area; the robot determines whether the length threshold of the straight lines in each column or row in the pixel area is greater than or equal to the set length threshold; if the length threshold of the straight lines in any column or row in the pixel area is greater than or equal to the set length threshold, the robot retains the straight lines in the column or row with the largest length threshold in the pixel area, and removes the straight lines in other columns or rows in the pixel area; the robot determines whether the distance threshold of the straight lines in the column or row with the largest length threshold in the pixel area is less than or equal to the set distance threshold; if the distance threshold of the straight lines in the column or row with the largest length threshold in the pixel area is less than or equal to the set distance threshold, the robot connects the straight lines in the column or row; if the length threshold of the straight lines in any column or row in the pixel area is less than the set length threshold, the robot does not fuse the straight lines in the pixel area; wherein, the distance threshold is the distance between the two nearest endpoints of the straight lines in the same column or row; and the length threshold is the total length of the straight lines in the same column or row. As Figure 5 As shown in (1), if the length threshold of the straight line of the second pixel row in the pixel area is greater than the set length threshold, and the length threshold of the straight line of the second pixel row is the largest, then the straight lines of the first pixel row and the third pixel row are removed, and only the straight line of the second pixel row is retained. Then the robot determines the distance threshold of the straight line of the second pixel row. Since the distance threshold of the straight line of the second pixel row is greater than the set distance threshold, the straight line of the second pixel row is not connected, and the straight lines of the first pixel row and the third pixel row in the pixel area are removed. Figure 5 As shown in (2) in , the length threshold of the straight line in the second pixel row of the pixel area is the largest and greater than the set length threshold, so only the straight line in the second pixel row is retained, and the distance threshold of the straight line in the second pixel row is less than the set distance threshold, then the two straight lines in the second pixel row are connected. Figure 5 As shown in (3), if the length thresholds of the straight lines of the three pixel rows in the pixel area are all less than the set length threshold, the robot will not process the straight lines in the pixel area to prevent incorrect fusion. The robot performs straight line fusion by deleting redundant straight lines at the boundary to improve the display quality of the raster map.
[0030] As one of the embodiments, the robot detects a straight line in a pixel area, including the following steps: when the robot traverses a grid map through the pixel area from top to bottom, if there are two or more boundary points of independent areas adjacent in a pixel row of the pixel area, these adjacent boundary points are set to straight lines; when the robot traverses the grid map through the pixel area from left to right, if there are two or more boundary points of independent areas adjacent in a pixel column of the pixel area, these adjacent boundary points are set to straight lines.
[0031] Compared with the existing technology, the advantage of the present application lies in that: the robot described in the present application first searches for the contour of the raster map to obtain the contour in the raster map, then uses the contour of the raster map as the boundary to construct an independent area, and then performs straight line fusion on the boundary of the independent area to straighten the boundary of the independent area, thereby obtaining an optimized raster map, which effectively improves the display quality of the raster map.
[0032] In the description of the specification, the description with reference to the terms "one embodiment", "preferably", "example", "specific example" or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention, and the schematic expressions of the above terms in this specification do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. The connection method connected in the description of the specification has obvious effects and practical effectiveness.
[0033] Through the description of the above structure and principle, technicians in the relevant technical field should understand that the present invention is not limited to the above-mentioned specific implementation methods. Improvements and substitutions based on the present invention using the well-known technology in the field all fall within the protection scope of the present invention and should be defined by the claims.
Claims
1. A method for optimizing a grid map, characterized in that: The method comprises the following steps: S1: The robot obtains a grid map of the environment, and then searches for contours on the grid map; S2: The robot obtains the independent area according to the outline of the grid map, and then the robot traverses the boundary of the independent area; S3: When the robot traverses the boundaries of independent areas, it performs straight line fusion to obtain an optimized grid map.
2. A grid map optimization method according to claim 1, characterized in that: In step S1, after the robot obtains the grid map of the environment, The following steps are involved: The robot acquires laser data of the environment through laser sensors and constructs a grid map based on the acquired laser data; The robot performs ternary processing on the acquired raster map to obtain a ternary raster map; The robot performs an opening operation on the ternary grid map to obtain a grid map after removing boundary noise.
3. A grid map optimization method according to claim 2, characterized in that: The robot searches for contours on the grid map, including the following steps: The robot performs binarization processing on the grid map, and then traverses the binarized grid map; During the robot's traversal process, if the eight adjacent pixels of any black pixel in the binary grid map are all black pixels, the black pixel will be deleted; The robot uses the retained black pixels as the outline of the raster map.
4. A grid map optimization method according to claim 1, characterized in that: The robot obtains independent areas according to the outline of the grid map, including the following steps: The robot traverses the contours of the grid map and obtains the closed contours in the grid map; The robot calculates the area of closed contours in the raster map; The robot sets contours with an area greater than or equal to the set area as independent areas.
5. A grid map optimization method according to claim 4, characterized in that: The robot obtains closed contours in the grid map, including the following steps: The robot traverses the outline of the grid map. If any pixel point on the outline of the grid map has two or more pixel points adjacent to it, the outline is judged to be a closed outline.
6. A grid map optimization method according to claim 4, characterized in that: The robot calculates the area of a closed contour, including the following steps: The robot obtains the number of pixels constituting the closed contour and obtains the pixel coordinates of each pixel on the grid map; The robot calculates the area of the closed contour based on the number of pixels that make up the closed contour and the pixel coordinates of each pixel on the grid map.
7. A grid map optimization method according to claim 6, characterized in that: After the robot obtains the independent area, it generates the seed point of the independent area, and then the robot selects the independent area according to the seed point, including the following steps: The robot converts the raster map of the screened independent area into a three-valued raster map; The robot selects a grid from the free grids in the independent area of the ternary grid map; The robot uses the selected grid as the seed point, and then clusters the grids of the grid map according to the seed point to filter out the target independent area; The robot removes the independent areas except the target independent area to obtain a denoised grid map.
8. A grid map optimization method according to claim 7, characterized in that: The robot traverses the boundaries of the independent area, The following steps are involved: The robot selects N rows of pixels to construct a pixel region, and then the robot traverses the grid map from top to bottom through the pixel region; Next, the robot selects N columns of pixels to construct a pixel region, and then the robot traverses the grid map from left to right through the pixel region; When the robot traverses the grid map, the robot performs straight line fusion on the boundaries of independent areas of the grid map in the pixel area; Wherein, N is a natural number greater than 1.
9. A grid map optimization method according to claim 8, characterized in that: The robot performs line fusion in the pixel area, including the following steps: The robot detects a straight line in a pixel area, and then obtains a distance threshold and a length threshold of the straight line in the pixel area; The robot determines whether a length threshold of a straight line in each column or row in the pixel area is greater than or equal to a set length threshold; If the length threshold of a straight line in any column or row in the pixel area is greater than or equal to the set length threshold, the robot retains the straight line in the column or row with the largest length threshold in the pixel area, and removes the straight lines in other columns or rows in the pixel area; The robot determines whether the distance threshold of a straight line in a column or a row with the largest length threshold in the pixel area is less than or equal to the set distance threshold; If the distance threshold of the straight lines in a column or row with the largest length threshold in the pixel area is less than or equal to the set distance threshold, the robot connects the straight lines in the column or row; If the length threshold of a straight line in any column or row in the pixel area is less than the set length threshold, the robot will not fuse the straight lines in the pixel area; The distance threshold is the distance between the two nearest endpoints of the straight lines in the same column or row; and the length threshold is the total length of the straight lines in the same column or row.
10. A grid map optimization method according to claim 9, characterized in that: The robot detects straight lines in a pixel area, including the following steps: When the robot traverses the grid map from top to bottom through the pixel area, if there are two or more adjacent boundary points of independent areas in the pixel row of the pixel area, these adjacent boundary points are set as straight lines; When the robot traverses the grid map from left to right through the pixel area, if there are two or more adjacent boundary points of independent areas in the pixel column of the pixel area, these adjacent boundary points are set as straight lines.