A mapping direction correction method based on an optimized RANSAC algorithm and a mobile robot

CN122192283APending Publication Date: 2026-06-12SHEN ZHEN HAO CHENG ZHI NENG KE JI YOU XIAN GONG SI

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHEN ZHEN HAO CHENG ZHI NENG KE JI YOU XIAN GONG SI
Filing Date
2026-04-10
Publication Date
2026-06-12

Smart Images

  • Figure CN122192283A_ABST
    Figure CN122192283A_ABST
Patent Text Reader

Abstract

The application relates to a mapping direction correction method and a mobile robot. When a robot mapping process meets a staged preset trigger condition, initial mapping data and a reference main direction are obtained. Based on an optimized RANSAC algorithm, linear feature extraction is performed on the initial mapping data to obtain each first straight line and linear feature information of each corresponding first straight line. According to the linear feature information, the corresponding first straight line is subjected to dominant direction screening to obtain a target main direction. When the target main direction and the reference main direction meet a preset correction condition, angle processing is performed on the target main direction to obtain a correction angle. According to the correction angle, the direction of the corresponding initial mapping data is corrected to automatically and accurately correct the mapping direction of the robot, without manual operation of a user, to avoid insufficient linear feature extraction and misjudgment of the dominant direction, improve the comprehensiveness and accuracy of the linear feature, and improve the reliability and robustness of the map direction correction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of mobile robot technology, and in particular to a mapping orientation correction method based on an optimized RANSAC algorithm and a mobile robot. Background Technology

[0002] With the continuous development of robotics technology, mobile robots have been widely used in various fields such as service, warehousing, and cleaning. In map creation mode, mobile robots typically use features scanned for the first time (such as straight lines in the initial frame) as a reference to establish a local map coordinate system. However, when the robot's initial parking position is neither parallel nor perpendicular to the direction of the main wall of the indoor environment (such as east-west or north-south), the entire mapping process will unfold based on a tilted coordinate system, ultimately resulting in an overall skewed map.

[0003] Existing methods for calibrating map orientation in mobile robots typically include manual and automatic calibration. Manual calibration relies on the user manually rotating the map on the terminal, which is not only cumbersome but also difficult to control precisely, leading to a decrease in map quality. Automatic calibration, on the other hand, suffers from insufficient extraction of straight-line features and is prone to misjudging the dominant direction, affecting the reliability and robustness of map orientation calibration. Summary of the Invention

[0004] Based on this, in order to solve the problems existing in the map orientation calibration of mobile robots, a mapping orientation correction method and a mobile robot based on the optimized RANSAC algorithm are provided.

[0005] Firstly, this application provides a mapping orientation correction method based on an optimized RANSAC algorithm, comprising:

[0006] When the robot mapping process meets the preset triggering conditions in stages, the initial mapping data and reference main direction are obtained;

[0007] Based on the optimized RANSAC algorithm, straight line features are extracted from the initial mapping data to obtain the straight line feature information of each first straight line and each corresponding first straight line.

[0008] Based on the feature information of each line, the dominant direction of the extracted first line is filtered to obtain the target main direction;

[0009] When the target principal direction and the reference principal direction meet the preset correction conditions, the target principal direction is processed to obtain the correction angle.

[0010] Based on the correction angle, the orientation of the map corresponding to the initial mapping data is corrected.

[0011] In one embodiment, the step of acquiring initial mapping data and a reference main direction when the robot mapping process meets the pre-set phased triggering conditions includes:

[0012] When the robot's mapped area reaches a preset area threshold, initial mapping data and reference main direction are acquired.

[0013] Alternatively, when the robot completes mapping and returns to the charging base station, it can acquire initial mapping data and a reference main direction.

[0014] In one embodiment, the straight line feature information includes interior point information and direction angle information of the corresponding first straight line;

[0015] Based on the optimized RANSAC algorithm, the steps for extracting straight line features from the initial mapping data to obtain the straight line feature information of each first straight line and each corresponding first straight line include:

[0016] Based on a preset random sampling algorithm, the initial mapping data is iteratively sampled for detection points to obtain at least two sampling points.

[0017] Based on a preset distance threshold constraint, two target sampling points are selected from the sampling points in the current iteration, and a straight line is fitted to the two selected target sampling points to obtain the initial first straight line;

[0018] When the initial first line meets the preset line conditions, the corresponding initial first line is confirmed as a valid first line;

[0019] Based on the valid first straight line, obtain the interior point information and direction angle information of the corresponding valid first straight line.

[0020] In one embodiment, after the step of confirming the corresponding initial first line as a valid first line when the initial first line meets the preset line conditions, the method includes:

[0021] Obtain the proportion of interior points of each valid first straight line; and based on the proportion of each interior point, obtain the current optimal proportion of interior points.

[0022] Based on the preset iteration number algorithm, the current optimal in-point ratio is processed to obtain the current iteration number;

[0023] Before the step of iteratively sampling detection points on the initial mapping data based on a preset random sampling algorithm to obtain at least two sampling points, the following steps are included:

[0024] Based on the preset random sampling algorithm and the current iteration number, the initial mapping data is iteratively sampled for detection points to obtain at least two sampling points.

[0025] In one embodiment, the algorithm for the preset number of iterations is:

[0026] K = log(1-P) / log(1-w^n)

[0027] Where K is the current iteration number, P is the confidence level, n is the minimum number of sampling points, and w is the current optimal proportion of interior points.

[0028] In one embodiment, after obtaining the proportion of interior points of each valid first straight line, the method includes:

[0029] When the proportion of interior points on the corresponding valid first straight line exceeds a preset proportion threshold, the iterative sampling of detection points is terminated.

