Position recognition method and device based on two-dimensional laser radar feature point template matching
Through two-dimensional lidar feature point template matching technology, the feature points and descriptors of key frames are extracted and matched to build a word bag library, which solves the problems of large calculation amount and insufficient real-time performance in the existing technology, and realizes fast and accurate robots. Relocation.
Patent Information
- Application Number
- CN202110930420.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-13
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-08-13
AI Technical Summary
The existing position recognition technology based on two-dimensional lidar is computationally intensive and cannot meet the real-time needs of robot relocation.
A method based on two-dimensional lidar feature point template matching is used to construct a word bag library by extracting feature points and descriptors of key frames, and query the trained dictionary during relocation to quickly match the map location.
It significantly reduces the amount of calculation, improves the matching speed, and meets the real-time requirements for robot relocation.
Smart Images

Figure CN113569982B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of autonomous navigation and positioning technology, and in particular relates to a position recognition method and device based on two-dimensional laser radar feature point template matching. Background Art
[0002] In order to realize the autonomous movement of robots, people often need to build a map of the environment and obtain the robot's position in the map after building the map to perform tasks. For robots equipped with two-dimensional laser radar, when the robot's position in the map is unknown, it is necessary to determine the robot's position by identifying the positions it has been to. This process is called relocalization. The technology of identifying the positions that have been visited is called "position recognition."
[0003] At present, position recognition technology based on two-dimensional lidar often uses a more brute force method: that is, by trying to place the emission origin of the current laser data in all possible places in the map, calculating the degree of match between the laser contour and the map at that location when the emission origin is at that location. This method not only causes a huge amount of calculation, but also cannot meet the real-time requirements of robot repositioning. Summary of the invention
[0004] In view of the above problems, the present invention provides a position recognition method and device based on two-dimensional laser radar feature point template matching to solve the above or other problems existing in the prior art.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: a location recognition method based on two-dimensional laser radar feature point template matching, comprising:
[0006] The robot builds a map. During the mapping process, it extracts the feature points of each key frame and calculates the descriptors of the feature points.
[0007] The information of each key frame and the data of all descriptors in each key frame are saved, and the dictionary is trained during the saving process to calculate the bag-of-words library of each key frame;
[0008] When the robot is relocalized, the feature points of the current key frame are extracted, the descriptors are calculated, and the bag-of-words library of the current key frame is generated;
[0009] Calculate the similarity between the bag-of-words library of the current key frame and the bag-of-words library of all key frames saved during the construction of the map one by one to obtain the most similar key frame;
[0010] The data of the current keyframe is matched with the map at the position corresponding to the most similar keyframe for relocation.
[0011] Furthermore, in the process of mapping, in the step of extracting the feature points of each key frame, the calculation formula of the feature points is:
[0012]
[0013] Wherein, S(x; t) is the distance shape function of the one-dimensional laser data, and t is the serial number of the laser point.
[0014] Furthermore, in the process of mapping, feature points of each key frame are extracted, and in the step of calculating the descriptor of the feature points, the shape context method is used to calculate the descriptor, including:
[0015] Make polar coordinates for any feature point in the key frame and divide it into angle area and distance area;
[0016] The number of contour points in each area is counted and normalized to generate a histogram of any feature point.
[0017] Furthermore, the similarity between the bag-of-words library of the current key frame and the bag-of-words library of all key frames saved during map construction is calculated one by one. In the step of obtaining the most similar key frame, the similarity between each feature point is determined by comparing the descriptors of the feature points. The key frame is represented by a vector, key frame = [the number of feature points of the first type, the number of feature points of the second type, the number of feature points of the third type, ...], and the similarity is calculated using the Hamming distance of the two vectors.
[0018] Furthermore, the dictionary includes all words, a word is each type of descriptor, and the bag of words library is the words corresponding to all descriptors in each key frame.
[0019] Furthermore, the dictionary construction steps include:
[0020] a. Randomly select k features and set them as the center;
[0021] b. Calculate the distance between each feature and each center, and take the feature with the smallest distance as the classification;
[0022] c. Recalculate the mean of all classes. If the mean changes very little, the algorithm converges and exits; otherwise, return to step c.
[0023] Furthermore, the dictionary is expressed using a k-ary tree, where the number of layers of the k-ary tree is d and the number of branches in each layer is k, until the leaf layer.
[0024] Furthermore, the data of the current key frame is matched with the map at the position corresponding to the most similar key frame, and in the relocalization step, it is determined whether the matching score is greater than a threshold, and if so, the relocalization is determined to be successful.
[0025] A position recognition device based on two-dimensional laser radar feature point template matching, comprising:
[0026] Feature point extraction module, used to obtain feature points of each key frame;
[0027] A descriptor calculation module is used to calculate the descriptors of feature points;
[0028] The storage module is used to save the information of all key frames and their descriptor data during the mapping process;
[0029] Dictionary training module, used to perform dictionary training using saved data;
[0030] The query module is used to query all key frames saved during the construction of the map with the current key frame, and calculate the similarity with each key frame;
[0031] The map matching module is used to match the current key frame with the map at the position corresponding to the most similar key frame for repositioning.
[0032] An electronic device includes a memory, a processor, and one or more programs stored in the memory and executable on the processor. When the one or more programs are executed by the processor, the electronic device executes the above-mentioned position recognition method based on two-dimensional laser radar feature point template matching.
[0033] A computer-readable storage medium stores computer instructions. When the computer instructions are executed on a processor of an electronic device, the device where the computer storage medium is located executes the above-mentioned position recognition method based on two-dimensional laser radar feature point template matching.
[0034] Due to the adoption of the above technical solution, in the process of robot mapping, the feature points of each key frame are extracted, and the descriptors are calculated, and the serial numbers and descriptors of the key frames are saved. The dictionary is constructed and trained according to the saved data, and the word bag library of each key frame is calculated. When relocating, the feature points and descriptors of the current key frame are obtained, the trained dictionary is queried, and the word bag library of the current key frame is generated. By comparing the similarity between the word bag library of the current frame and the word bag library of all frames during mapping, the most similar mapping key frame is found for positioning, and the traversal of all positions on the matching map is changed to comparing the word bag library of the current frame and the word bag library of the mapping frame, so as to reduce the amount of calculation, greatly improve the matching speed, find the positioning, greatly improve the speed of relocation, save time, and meet the real-time nature of robot relocation. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 is a logic flow chart of a mapping process according to an embodiment of the present invention;
[0036] Figure 2 is a logic flow chart of relocation of an embodiment of the present invention;
[0037] Figure 3 is a characteristic point marking schematic diagram of an embodiment of the present invention;
[0038] Figure 4 is a schematic diagram of a distance shape function of one-dimensional laser data according to an embodiment of the present invention;
[0039] Figure 5 is a schematic diagram of shape context logarithmic polar coordinates according to an embodiment of the present invention;
[0040] Figure 6 is a schematic diagram of a shape context histogram according to an embodiment of the present invention;
[0041] Figure 7 is a polar coordinate histogram of a certain feature point of an embodiment of the present invention;
[0042] Figure 8 is a schematic diagram of a k-ary tree structure of a dictionary according to an embodiment of the present invention;
[0043] Fig. 9 1 is a comparison chart of the repositioning time with and without laser feature matching according to an embodiment of the present invention. DETAILED DESCRIPTION
[0044] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
[0045] Figure 1 and Figure 2 A logic flow chart of an embodiment of the present invention is shown. An embodiment of the present invention relates to a position recognition method and device based on two-dimensional laser radar feature point template matching, which is suitable for an autonomous mobile robot carrying a two-dimensional laser radar to obtain a position in a priori map from an unknown state. By changing the traversal of all positions on the matching map to comparing the word bag library of the current frame and the word bag library of the mapping frame, the matching speed can be greatly improved, the position can be found, and the speed of repositioning can be improved.
[0046] A location recognition method based on two-dimensional laser radar feature point template matching, comprising:
[0047] The robot builds a map. During the mapping process, the feature points of each key frame are extracted and the descriptors of the feature points are calculated. Specifically, when starting to build a map, laser data is received. When using a lidar to build a map, not every frame of laser data is used. Usually, a frame is used at a certain distance. Such a frame is called a key frame. The feature points of each key frame are extracted, such as corner points, endpoints, etc. Figure 3 As shown in the figure, the circled part is the location of the feature point.
[0048] In the process of using LiDAR to build maps, when extracting the feature points of each key frame, considering the distance data in the LiDAR data, a frame of laser data can be simplified into a sequence of one-dimensional data, and the distance shape function of the one-dimensional laser data is recorded as S(x; t). The second-order derivative of S(x; t) is obtained:
[0049]
[0050] (D2*S)(x;t)=S(x-1;t)-2S(x;t)+S(x+1;t)
[0051] The calculation formula of the feature points is:
[0052]
[0053] Wherein, S(x; t) is the distance shape function of the one-dimensional laser data, and t is the serial number of the laser point.
[0054] Therefore, solving the extreme value of the above formula can find the characteristic points, such as Figure 4 Point A shown.
[0055] Extract the feature points of each key frame and calculate the descriptor of the extracted feature points. Each key frame has multiple feature points, so when extracting feature points, extract all the feature points of the key frame. The descriptor is a parameter used to describe the characteristics of the feature points. Each feature point is identified by encoding the feature points. During the relocation process, the system determines the similarity between each feature point by comparing the descriptors of the feature points.
[0056] In this application, a shape context method is used to calculate the descriptor, including:
[0057] Make polar coordinates for any feature point in the key frame and divide it into angle area and distance area;
[0058] The number of contour points in each area is counted and normalized to generate a histogram of any feature point.
[0059] For example: Figure 5 , select any point in shape "A" to make polar coordinates for it, and divide it into angle area and distance area, then count the number of contour points in each area and normalize them, so as to generate the histogram of the point, such as Figure 6 shown. Figure 7 The polar coordinate histogram describing a certain feature point is visualized, where the darker the color of the grid, the more laser points fall into the grid.
[0060] The information of each key frame and the data of all descriptors in each key frame are saved, and the dictionary is trained during the saving process, and the word bag library of each key frame is calculated; after all the feature points of each key frame are extracted and the descriptors of each feature point are calculated, the key frame sequence information and its related feature points and descriptors are saved in the running memory, that is, the running memory stores the sequence information, posture and all feature points and descriptors of all key frames during the mapping process; after the mapping is completed, the data saved in the running memory during the mapping process is saved, the dictionary is trained, and the word bag library of each key frame is calculated.
[0061] Among them, the dictionary includes all words, a word is each type of descriptor, and the word bag library is the words corresponding to all descriptors in each key frame. Specifically, after the map is built, all descriptors are classified, and a label called "word" is set for each type of descriptor. The collection of all words is called a "dictionary". After obtaining the dictionary, query the words corresponding to all descriptors in each key frame to form a word group. This word group is called a "word bag library", that is, one word bag library for one key frame. The process of building a dictionary and obtaining a historical key frame word bag library is called "training", and the dictionary is trained using the saved data.
[0062] Each "word" in the dictionary is a collection of certain features, that is, the process of generating a dictionary is a clustering process. Here, the classic K-means algorithm is used to build the system dictionary. The steps of building the dictionary include:
[0063] a. Randomly select k features, such as c1, c2, c3, ..., and set these k features as the center;
[0064] b. Calculate the distance between each feature and each center, and take the feature with the smallest distance as the classification;
[0065] c. Recalculate the mean of all classes. If the mean changes very little, the algorithm converges and exits; otherwise, return to step c.
[0066] Since each key frame can extract a large number of feature points, the dictionary size is usually very large. In order to reduce the time cost of searching for words, in this embodiment, a simple and practical tree structure is used to express the dictionary. In this embodiment, the dictionary is expressed using a k-ary tree, such as Figure 8 As shown in the figure, the number of layers (depth) of the k-ary tree is d, and the number of forks in each layer is k, that is, the samples under each layer node are clustered into k categories again until the leaf layer, which can accommodate kd words. k and d are selected and adjusted according to actual needs, and no specific requirements are made here. In the actual search process, the intermediate nodes above the leaf layer are only used for fast search, so as to ensure the efficiency of the search.
[0067] Then, the robot can find out what types of features and how many features exist in each key frame by looking up the dictionary. Give the words in the dictionary a number, such as "corner" as w1, "edge" as w2, "breakpoint" as w3, and so on.
[0068] According to the bag-of-words library of the key frame, we can know the words contained in the key frame. For example, the key frame contains two w1, one w2, and three w3. Then the content can be recorded as follows: set the key frame to A, then A=2w1+w2+3w3.
[0069] In this embodiment, the key frame is represented by a vector, then, key frame = [the number of feature points of the first type, the number of feature points of the second type, the number of feature points of the third type, ...], which is the bow vector. Then, the key frame A is represented by a vector: A = [2, 1, 3, 0, 0, 0 ...], and the word description of each key frame is calculated and saved.
[0070] When the robot is relocalized, the feature points of the current key frame are extracted, the descriptors are calculated, and the bag-of-words library of the current key frame is generated; specifically, when the robot is relocalized, first, it is added to the trained dictionary, and then, positioning is started, laser data is received, the feature points of the current key frame are extracted and its descriptors are calculated, a dictionary query is performed, the words corresponding to the descriptors are queried, the bag-of-words library of the current key frame is obtained, and the bow vector of the current key frame is calculated.
[0071] Calculate the similarity between the bag-of-words library of the current key frame and the bag-of-words library of all key frames saved during map construction one by one to obtain the most similar key frame: judge the similarity between each feature point by comparing the descriptors of the feature points, use the bow vector of the current key frame to query all key frames saved during map construction, calculate the similarity with each frame, and obtain the most similar key frame.
[0072] The similarity is calculated using the Hamming distance between two vectors. The Hamming distance refers to the number of different characters in the corresponding positions of two equal-length strings. Assume that the bow vectors of keyframe A and keyframe B are a and b respectively, then the similarity s between the two is: ||ab||1, where the norm L1 is the sum of the absolute values of each element. If a=b, then s=1, if a and b are completely opposite, then s=0.
[0073] Match the data of the current keyframe with the map at the position corresponding to the most similar keyframe for relocation: After finding the most similar keyframe, use the current laser data to match the map at the position corresponding to the keyframe to further refine the robot's position and get accurate positioning; when matching, determine whether the matching score is greater than the threshold. If so, the relocation is successful, otherwise, re-match. The threshold is set according to actual needs and no specific requirements are made here. Any known and feasible matching method such as ICP matching method and branch and bound matching method can be used for matching.
[0074] By using the above method, the traversal of all positions on the matching map is changed to comparing the word bag library of the current key frame and the word bag library of the mapping frame, which can greatly improve the matching speed and find the location, and can greatly improve the speed of relocation, such as Figure 2 As shown, curve 1 is a time-consuming curve diagram for traversing all position changes on the matching map, and curve 2 is a time-consuming curve diagram for relocation using mechanism feature matching. Figure 3 is the curve diagram of the difference between the two time consumptions, Figure 2 It can be known that the use of the method of the present application for relocation can shorten the time consumed in relocation and can greatly increase the speed of relocation.
[0075] A position recognition device based on two-dimensional laser radar feature point template matching, comprising:
[0076] Feature point extraction module, used to obtain feature points of each key frame;
[0077] A descriptor calculation module is used to calculate the descriptors of feature points;
[0078] The storage module is used to save the information of all key frames and their descriptor data during the mapping process;
[0079] Dictionary training module, used to perform dictionary training using saved data;
[0080] The query module is used to query all key frames saved during the construction of the map with the current key frame, and calculate the similarity with each key frame;
[0081] The map matching module is used to match the current key frame with the map at the position corresponding to the most similar key frame for repositioning.
[0082] During the robot's mapping process, the feature point extraction module extracts the feature points of each key frame, the descriptor calculation module describes the feature points, calculates the descriptors, and saves the key frame sequence number and descriptor to the storage module (running memory).
[0083] When the map is built, the data stored in the running memory during the program is saved. The dictionary training module trains the dictionary and calculates the bag of words library for each key frame.
[0084] When the robot starts positioning, it first loads the database and dictionary saved during mapping. The feature point extraction module extracts the feature points of the current key frame, the descriptor calculation module calculates the descriptor, and the query module queries the dictionary trained after the mapping is completed based on the descriptor to generate a bag of words library for the key frame, and calculates the similarity one by one with the bag of words of the mapping key frame in the database to find the most similar key frame. The map matching module uses the data of the current key frame to match the map at the corresponding position of the mapping key frame to obtain positioning.
[0085] An electronic device includes a memory, a processor, and one or more programs stored in the memory and executable on the processor. When the one or more programs are executed by the processor, the electronic device executes the above-mentioned position recognition method based on two-dimensional laser radar feature point template matching.
[0086] A computer-readable storage medium stores computer instructions. When the computer instructions are executed on a processor of an electronic device, the device where the computer storage medium is located executes the above-mentioned position recognition method based on two-dimensional laser radar feature point template matching.
[0087] The above-mentioned functional modules can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional units.
[0088] If the integrated module is implemented in the form of a software functional unit, it can be stored in a computer-readable storage medium. The technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the automatic slot counting method described in the embodiments of the present application.
[0089] The aforementioned storage media include: U disk, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.
[0090] Due to the adoption of the above technical solution, in the process of robot mapping, the feature points of each key frame are extracted, and the descriptors are calculated, and the serial numbers and descriptors of the key frames are saved. The dictionary is constructed and trained according to the saved data, and the word bag library of each key frame is calculated. When relocating, the feature points and descriptors of the current key frame are obtained, the trained dictionary is queried, and the word bag library of the current key frame is generated. By comparing the similarity between the word bag library of the current frame and the word bag library of all frames during mapping, the most similar mapping key frame is found for positioning, and the traversal of all positions on the matching map is changed to comparing the word bag library of the current frame and the word bag library of the mapping frame, so as to reduce the amount of calculation, greatly improve the matching speed, find the positioning, greatly improve the speed of relocation, save time, and meet the real-time nature of robot relocation.
[0091] The embodiments of the present invention are described in detail above, but the contents described are only preferred embodiments of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made within the scope of the present invention should still fall within the scope of the patent coverage of the present invention.
Claims
1. A location recognition method based on two-dimensional laser radar feature point template matching, characterized in that: The robot performs mapping, extracts feature points of each key frame during the mapping process, and calculates descriptors of the feature points; The information of each key frame and the data of all descriptors in each key frame are saved, and during the saving process, a dictionary is trained to calculate a bag-of-words library of each key frame; When the robot is repositioning, feature points of the current key frame during positioning are extracted, descriptors are calculated, and a bag-of-words library of the current key frame is generated; Calculate the similarity between the word bag library of the current key frame and the word bag libraries of all key frames saved during map construction one by one to obtain the most similar key frame; Matching the data of the current key frame with the map at the position corresponding to the most similar key frame to perform relocation; The robot builds a map. During the mapping process, it extracts the feature points of each key frame and calculates the descriptors of the feature points. When starting to build a map, it receives laser data. When using laser radar to build a map, it uses a frame at a certain distance. Such a frame is called a key frame, and the feature points of each key frame are extracted. In the process of using LiDAR to build maps, when extracting the feature points of each key frame, based on the distance data in the LiDAR data, a frame of laser data is simplified into a sequence of one-dimensional data, and the distance shape function of the one-dimensional laser data is recorded as S(x; t). The second-order derivative of S(x; t) is obtained: (D2*S)(x;t)=S(x-1;t)-2S(x;t)+S(x+1;t) The calculation formula of the feature points is: Where S(x; t) is the distance shape function of the one-dimensional laser data, and t is the serial number of the laser point; Solving the extreme value of the above formula will find the characteristic point; In the process of mapping, the feature points of each key frame are extracted, and in the step of calculating the descriptor of the feature points, the shape context method is used to calculate the descriptor, including: making polar coordinates for any feature point in the key frame, dividing the angle area and the distance area; counting the number of contour points in each area, and performing normalization processing to generate a histogram of any feature point.
2. The position recognition method based on two-dimensional laser radar feature point template matching according to claim 1 is characterized in that: The similarity between the bag-of-words library of the current key frame and the bag-of-words library of all key frames saved during map construction is calculated one by one. In the step of obtaining the most similar key frame, the similarity between each feature point is determined by comparing the descriptors of the feature points. The key frame is represented by a vector, key frame = [the number of feature points of the first type, the number of feature points of the second type, the number of feature points of the third type, ...], and the calculation of the similarity is represented by the Hamming distance of the two vectors.
3. The position recognition method based on two-dimensional laser radar feature point template matching according to claim 1 or 2, characterized in that: The dictionary includes all words, which are descriptors of each type, and the bag-of-words library includes words corresponding to all descriptors in each key frame.
4. The position recognition method based on two-dimensional laser radar feature point template matching according to claim 3 is characterized in that: The steps of constructing the dictionary include: a. Randomly select k features and set them as the center; b. Calculate the distance between each feature and each center, and take the feature with the smallest distance as the classification; c. Recalculate the mean of all classes. If the mean changes very little, the algorithm converges and exits; otherwise, return to step c.
5. The position recognition method based on two-dimensional laser radar feature point template matching according to claim 4 is characterized in that: The dictionary is expressed by a k-ary tree, the number of layers of the k-ary tree is d, and the number of branches in each layer is k, until the leaf layer.
6. The position recognition method based on two-dimensional laser radar feature point template matching according to claim 1 is characterized in that: The data of the current key frame is matched with the map at the position corresponding to the most similar key frame, and in the relocation step, it is determined whether the matching score is greater than a threshold. If so, the relocation is determined to be successful.
7. A position recognition device for two-dimensional laser radar feature point template matching based on the position recognition method for two-dimensional laser radar feature point template matching as claimed in claim 1, characterized in that: include: Feature point extraction module, used to obtain feature points of each key frame; A descriptor calculation module, used to calculate the descriptor of the feature point; The storage module is used to save the information of all key frames and their descriptor data during the mapping process; Dictionary training module, used to perform dictionary training using saved data; The query module is used to query all key frames saved during the construction of the map with the current key frame, and calculate the similarity with each key frame; The map matching module is used to match the current key frame with the map at the position corresponding to the most similar key frame for repositioning.
8. An electronic device, characterized in that: It includes a memory, a processor, and one or more programs stored in the memory and executable on the processor. When the one or more programs are executed by the processor, the electronic device executes the position recognition method based on two-dimensional laser radar feature point template matching as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions. When the computer instructions are executed on a processor of an electronic device, the device where the computer storage medium is located executes the position recognition method based on two-dimensional laser radar feature point template matching as described in any one of claims 1 to 6.
