Disclosure of Invention
The present invention is directed to at least one of the technical problems in the prior art, and provides a method, an apparatus and a storage medium for full coverage path planning.
The technical scheme adopted by the invention for solving the problems is as follows:
in a first aspect of the present invention, a method for planning a full coverage path includes the steps of:
decomposing a map into a plurality of access units;
acquiring an access sequence of a plurality of access units;
acquiring the shortest connection path among a plurality of access units according to the access sequence;
acquiring a fully planned path according to the shortest connection path;
wherein the step of decomposing the map into a plurality of access units comprises:
acquiring a connected domain of each column of the map;
acquiring an adjacent matrix of two adjacent columns of the map, wherein the adjacent matrix is used for representing the connection condition between two columns of connected domains;
converting the connected component into the access unit according to the adjacency matrix.
According to the first aspect of the present invention, the step of obtaining the connection matrix of two adjacent columns of the map specifically includes:
setting the size of the map as m x k, wherein the ith column of the map is provided with a connected domains, the (i-1) th column of the map is provided with b connected domains, and establishing the adjacent matrix with the size of a x b, wherein the columns of the adjacent matrix represent the connected domains of the ith column of the map in a one-to-one correspondence manner, the rows of the adjacent matrix represent the connected domains of the (i-1) th column of the map in a one-to-one correspondence manner, and i belongs to {2,3, …, k };
the elements of the adjacency matrix are labeled as 0 or 1, where 0 denotes that two connected domains are connected and 1 denotes that two connected domains are not connected.
According to a first aspect of the invention, the step of converting the connected component into the access unit according to the adjacency matrix comprises:
when the sum of a row of elements in the adjacency matrix is equal to 0, closing the current access unit to generate a new access unit; when the sum of a row of elements in the adjacency matrix is equal to 1, the connected domain corresponding to the row of elements is attributed to the current access unit; when the sum of the row of elements in the adjacent matrix is greater than 1, closing all current access units, and generating a new access unit by the connected domain corresponding to the row of elements;
when the sum of a column of elements in the adjacency matrix is equal to 0 or 1, closing all current access units; and when the sum of the elements in the adjacent matrix and one column is more than 1, merging the access unit corresponding to the last connected domain of the column with the access unit corresponding to the connected domain.
According to the first aspect of the present invention, the obtaining an access sequence of the plurality of access units comprises:
randomly generating a plurality of father individuals, and forming a population by the father individuals, wherein the father individuals are random combination sequences of the access units;
calculating the length of a covering path of each father individual to obtain an optimal individual with the shortest length of the covering path;
repeating the following steps until the iteration is completed, and outputting the final optimal individual as an access sequence of a plurality of access units:
randomly selecting any two father individuals in the population, and generating a plurality of child individuals by using a genetic operator, wherein the number of the child individuals is the same as that of the father individuals in the population;
randomly transforming the sequence order of any two access units in each sub-individual to obtain transformed sub-individuals;
and replacing the parent individuals of the population with the transformation child individuals, calculating the coverage path length of each transformation child individual, comparing the coverage path length of each transformation child individual with the coverage path length of the optimal individual, and updating the optimal individual.
According to the first aspect of the present invention, the method for obtaining the shortest connection path between the plurality of access units according to the access sequence is a visual graph method, an a-x method, a fast random search method, an artificial potential field method, or a Dijkstra method.
In a second aspect of the present invention, a full coverage path planning apparatus includes:
a decomposition unit for decomposing the map into a plurality of access units;
a sequence calculation unit for acquiring access sequences of the plurality of access units;
the shortest path calculation unit is used for acquiring the shortest connection path among the access units according to the access sequence;
the fully planned path calculation unit is used for acquiring a fully planned path according to the shortest connection path;
wherein the decomposition unit comprises:
a connected domain calculation unit for acquiring a connected domain of each column of the map;
the adjacency matrix calculation unit is used for acquiring adjacency matrixes of two adjacent columns of the map, wherein the adjacency matrixes are used for representing the connection condition between two columns of connected domains;
a conversion unit for converting the connected component into the access unit according to the adjacency matrix.
According to the second aspect of the present invention, the adjacency matrix calculation unit includes:
the map generation device comprises an establishing unit, a generating unit and a generating unit, wherein the establishing unit is used for establishing an adjacent matrix, the size of the adjacent matrix is a x b, the size of the map is m x k, the ith column of the map is provided with a connected domain, the ith-1 column of the map is provided with b connected domains, the columns of the adjacent matrix represent the connected domains of the ith column of the map in a one-to-one correspondence mode, the rows of the adjacent matrix represent the connected domains of the ith-1 column of the map in a one-to-one correspondence mode, and i belongs to {2,3, …, k };
and the marking unit is used for marking the elements of the adjacency matrix as 0 or 1, wherein 0 represents that two connected domains are connected, and 1 represents that the two connected domains are not connected.
According to a second aspect of the invention, the conversion unit is adapted to perform the steps of:
when the sum of a row of elements in the adjacency matrix is equal to 0, closing the current access unit to generate a new access unit; when the sum of a row of elements in the adjacency matrix is equal to 1, the connected domain corresponding to the row of elements is attributed to the current access unit; when the sum of the row of elements in the adjacent matrix is greater than 1, closing all current access units, and generating a new access unit by the connected domain corresponding to the row of elements;
when the sum of a column of elements in the adjacency matrix is equal to 0 or 1, closing all current access units; and when the sum of the elements in the adjacent matrix and one column is more than 1, merging the access unit corresponding to the last connected domain of the column with the access unit corresponding to the connected domain.
According to a second aspect of the invention, the sequence calculation unit is adapted to perform the steps of:
randomly generating a plurality of father individuals, and forming a population by the father individuals, wherein the father individuals are random combination sequences of the access units;
calculating the length of a covering path of each father individual to obtain an optimal individual with the shortest length of the covering path;
repeating the following steps until the iteration is completed, and outputting the final optimal individual as an access sequence of a plurality of access units:
randomly selecting any two father individuals in the population, and generating a plurality of child individuals by using a genetic operator, wherein the number of the child individuals is the same as that of the father individuals in the population;
randomly transforming the sequence order of any two access units in each sub-individual to obtain transformed sub-individuals;
and replacing the parent individuals of the population with the transformation child individuals, calculating the coverage path length of each transformation child individual, comparing the coverage path length of each transformation child individual with the coverage path length of the optimal individual, and updating the optimal individual.
In a third aspect of the present invention, a storage medium stores instructions executable by a processor to implement a full coverage path planning method according to the first aspect of the present invention.
The scheme at least has the following beneficial effects: and converting the connected domains into the access units according to the adjacency matrix for representing the connection condition between the two columns of connected domains, so that the number of the access units is reduced, the repeated paths and the turning number in the fully planned path are further reduced, and the working time and the energy consumption of the robot are reduced.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Detailed Description
Reference will now be made in detail to the present preferred embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like reference numerals refer to like elements throughout.
In the description of the present invention, it should be understood that the orientation or positional relationship referred to in the description of the orientation, such as the upper, lower, front, rear, left, right, etc., is based on the orientation or positional relationship shown in the drawings, and is only for convenience of description and simplification of description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus, should not be construed as limiting the present invention.
In the description of the present invention, the meaning of a plurality of means is one or more, the meaning of a plurality of means is two or more, and larger, smaller, larger, etc. are understood as excluding the number, and larger, smaller, inner, etc. are understood as including the number. If the first and second are described for the purpose of distinguishing technical features, they are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
In the description of the present invention, unless otherwise explicitly limited, terms such as arrangement, installation, connection and the like should be understood in a broad sense, and those skilled in the art can reasonably determine the specific meanings of the above terms in the present invention in combination with the specific contents of the technical solutions.
Referring to fig. 1 and 2, an embodiment of a first aspect of the present invention provides a full coverage path planning method.
The full coverage path planning method comprises the following steps:
step S100, decomposing a map into a plurality of access units;
step S200, acquiring access sequences of a plurality of access units;
step S300, acquiring the shortest connection path among a plurality of access units according to the access sequence;
s400, acquiring a fully planned path according to the shortest connection path;
wherein, in step S100, the step of decomposing the map into a plurality of access units comprises:
step S110, acquiring a connected domain of each row of the map;
step S120, acquiring an adjacent matrix of two adjacent columns of the map, wherein the adjacent matrix is used for representing the connection condition between two columns of connected domains;
and step S130, converting the connected domain into an access unit according to the adjacency matrix.
It should be noted that, for a map with a size of m × k, the map has k columns of pixels. For a column of pixels, a pixel with an obstacle is represented by 0, a pixel without an obstacle is represented by 1, and a plurality of consecutive pixels represented by 1 constitute a connected domain.
For the adjacent matrix, a one-dimensional array is used for storing the data of the connected domains of two adjacent columns, and a two-dimensional array is used for storing the data of the relationship between the connected domains. This two-dimensional array is effectively a contiguous matrix.
In the embodiment, the connected domains are converted into the access units according to the adjacency matrix for representing the connection condition between the two columns of connected domains, so that the number of the access units is reduced, the repeated paths and the number of turns in the fully planned path are further reduced, and the working time and the energy consumption of the robot are reduced.
The step of decomposing the map into a plurality of access units of the present invention is an improvement over the no-till unit decomposition method. The basic idea of the cattle cultivation type unit decomposition method is as follows: and traversing each column in the map, and calculating the connectivity of the connected domains of two adjacent columns. Whenever connectivity increases, an IN event is triggered, closing the current access unit and opening two new access units. Whenever connectivity is degraded, an OUT event is triggered, the current two access units close, and a new access unit opens. Combining multiple units in the Middle event into one unit, neither starting a new unit nor closing the current unit in the Middle event, but only updating the range of the current unit.
Further, for step S120, the step of acquiring the connection matrix of two adjacent columns of the map specifically includes:
setting the size of the map as m x k, wherein the ith column of the map is provided with a connected domain, the (i-1) th column of the map is provided with b connected domains, and establishing an adjacent matrix with the size of a x b, wherein the columns of the adjacent matrix represent the connected domains of the ith column of the map in a one-to-one correspondence manner, the rows of the adjacent matrix represent the connected domains of the (i-1) th column of the map in a one-to-one correspondence manner, and i belongs to {2,3, …, k };
the elements of the adjacency matrix are labeled as 0 or 1, where 0 indicates that two connected domains are connected and 1 indicates that two connected domains are not connected.
Further, for step S130, the step of converting the connected component into the access unit according to the adjacency matrix includes:
judging the connection condition from the i-1 column to the i column: when the sum of a row of elements in the adjacency matrix is equal to 0, closing the current access unit to generate a new access unit; when the sum of a row of elements in the adjacency matrix is equal to 1, the connected domain corresponding to the row of elements belongs to the current access unit; when the sum of the row of elements in the adjacency matrix is greater than 1, closing all current access units, and generating a new access unit by using a connected domain corresponding to the row of elements;
judging the connection condition from the i column to the i-1 column: when the sum of a column of elements in the adjacency matrix is equal to 0 or 1, closing all current access units; when the sum of the elements in the adjacent matrix and a column is greater than 1, the access unit corresponding to the last connected domain of the column is merged with the access unit corresponding to the connected domain.
In summary, the basic idea of the step of decomposing the map into a plurality of access units of the present invention is:
judging the connection condition from the i-1 column to the i column: (1) referring to FIG. 4, if the i-1 column is connected to the i column, the i column and the i-1 column are merged into one access unit, and the access units are labeled the same; (2) referring to FIG. 5, if an In event occurs, the i column generates two new access units.
Judging the connection condition from the i column to the i-1 column: (1) referring to FIG. 6, when a portion of i column is connected to a plurality of portions of i-1 column, i column is connected to the last portion of i-1 column and merged into one access unit, and the access unit number of i column is equal to the access unit number connected to it; (2) referring to fig. 7, all connected parts of the i column are not connected to any part of the i-1 column, and the numbered process of the connected parts of the i column is the same as the In event. The different access units in the figure are marked 1, 2 and 3 respectively; the same access unit is labeled with the same number. Denoted as ith column, with i marked above. The white solid portion is an obstacle.
Some embodiments of the first aspect of the present invention, obtaining an access sequence of a plurality of access units comprises:
randomly generating a plurality of father individuals, and forming a population by the father individuals, wherein the father individuals are random combination sequences of the access units;
calculating the length of a covering path of each father individual to obtain an optimal individual with the shortest length of the covering path;
repeating the following steps until the iteration is completed, and outputting the final optimal individual as an access sequence of a plurality of access units:
randomly selecting any two father individuals in the population, and generating a plurality of child individuals by using a genetic operator, wherein the number of the child individuals is the same as that of the father individuals in the population;
randomly transforming the sequence order of any two access units in each sub-individual to obtain transformed sub-individuals;
and replacing the transformation sub-individuals with the parent individuals of the population, calculating the length of the coverage path of each transformation sub-individual, comparing the length of the coverage path of each transformation sub-individual with the length of the coverage path of the optimal individual, and updating the optimal individual.
In some embodiments of the first aspect of the present invention, the method for obtaining the shortest connection path between the plurality of access units according to the access sequence is a visual graph method.
In certain embodiments of the first aspect of the present invention, the method by which the fully planned path is obtained from the shortest connecting path is a path planning algorithm based on a biostimulation neural network algorithm.
Referring to fig. 3, an embodiment of a second aspect of the present invention provides a full coverage path planning apparatus.
The full coverage path planning device comprises:
a decomposition unit 100 for decomposing the map into a plurality of access units;
a sequence calculation unit 200 for obtaining access sequences of a plurality of access units;
a shortest path calculating unit 300, configured to obtain a shortest connection path between multiple access units according to the access sequence;
a fully planned path calculation unit 400, configured to obtain a fully planned path according to the shortest connection path;
wherein, the decomposition unit 100 includes:
a connected component calculation unit 110, configured to obtain a connected component for each column of the map;
the adjacency matrix calculation unit 120 is configured to obtain an adjacency matrix of two adjacent columns of the map, where the adjacency matrix is used to represent a connection condition between two columns of connected domains;
a conversion unit 130 for converting the connected component into an access unit according to the adjacency matrix.
In some embodiments of the second aspect of the present invention, the adjacency matrix calculation unit 120 includes:
the map building method comprises the steps of building an adjacency matrix, wherein the size of the adjacency matrix is a x b, the size of the map is m x k, the ith column of the map is provided with a connected domains, the (i-1) th column of the map is provided with b connected domains, columns of the adjacency matrix represent the connected domains of the ith column of the map in a one-to-one correspondence mode, rows of the adjacency matrix represent the connected domains of the (i-1) th column of the map in a one-to-one correspondence mode, and i belongs to {2,3, …, k };
and the marking unit is used for marking the elements of the adjacency matrix as 0 or 1, wherein 0 represents that the two connected domains are connected, and 1 represents that the two connected domains are not connected.
In some embodiments of the second aspect of the present invention, the conversion unit 130 is configured to perform the following steps:
when the sum of a row of elements in the adjacency matrix is equal to 0, closing the current access unit to generate a new access unit; when the sum of a row of elements in the adjacency matrix is equal to 1, the connected domain corresponding to the row of elements belongs to the current access unit; when the sum of the row of elements in the adjacency matrix is greater than 1, closing all current access units, and generating a new access unit by using a connected domain corresponding to the row of elements;
when the sum of a column of elements in the adjacency matrix is equal to 0 or 1, closing all current access units; when the sum of the elements in the adjacent matrix and a column is greater than 1, the access unit corresponding to the last connected domain of the column is merged with the access unit corresponding to the connected domain.
In some embodiments of the second aspect of the present invention, the sequence calculation unit 200 is configured to perform the following steps:
randomly generating a plurality of father individuals, and forming a population by the father individuals, wherein the father individuals are random combination sequences of the access units;
calculating the length of a covering path of each father individual to obtain an optimal individual with the shortest length of the covering path;
repeating the following steps until the iteration is completed, and outputting the final optimal individual as an access sequence of a plurality of access units:
randomly selecting any two father individuals in the population, and generating a plurality of child individuals by using a genetic operator, wherein the number of the child individuals is the same as that of the father individuals in the population;
randomly transforming the sequence order of any two access units in each sub-individual to obtain transformed sub-individuals;
and replacing the transformation sub-individuals with the parent individuals of the population, calculating the length of the coverage path of each transformation sub-individual, comparing the length of the coverage path of each transformation sub-individual with the length of the coverage path of the optimal individual, and updating the optimal individual.
In some embodiments of the second aspect of the present invention, the method employed by the shortest path calculation unit 300 is a visual graph method.
In some embodiments of the second aspect of the present invention, the method used by the fully planned path computation unit 400 is a path planning algorithm based on a biostimulating neural network algorithm.
It should be noted that, the full-coverage path planning apparatus provided by the second aspect of the present invention adopts the full-coverage path planning method provided by the first aspect of the present invention, and each unit of the full-coverage path planning apparatus provided by the second aspect of the present invention corresponds to each step of the full-coverage path planning method provided by the first aspect of the present invention one by one, has the same technical solution, solves the same technical problem, has the same technical effect, and is not described in detail herein.
Embodiments of a third aspect of the present invention provide a storage medium. The storage medium stores instructions executable by the processor to implement a full coverage path planning method as an embodiment of the first aspect of the invention.
Examples of storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
The above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above embodiment, and the present invention shall fall within the protection scope of the present invention as long as the technical effects of the present invention are achieved by the same means.