[0030] In one embodiment, after the step of performing line fitting on two selected target sampling points to obtain an initial first line, the method includes:

[0031] Select a first preset number of sampling points from the interior points of the initial first straight line, and mark the selected sampling points as used points; used points are used to indicate that the corresponding detection points in the initial mapping data are no longer used for iterative sampling;

[0032] When the number of points used exceeds the second preset number, the extraction of straight line features from the initial mapping data is terminated.

[0033] In one embodiment, the step of iteratively sampling the initial mapping data based on a preset random sampling algorithm to obtain at least two sampling points includes:

[0034] Based on the rand function, Mason rot algorithm, or preset distance constraint algorithm, the initial mapping data is iteratively sampled to obtain at least two sampling points; wherein the distance between any two sampling points is greater than or equal to the preset distance threshold.

[0035] In one embodiment, the step of confirming the corresponding initial first line as a valid first line when the initial first line meets the preset line conditions includes:

[0036] When the number of interior points of the initial first line is greater than a preset interior point threshold, the projection length of the initial first line is greater than a preset projection threshold, and the interior point density of the initial first line is greater than a preset density threshold, the corresponding initial first line is identified as a valid first line.

[0037] In one embodiment, the step of filtering the dominant direction of the extracted first straight line based on the feature information of each line to obtain the target main direction includes:

[0038] Based on the feature information of each line, the extracted first line is grouped by feature to obtain several line groups;

[0039] The interior point weights of each line group are processed to obtain the interior point weights of each line group. The line group with the largest interior point weight is determined as the dominant direction group.

[0040] Find the first straight line with the largest number of interior points in the dominant direction group, and determine the direction of the corresponding first straight line as the target main direction.

[0041] In one embodiment, the step of grouping the extracted first straight lines into several groups of straight lines based on the feature information of each line includes:

[0042] The difference in direction angles between any two first lines is obtained.

[0043] When the difference in the direction angle of the straight lines is less than a preset angle threshold or the difference between the difference in the direction angle of the straight lines and 90° is less than a preset angle threshold, the two corresponding first straight lines are grouped into the same straight line group.

[0044] When the difference in the direction angle of the straight lines is greater than a preset angle threshold and the difference between the difference in the direction angle of the straight lines and 90° is greater than a preset angle threshold, if the current number of straight line groups is less than a preset number of groups threshold, a new straight line group is created and the corresponding first straight line is added to the newly created straight line group. If the current number of straight line groups is greater than or equal to the preset number of groups threshold, the straight line group with the smallest number of interior points is selected from all straight line groups to obtain the straight line group to be compared. If the number of interior points of the corresponding first straight line is greater than the number of interior points of the straight line group to be compared, the corresponding first straight line replaces the first straight line of the straight line group to be compared.

[0045] In one embodiment, when the target principal direction and the reference principal direction meet a preset correction condition, the step of performing angle processing on the target principal direction to obtain a correction angle includes:

[0046] The angle difference between the target principal direction and the reference principal direction is processed to obtain the principal direction angle difference value;

[0047] When the difference in the main direction angle is greater than the preset angle threshold and the difference between the main direction angle difference and 90° is greater than the preset angle threshold, the target main direction is processed based on the preset angle correction algorithm to obtain the corrected angle.

[0048] In one embodiment, the step of acquiring initial mapping data and a reference main direction when the robot mapping process meets the pre-set phased triggering conditions includes:

[0049] When the robot mapping process meets the pre-set triggering conditions in stages, an independent calibration thread is invoked, and based on the independent calibration thread, the initial mapping data and reference main direction are obtained.

[0050] Secondly, this application also provides a mobile robot, including a robot body and a processing device; the processing device is disposed on the robot body, and the processing device is used to perform the steps of the mapping orientation correction method based on the optimized RANSAC algorithm described above.

[0051] One of the above technical solutions has the following advantages and beneficial effects:

[0052] In the above-described mapping direction correction method, when the robot mapping process meets the preset triggering conditions in stages, initial mapping data and a reference main direction are acquired; based on the optimized RANSAC algorithm, straight line features are extracted from the initial mapping data to obtain the straight line feature information of each first straight line and each corresponding first straight line; according to the straight line feature information, the extracted corresponding first straight lines are filtered for dominant directions to obtain the target main direction; when the target main direction and the reference main direction meet the preset correction conditions, the target main direction is processed by angle to obtain the correction angle; according to the correction angle, the map corresponding to the initial mapping data is oriented to achieve automatic and accurate robot mapping direction correction. This application determines whether the robot's mapping process meets the triggering conditions. If the triggering conditions are met, it triggers mapping direction correction without requiring manual user operation. By employing an improved and optimized RANSAC algorithm for straight line feature extraction and filtering the dominant direction of the first straight line, it avoids insufficient straight line feature extraction and easy misjudgment of the dominant direction, thus improving the comprehensiveness and accuracy of straight line features. By processing the angle of the dominant direction to correct the mapping direction, it avoids mapping skew caused by the inconsistency between the initial environment's dominant direction and the overall map's dominant direction, thus improving the reliability and robustness of map direction correction. Attached Figure Description

[0053] Figure 1 This is a schematic diagram of the application environment of the mapping direction correction method based on the optimized RANSAC algorithm in the embodiments of this application;

[0054] Figure 2 This is a flowchart illustrating the mapping direction correction method based on the optimized RANSAC algorithm in an embodiment of this application.

[0055] Figure 3 This is a flowchart illustrating the line feature extraction step in an embodiment of this application;

[0056] Figure 4 This is a flowchart illustrating the target main direction processing steps in the embodiments of this application;

[0057] Figure 5 This is a flowchart illustrating the linear grouping step in an embodiment of this application;

[0058] Figure 6This is a flowchart illustrating the correction angle calculation steps in an embodiment of this application. Detailed Implementation

[0059] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0060] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0061] In addition, the term "multiple" should mean two or more.

[0062] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0063] The mapping orientation correction method based on the optimized RANSAC algorithm provided in this application can be applied to, for example... Figure 1The application environment shown is illustrated. The mobile robot includes a robot body 20 and a processing device 10. The processing device 10 is mounted on the robot body 20, which is equipped with a moving mechanism (such as rollers or tracks) to drive the robot body 20. The processing device 10 includes a processor 102 and a memory 104. The processor 102 is connected to the memory 104, which stores initial mapping data, reference main direction, first straight lines, straight line feature information, target main direction, and correction angle. The processor 102 is used to acquire the initial mapping data and reference main direction when the robot mapping process meets the preset trigger conditions in stages; based on the optimized RANSAC algorithm, it extracts straight line features from the initial mapping data to obtain the straight line feature information of each first straight line and each corresponding first straight line; based on the straight line feature information, it filters the extracted first straight lines for the main direction to obtain the target main direction; when the target main direction and the reference main direction meet the preset correction conditions, it performs angle processing on the target main direction to obtain the correction angle; and based on the correction angle, it performs direction correction on the map corresponding to the initial mapping data. For example, mobile robots can be, but are not limited to, service robots, warehousing and logistics robots, and cleaning robots. For instance, a mobile robot could be a robotic vacuum cleaner equipped with a laser module, which is used to create a map using laser scanning in a new mapping mode.

[0064] In one embodiment, such as Figure 2 As shown, a mapping orientation correction method based on an optimized RANSAC algorithm is also provided, which is applied to... Figure 1 Taking the aforementioned processor as an example, the process includes the following steps:

[0065] Step S210: When the robot mapping process meets the pre-set triggering conditions for each stage, obtain the initial mapping data and the reference main direction.

[0066] For example, when a mobile robot is used for the first time, it will map the current environment; alternatively, a user can manually control the mobile robot to perform mapping. Phased preset trigger conditions can be set according to the mapping progress; for example, phased preset trigger conditions can be set to 20%, 50%, or 100% of the mapping process. The initial mapping data can be the point cloud data scanned during the mobile robot's mapping process. The reference principal direction is the direction of the straight line in the initial frame scanned by the mobile robot for the first time.

[0067] For example, when the robot starts mapping, the mapping process is monitored in real time. When the mapping process meets the preset trigger conditions in stages, the mapping direction correction of the robot is triggered, thereby obtaining the initial mapping data and reference main direction obtained during the mapping process of the mobile robot.

[0068] Step S220: Based on the optimized RANSAC algorithm, perform line feature extraction on the initial mapping data to obtain the line feature information of each first line and each corresponding first line.

[0069] The optimized RANSAC algorithm can be obtained by improving the RANdom Sampling Consensus (RANSAC) algorithm.

[0070] For example, based on the optimized RANSAC algorithm, the initial mapping data is randomly sampled to obtain corresponding sampling points. These sampling points are then fitted to obtain a first straight line. Feature extraction is then performed on this first straight line to obtain its linear feature information. It should be noted that the linear feature information may include the number of interior points and the orientation angle of the corresponding first straight line.

[0071] Step S230: Based on the feature information of each line, the dominant direction of the extracted first line is filtered to obtain the target main direction.

[0072] Here, the target main direction refers to the actual main direction of the mobile robot's mapping. Based on the feature information of each straight line, each first straight line is filtered, and based on the filtering results, the direction of the filtered first straight line is determined as the target main direction.

[0073] Step S240: When the target principal direction and the reference principal direction meet the preset correction conditions, the target principal direction is processed to obtain the correction angle.

[0074] For example, the target main direction is compared with the reference main direction, and when the processing result meets the preset correction conditions, it is determined that the map is skewed, and then the target main direction is processed to obtain the correction angle.

[0075] Step S250: According to the correction angle, perform orientation correction on the map corresponding to the initial mapping data.

[0076] For example, based on the calculated correction angle, the orientation of the map built by the mobile robot can be corrected, such as by performing rotation changes on the already built map to avoid the generated map being skewed, thus achieving automatic correction of the mapping orientation of the mobile robot.

[0077] In the above embodiments, when the robot mapping process meets the preset triggering conditions in stages, initial mapping data and a reference main direction are acquired; based on the optimized RANSAC algorithm, straight line features are extracted from the initial mapping data to obtain the straight line feature information of each first straight line and each corresponding first straight line; according to the straight line feature information, the extracted corresponding first straight lines are filtered for the main direction to obtain the target main direction; when the target main direction and the reference main direction meet the preset correction conditions, the target main direction is processed by angle to obtain the correction angle; according to the correction angle, the map of the corresponding initial mapping data is oriented to achieve automatic and accurate orientation correction of the robot mapping. This application determines whether the robot's mapping process meets the triggering conditions. If the triggering conditions are met, it triggers mapping direction correction without requiring manual user operation. By employing an improved and optimized RANSAC algorithm for straight line feature extraction and filtering the dominant direction of the first straight line, it avoids insufficient straight line feature extraction and easy misjudgment of the dominant direction, thus improving the comprehensiveness and accuracy of straight line features. By processing the angle of the dominant direction to correct the mapping direction, it avoids mapping skew caused by the inconsistency between the initial environment's dominant direction and the overall map's dominant direction, thus improving the reliability and robustness of map direction correction.

[0078] In one embodiment, the step of acquiring initial mapping data and a reference main direction when the robot mapping process meets the pre-set phased triggering conditions includes:

[0079] When the robot's mapped area reaches a preset area threshold, initial mapping data and reference main direction are acquired; or, when the robot completes mapping and returns to the charging base station, initial mapping data and reference main direction are acquired.

[0080] For example, the phased preset trigger conditions may include two preset correction trigger nodes. For instance, when the robot begins mapping and explores to a preset area threshold (e.g., 20 square meters), it is determined that the robot's mapping process meets the phased preset trigger conditions, i.e., the mobile robot triggers correction for the first time. At this stage, the map already contains environmental structural features of a certain scale, but it is not yet finalized, which facilitates early correction. When the robot completes mapping and returns to the charging base station, it is determined that the robot's mapping process meets the phased preset trigger conditions, i.e., the mobile robot triggers correction for the second time. At this stage, the map is globally complete, and the final and most reliable correction can be performed based on the most comprehensive environmental information.

[0081] In the above embodiments, by actively triggering corrections at key nodes in the robot mapping process, a phased triggering mechanism is implemented to ensure the timing of corrections, preventing the generation of skewed maps from the source, without requiring manual operation by the user. In addition, the timing of corrections is determined by the external main process based on the mapping progress (such as the mapped area and refill events), making corrections loosely coupled with the mapping process and highly flexible.

[0082] In one embodiment, such as Figure 3 As shown, the steps for extracting line features from the initial mapping data based on the optimized RANSAC algorithm to obtain the line feature information of each first line and each corresponding first line include:

[0083] Step S310: Based on a preset random sampling algorithm, iterative sampling of detection points is performed on the initial mapping data to obtain at least two sampling points.

[0084] The straight line feature information includes the interior point information and direction angle information of the corresponding first straight line; the interior point information includes the number of interior points of the corresponding first straight line, and the direction angle information includes the direction angle value of the corresponding first straight line.

[0085] For example, the initial mapping data includes multiple detection points. Based on a preset random sampling algorithm, each detection point in the initial mapping data is iteratively sampled to obtain at least two sampling points, thereby realizing random sampling of the sampling points.

[0086] In one example, the preset random sampling algorithm includes the rand function, the Mason rot algorithm, or a preset distance constraint algorithm. Step S310 includes: iteratively sampling detection points on the initial mapping data based on the rand function, the Mason rot algorithm, or the preset distance constraint algorithm to obtain at least two sampling points; wherein the distance between any two sampling points is greater than or equal to a preset distance threshold.

[0087] For example, random sampling can be performed using the standard library's `rand` function, requiring a minimum distance between two sampling points to be a preset distance threshold (e.g., 0.1 meters) to prevent points from being too close together and causing unstable line fitting. Another example is using the C++11 `std::mt19937` Mason tween algorithm to iteratively sample detection points on the initial mapping data, providing a higher quality random distribution, also requiring a minimum distance between points within a preset threshold (e.g., 0.1 meters). Yet another example is using a preset distance constraint algorithm to select a second sampling point within a fixed distance range (0.15 meters to 0.25 meters), ensuring that the sampling points have sufficient spacing for stable fitting without being too far apart and crossing different wall structures. It should be noted that when no suitable point is found within the specified range, the condition can be relaxed to a range of 0.1-0.3 meters to continue trying. In the above examples, by providing three configurable sampling strategies, flexible selection can be made according to different hardware platforms and performance requirements, enhancing the adaptability and practicality of the algorithm.

[0088] Step S320: Based on the preset distance threshold constraint, select two target sampling points from each sampling point in the current iteration, and perform line fitting on the selected two target sampling points to obtain the initial first line.

[0089] For example, when randomly selecting two sampling points for line fitting in each iteration, the distance between the two sampling points is required to be greater than a preset distance threshold (such as 0.1 meters). This avoids the problem of unstable line fitting and sensitivity to noise caused by selecting points that are too close, and improves the robustness of line extraction.

[0090] Step S330: When the initial first line meets the preset line conditions, the corresponding initial first line is confirmed as a valid first line.

[0091] By filtering the initial first line according to conditions, the corresponding initial first line is confirmed as a valid first line when it meets the preset line conditions, thereby improving the accuracy of line detection.

[0092] Step S340: Based on the valid first straight line, obtain the interior point information and direction angle information of the corresponding valid first straight line.

[0093] By statistically analyzing the interior points of the valid first line, the interior point information of the corresponding valid first line is obtained; by calculating the direction angle of the valid first line, the direction angle information of the corresponding valid first line is obtained, thus avoiding insufficient line feature extraction and improving the comprehensiveness and accuracy of line feature extraction.

[0094] In one embodiment, after the step of confirming the corresponding initial first line as a valid first line when the initial first line meets the preset line conditions, the method includes:

[0095] Obtain the proportion of interior points of each valid first straight line; and based on the proportion of each interior point, obtain the current optimal proportion of interior points; based on the preset iteration number algorithm, process the current optimal proportion of interior points to obtain the current iteration number;

[0096] In one example, the preset iteration number algorithm is: K=log(1-P) / log(1-w^n).

[0097] Where K is the current iteration number, P is the confidence level, n is the minimum number of sampling points, and w is the current optimal proportion of interior points.

[0098] For example, if the minimum number of sampling points required to fit a straight line is n=2 and the confidence level is P=0.99, then the new current iteration number K is calculated using the formula K=log(1-0.99) / log(1-w^2).

[0099] By calculating the proportion of interior points for each valid first straight line and comparing these proportions, the proportion with the largest value is selected as the current optimal proportion. This optimal proportion is then input into an algorithm with a preset iteration count to obtain the current iteration count. It should be noted that the interior point proportion refers to the percentage of data points that conform to the valid first straight line out of the total number of data points.

[0100] In the above embodiments, by obtaining the optimal proportion of interior points that have found the corresponding valid first straight line, the maximum number of iterations required is dynamically calculated, thereby significantly improving computational efficiency while ensuring the reliability of the algorithm.

[0101] In one example, before the step of iteratively sampling detection points on the initial mapping data based on a preset random sampling algorithm to obtain at least two sampling points, the following steps are included:

[0102] Based on the preset random sampling algorithm and the current iteration number, the initial mapping data is iteratively sampled for detection points to obtain at least two sampling points.

[0103] For example, based on a preset random sampling algorithm, each detection point of the initial mapping data is iteratively sampled to obtain at least two sampling points until the number of iterations reaches the calculated current iteration number, thereby realizing random sampling of sampling points based on the current iteration number.

[0104] In one example, a random seed is generated by combining multiple entropy sources (such as system time, process ID, and CPU clock) to ensure that the randomness distribution is different for each run. By diversifying the random seeds, the robustness of the mapping direction correction is improved.

[0105] In one embodiment, after obtaining the proportion of interior points of each valid first straight line, the method includes:

[0106] When the proportion of interior points on the corresponding valid first straight line exceeds a preset proportion threshold, the iterative sampling of detection points is terminated.

[0107] The preset ratio threshold can be obtained from system settings, for example, the preset ratio threshold can be set to 80%. When the ratio of the interior points of the corresponding valid first straight line exceeds the preset ratio threshold, the iterative sampling is terminated in advance. Since a high-quality straight line has been found at this time, the benefit of continuing the iteration is limited, which can further improve the efficiency of mapping direction correction.

[0108] In one embodiment, after the step of performing line fitting on two selected target sampling points to obtain an initial first line, the method includes:

[0109] Select a first preset number of sampling points from the interior points of the initial first straight line and mark the selected sampling points as used points; used points are used to indicate that the corresponding detection points in the initial mapping data are no longer used for iterative sampling; when the number of used points exceeds a second preset number, terminate the straight line feature extraction of the initial mapping data.

[0110] The first preset quantity can be obtained according to the system preset, for example, the first preset quantity can be set to 1, 2 or 3. The second preset quantity can be obtained according to the system preset, for example, the second preset quantity can be set to two-thirds of the number of used points.

[0111] For example, after successfully fitting an initial first straight line each time, a first preset number of sampling points are randomly selected from the interior points of the initial first straight line, and the selected sampling points are marked as used points. In subsequent iterations, these points marked as used are no longer eligible to be selected as sampling points for line fitting. Each iteration is based on the currently available set of points (excluding used points). By forcibly exploring areas in the initial mapping data that have not yet been fully sampled, the algorithm effectively avoids repeatedly detecting the same long wall segment, prompting the discovery of other wall lines in the environment that may be shorter.

[0112] By counting the number of points used, the line extraction process is terminated in advance when the number of points used exceeds the second preset number. This ensures that the algorithm can stop in time after extracting enough lines, avoiding over-computation and improving computational efficiency while maintaining algorithm accuracy.

[0113] In one embodiment, the step of confirming the corresponding initial first line as a valid first line when the initial first line meets the preset line conditions includes:

[0114] When the number of interior points of the initial first line is greater than a preset interior point threshold, the projection length of the initial first line is greater than a preset projection threshold, and the interior point density of the initial first line is greater than a preset density threshold, the corresponding initial first line is identified as a valid first line.

[0115] The preset interior point threshold can be set to 7, the preset projection threshold to 0.25 meters, and the preset density threshold to 8 interior points per meter. For example, when evaluating the initial first straight line, multiple quality indicators are used to obtain the number of interior points, the projected length, and the interior point density of the initial first straight line. The number of interior points of the initial first straight line is compared with the preset interior point threshold. If the number of interior points of the initial first straight line is greater than the preset interior point threshold, the number of interior points of the initial first straight line is deemed acceptable. Then, the projected length of the initial first straight line is compared with the preset projection threshold. If the projected length of the initial first straight line is greater than the preset projection threshold, the projected length of the initial first straight line is deemed acceptable. Then, the interior point density of the initial first straight line is compared with the preset density threshold. If the interior point density of the initial first straight line is greater than the preset density threshold, the continuity of the initial first straight line is deemed acceptable. Thus, the corresponding initial first straight line is confirmed as a valid first straight line, improving the reliability of straight line detection. It should be noted that a preset interior point threshold of 7 interior points corresponds to a short wall structure of 35 centimeters. The projected length refers to the projected length of the initial first straight line in its own direction.

[0116] In the above embodiments, the quality of a straight line is comprehensively evaluated by multiple indicators such as the number of interior points, the projection length, and the density of interior points, which effectively filters out noise, short segments, and sparse point clouds, thereby improving the comprehensiveness and accuracy of the straight line features.

[0117] In one embodiment, such as Figure 4 As shown, the steps for filtering the dominant direction of the extracted first straight line based on the feature information of each line to obtain the target dominant direction include:

[0118] Step S410: Based on the feature information of each line, the extracted first line is grouped by feature to obtain several line groups.

[0119] For example, based on the number of interior points and the direction angle of the first straight line, the existing first straight line can be grouped by feature to obtain several straight line groups.

[0120] Step S420: Perform interior point weighting on each line group to obtain the interior point weights of each line group, and determine the line group with the largest interior point weight as the dominant direction group.

[0121] For example, count the number of interior points in each line group, assign weights to each line component based on the number of interior points, obtain the interior point weights of each line group, and determine the line group with the largest interior point weight as the dominant direction group.

[0122] Step S430: Obtain the first straight line with the largest number of interior points in the dominant direction group, and determine the direction of the corresponding first straight line as the target main direction.

[0123] For example, select the first straight line with the largest number of interior points in the dominant direction group, and determine the actual dominant direction of the current environment based on the direction angle of the first straight line.

[0124] In the above embodiments, by grouping the first straight line and filtering the dominant direction of the grouped straight line groups, the accuracy and reliability of the actual main direction extraction are improved, thereby improving the reliability and robustness of map direction correction.

[0125] In one embodiment, such as Figure 5 As shown, the steps of grouping the extracted first straight lines into several groups based on their feature information include:

[0126] Step S510: Obtain the difference in the direction angles of any two first lines.

[0127] For example, obtain any two first lines, perform difference processing on the direction angles of the corresponding two first lines, and then obtain the difference in the direction angles of the lines.

[0128] Step S520: When the difference in the direction angle of the straight line is less than the preset angle threshold or the difference between the difference in the direction angle of the straight line and 90° is less than the preset angle threshold, the two corresponding first straight lines are grouped into the same straight line group.

[0129] For example, when the difference in the direction angle of the lines is less than a preset angle threshold, the two corresponding first lines are determined to be parallel, and then the two corresponding first lines are grouped into the same line group; when the difference between the difference in the direction angle of the lines and 90° is less than a preset angle threshold, the two corresponding first lines are determined to be perpendicular, and then the two corresponding first lines are grouped into the same line group.

[0130] Step S530: When the difference in the direction angle of the straight lines is greater than a preset angle threshold and the difference between the difference in the direction angle of the straight lines and 90° is greater than a preset angle threshold, if the current number of straight line groups is less than a preset number of groups threshold, a new straight line group is created and the corresponding first straight line is added to the newly created straight line group. If the current number of straight line groups is greater than or equal to the preset number of groups threshold, the straight line group with the smallest number of interior points is selected from each straight line group to obtain the straight line group to be compared. If the number of interior points of the corresponding first straight line is greater than the number of interior points of the straight line group to be compared, the corresponding first straight line replaces the first straight line of the straight line group to be compared.

[0131] For example, all extracted first lines are grouped using a uniform and fault-tolerant angle judgment rule. For instance, a preset angle threshold ε (e.g., 5°) is set. For any two first lines, the minimum difference Δθ between their direction angles is calculated. If Δθ < ε, they are considered parallel and grouped together; if |Δθ - 90°| < ε, they are considered perpendicular and also grouped together. If a line does not match any of the line groups, and if the current group number is less than 10, a new group is created; if the group number has reached 10, the group with the fewest interior points is found. If the current line has more interior points than the group with interior points, that line group is replaced. After all groups are completed, they are sorted in descending order by the total number of interior points within each group.

[0132] In the above embodiments, the parallelism and perpendicularity of the two first lines are defined by using the same angle tolerance preset angle threshold. This determination method runs through the entire process of grouping, decision-making and visualization, ensuring the self-consistency of the algorithm logic.

[0133] In one embodiment, such as Figure 6 As shown, when the target principal direction and the reference principal direction meet the preset correction conditions, the step of performing angle processing on the target principal direction to obtain the correction angle includes:

[0134] Step S610: Perform angle difference processing on the target principal direction and the reference principal direction to obtain the principal direction angle difference value.

[0135] By obtaining the direction angle of the target main direction and the direction angle of the reference main direction, and then performing angle difference processing on the direction angle of the target main direction and the direction angle of the reference main direction, the angle difference value of the main direction is obtained.

[0136] Step S620: When the difference in the main direction angle is greater than the preset angle threshold and the difference between the main direction angle difference and 90° is greater than the preset angle threshold, the target main direction is processed based on the preset angle correction algorithm to obtain the corrected angle.

[0137] For example, when the difference in the principal direction angles is greater than a preset angle threshold, it is determined that the target principal direction and the reference principal direction are not parallel; when the difference between the principal direction angle difference and 90° is greater than a preset angle threshold, it is determined that the target principal direction and the reference principal direction are not perpendicular. Furthermore, when the difference in the principal direction angles does not meet either the parallelism condition or the perpendicularity condition, it is determined that the map constructed by the robot is skewed and the mapping direction needs to be corrected. For example, if the direction angle of the target principal direction is set to α and the correction angle is δ, then the correction angle δ = α_norm is calculated. It should be noted that α_norm is the value after normalizing α to [-45°, 45°].

[0138] In the above embodiments, by setting the correction trigger conditions, it is required that the newly detected target main direction is neither parallel nor perpendicular to the reference main direction, which effectively prevents the map that has been correctly rotated by 90° from being misjudged as skewed, and improves the reliability and robustness of map orientation correction.

[0139] In one embodiment, the step of acquiring initial mapping data and a reference main direction when the robot mapping process meets the pre-set phased triggering conditions includes:

[0140] When the robot mapping process meets the pre-set triggering conditions in stages, an independent calibration thread is invoked, and based on the independent calibration thread, the initial mapping data and reference main direction are obtained.

[0141] For example, an asynchronous threaded architecture for phased calibration can be pre-established, providing a calibration interface for the main mapping process to call at specific stages. The mesh data to be calibrated is submitted to the calibration system, and the calibration interface returns immediately without blocking. An independent calibration thread is created and runs continuously in the background, waiting for new calibration tasks via condition variables. A status flag is used to ensure that only one calibration task is executed at a time, and no new calibration tasks are accepted after calibration is completed (unless a reset interface is called to reset the flag status). Furthermore, the calibration results can be queried multiple times without redundant calculations. For instance, calibration results (such as whether calibration is needed, calibration angle, target principal direction, etc.) can be stored and queried by the main process through an interface for obtaining calibration results. The main process then determines whether to perform a rotation transformation on the constructed map based on these results.

[0142] In the above embodiments, when the robot mapping process meets the preset triggering conditions in stages, an independent correction thread is called to perform correction processing, so that the correction calculation is executed in an independent thread without blocking the main mapping process, thus ensuring the real-time nature of mapping.

[0143] It should be understood that, although Figures 2 to 6 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figures 2 to 6 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0144] In one embodiment, a mapping orientation correction device based on an optimized RANSAC algorithm is provided, comprising:

[0145] The calibration triggering unit is used to acquire initial mapping data and reference main direction when the robot mapping process meets the preset triggering conditions in stages.

[0146] The feature extraction unit is used to extract straight line features from the initial mapping data based on the optimized RANSAC algorithm, so as to obtain the straight line feature information of each first straight line and each corresponding first straight line.

[0147] The main direction filtering unit is used to filter the main direction of the extracted first line according to the feature information of each line to obtain the target main direction.

[0148] The correction angle calculation unit is used to process the angle of the target principal direction to obtain the correction angle when the target principal direction and the reference principal direction meet the preset correction conditions.

[0149] The correction unit is used to correct the orientation of the map corresponding to the initial mapping data according to the correction angle.

[0150] Specific limitations regarding the mapping orientation correction device based on the optimized RANSAC algorithm can be found in the limitations of the mapping orientation correction method based on the optimized RANSAC algorithm above, and will not be repeated here. Each module in the aforementioned mapping orientation correction device based on the optimized RANSAC algorithm can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the mobile robot in hardware form or independent of it, or stored in the memory of the mobile robot in software form, so that the processor can call and execute the corresponding operations of each module.

[0151] In one embodiment, this application also provides a mobile robot, including a robot body and a processing device; the processing device is disposed on the robot body, and the processing device is used to perform the steps of the mapping orientation correction method based on the optimized RANSAC algorithm described above.

[0152] For detailed descriptions of the robot body and processing equipment, please refer to the descriptions in the above embodiments; they will not be repeated here.

[0153] When the robot mapping process meets the preset triggering conditions in stages, the processing device acquires initial mapping data and a reference main direction. Based on the optimized RANSAC algorithm, it extracts straight line features from the initial mapping data to obtain the straight line feature information of each first straight line and its corresponding first straight line. According to the straight line feature information, it filters the main directions of the extracted first straight lines to obtain the target main direction. When the target main direction and the reference main direction meet the preset correction conditions, it performs angle processing on the target main direction to obtain the correction angle. According to the correction angle, it performs orientation correction on the map corresponding to the initial mapping data, thereby achieving automatic and accurate orientation correction for robot mapping.

[0154] In the above embodiments, the processing device determines whether the robot's mapping process meets the triggering conditions. If the triggering conditions are met, it triggers mapping direction correction without requiring manual operation by the user. By employing an improved optimized RANSAC algorithm for straight line feature extraction and filtering the dominant direction of the first straight line, it avoids insufficient straight line feature extraction and easy misjudgment of the dominant direction, thereby improving the comprehensiveness and accuracy of straight line features. By processing the angle of the dominant direction to correct the mapping direction, it avoids mapping skew caused by the inconsistency between the initial environment's dominant direction and the overall map's dominant direction, thereby improving the reliability and robustness of map direction correction.

[0155] In one embodiment, a computer storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the mapping orientation correction method based on the optimized RANSAC algorithm described above.

[0156] For example, when a computer program is executed by a processor, it performs the following steps:

[0157] When the robot mapping process meets the preset triggering conditions in stages, initial mapping data and reference main direction are acquired. Based on the optimized RANSAC algorithm, straight line features are extracted from the initial mapping data to obtain the straight line feature information of each first straight line and each corresponding first straight line. According to the straight line feature information, the extracted first straight lines are filtered for dominant directions to obtain the target main direction. When the target main direction and the reference main direction meet the preset correction conditions, the target main direction is processed to obtain the correction angle. According to the correction angle, the map of the corresponding initial mapping data is oriented to achieve automatic and accurate orientation correction of the robot mapping.

[0158] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the division operations described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), direct memory bus RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0159] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0160] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A mapping orientation correction method based on an optimized RANSAC algorithm, characterized in that, include: When the robot mapping process meets the preset triggering conditions in stages, the initial mapping data and reference main direction are obtained; Based on the optimized RANSAC algorithm, straight line features are extracted from the initial mapping data to obtain the straight line feature information of each first straight line and each corresponding first straight line. Based on the feature information of each line, the dominant direction of the extracted first line is filtered to obtain the target main direction; When the target principal direction and the reference principal direction meet the preset correction conditions, the target principal direction is processed to obtain the correction angle. Based on the correction angle, the map corresponding to the initial mapping data is oriented and corrected.

2. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 1, characterized in that, The step of acquiring initial mapping data and reference main direction when the robot mapping process meets the preset triggering conditions in stages includes: When the robot's mapped area reaches a preset area threshold, the initial mapping data and the reference main direction are acquired. Alternatively, when the robot completes mapping and returns to the charging base station, the initial mapping data and the reference main direction can be acquired.

3. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 1, characterized in that, The straight line feature information includes the interior point information and direction angle information of the corresponding first straight line; The step of extracting straight line features from the initial mapping data based on the optimized RANSAC algorithm to obtain the straight line features of each first straight line and the corresponding straight line feature information includes: Based on a preset random sampling algorithm, the initial mapping data is iteratively sampled for detection points to obtain at least two sampling points. Based on a preset distance threshold constraint, two target sampling points are selected from the sampling points in the current iteration, and a straight line is fitted to the two selected target sampling points to obtain an initial first straight line; When the initial first straight line meets the preset straight line conditions, the corresponding initial first straight line is confirmed as a valid first straight line; Based on the effective first straight line, the interior point information and direction angle information corresponding to the effective first straight line are obtained.

4. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 3, characterized in that, After the step of confirming the corresponding initial first straight line as a valid first straight line when the initial first straight line satisfies the preset straight line condition, the method includes: Obtain the proportion of interior points of each of the effective first straight lines; and based on the proportion of each interior point, obtain the current optimal proportion of interior points. Based on the preset iteration number algorithm, the current optimal in-point ratio is processed to obtain the current iteration number; Before the step of iteratively sampling the initial mapping data based on a preset random sampling algorithm to obtain at least two sampling points, the following steps are included: Based on a preset random sampling algorithm and the current iteration number, the initial mapping data is iteratively sampled for detection points to obtain at least two sampling points.

5. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 4, characterized in that, The algorithm for the preset number of iterations is as follows: K = log(1-P) / log(1-w^n) Where K is the current iteration number, P is the confidence level, n is the minimum number of sampling points, and w is the current optimal proportion of interior points.

6. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 4, characterized in that, After the step of obtaining the proportion of interior points of each of the effective first straight lines, the following steps are included: When the proportion of interior points on the corresponding valid first straight line exceeds a preset proportion threshold, the iterative sampling of detection points is terminated.

7. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 3, characterized in that, After the step of performing linear fitting on the two selected target sampling points to obtain the initial first straight line, the following steps are included: A first preset number of sampling points are selected from the interior points of the initial first straight line, and the selected sampling points are marked as used points; the used points are used to indicate that the corresponding detection points in the initial mapping data are no longer used for iterative sampling; When the number of used points exceeds a second preset number, the extraction of straight line features from the initial mapping data is terminated.

8. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 3, characterized in that, The step of iteratively sampling the initial mapping data based on a preset random sampling algorithm to obtain at least two sampling points includes: Based on the rand function, Mason rot algorithm, or preset distance constraint algorithm, the initial mapping data is iteratively sampled to obtain at least two sampling points; wherein the distance between any two sampling points is greater than or equal to a preset distance threshold.

9. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 3, characterized in that, The step of confirming the initial first straight line as a valid first straight line when the initial first straight line meets the preset straight line conditions includes: When the number of interior points of the initial first straight line is greater than a preset interior point threshold, the projection length of the initial first straight line is greater than a preset projection threshold, and the interior point density of the initial first straight line is greater than a preset density threshold, the corresponding initial first straight line is confirmed as a valid first straight line.

10. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 1, characterized in that, The step of filtering the dominant direction of the extracted first straight line based on the feature information of each straight line to obtain the target dominant direction includes: Based on the feature information of each line, the extracted first line is grouped by feature to obtain several line groups; The interior point weights of each line group are processed to obtain the interior point weights of each line group, and the line group with the largest interior point weight is determined as the dominant direction group. Obtain the first straight line with the largest number of interior points in the dominant direction group, and determine the direction of the corresponding first straight line as the target main direction.

11. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 10, characterized in that, The step of grouping the extracted first straight lines into several groups based on their feature information includes: The difference in direction angles between any two first lines is obtained. When the difference in the direction angle of the lines is less than a preset angle threshold or the difference between the difference in the direction angle of the lines and 90° is less than a preset angle threshold, the two corresponding first lines are grouped into the same line group. When the difference in the direction angle of the lines is greater than a preset angle threshold and the difference between the difference in the direction angle of the lines and 90° is greater than a preset angle threshold, if the current number of lines in the line group is less than a preset number of groups threshold, a new line group is created and the corresponding first line is added to the newly created line group. If the current number of lines in the line group is greater than or equal to the preset number of groups threshold, the line group with the smallest number of interior points is selected from all line groups to obtain the line group to be compared. If the number of interior points of the corresponding first line is greater than the number of interior points of the line group to be compared, the corresponding first line replaces the first line of the line group to be compared.

12. The mapping direction correction method based on the optimized RANSAC algorithm according to claim 1, characterized in that, The step of performing angle processing on the target principal direction to obtain a correction angle when the target principal direction and the reference principal direction satisfy a preset correction condition includes: The angle difference between the target principal direction and the reference principal direction is processed to obtain the principal direction angle difference value; When the difference in the main direction angle is greater than a preset angle threshold and the difference between the main direction angle difference and 90° is greater than a preset angle threshold, the target main direction is processed based on a preset angle correction algorithm to obtain the corrected angle.

13. The mapping orientation correction method based on the optimized RANSAC algorithm according to any one of claims 1 to 12, characterized in that, The step of acquiring initial mapping data and reference main direction when the robot mapping process meets the preset triggering conditions in stages includes: When the robot mapping process meets the preset triggering conditions in stages, an independent calibration thread is invoked, and based on the independent calibration thread, the initial mapping data and the reference main direction are obtained.

14. A mobile robot, characterized in that, It includes a robot body and a processing device; the processing device is disposed on the robot body and is used to perform the steps of the mapping orientation correction method based on the optimized RANSAC algorithm as described in any one of claims 1 to 13.