Indoor map construction method and device, robot and computer readable storage medium
By adopting the three main direction detection and rotation mechanism in the cleaning robot, the problem of map tilt and jagging when the cleaning robot is constructed is solved, and the accuracy and aesthetics of the global map are improved.
Patent Information
- Application Number
- CN202411162370.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-11-12
AI Technical Summary
When the cleaning robot builds a map indoors, due to the uncertain starting position or orientation, the built global map is tilted and jagged, which affects the aesthetics. The existing main direction detection method is not effective in complex environments.
The three-time main direction detection mechanism is adopted to rotate and convert the initial, updated and global point cloud data to ensure the accuracy of the main direction of the map and reduce jagged phenomena and tilts.
Improves the accuracy of the main direction of the global map, avoids the tilt and jagged shape of the map, and improves the aesthetics and user experience of the map.
Smart Images

Figure CN118936456A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an indoor map construction method, device, robot and computer-readable storage medium. Background Art
[0002] For example, when a cleaning robot moves and builds a map indoors, it will build a map of the surrounding environment in real time based on the surrounding environment detected by the laser radar, thereby facilitating map-based cleaning path planning for the indoor environment. However, since the angle of the cleaning robot when it starts to build a map is usually uncertain, for example, the user may place it randomly, so that its starting position or orientation will form a certain angle with the wall, which makes the straight wall appear as a diagonal line in the constructed map of a certain resolution. The user can see with the naked eye that these diagonal lines are jagged, and the entire map is tilted, especially in some home scenes where the walls are horizontal and vertical. Since the map often needs to be presented to the user through an interface, this has a great impact on the aesthetics of the map. By rotating the main direction, the map jaggedness can be greatly reduced, and the map will not be tilted. The current practice is to perform a main direction detection when the machine is turned on. However, due to the complexity and unpredictability of the actual operating environment, the above approach often does not achieve good results. Summary of the invention
[0003] In view of this, the embodiments of the present application provide an indoor map construction method, device, robot and computer-readable storage medium, which can effectively solve the problem of tilted display of the main direction of the global map in the prior art.
[0004] In a first aspect, an embodiment of the present application provides a method for constructing an indoor map, comprising:
[0005] After the robot starts the mapping mode, it obtains the initial point cloud data of the starting position;
[0006] Extracting a first main direction for constructing an indoor global map from the initial point cloud data;
[0007] After rotating the initial point cloud data according to the first main direction, controlling the robot to travel a preset distance to obtain updated point cloud data of the adjusted position;
[0008] Extracting a second main direction from the updated point cloud data;
[0009] When the first main direction is different from the second main direction, after rotating the acquired point cloud data according to the second main direction, controlling the robot to continue moving and mapping until the indoor global point cloud data is acquired;
[0010] Extracting a third main direction from the global point cloud data;
[0011] When the second main direction is different from the third main direction, point cloud rotation and map conversion are performed on the global point cloud data according to the third main direction to obtain an indoor global map.
[0012] In a second aspect, an embodiment of the present application provides an indoor map construction device, comprising:
[0013] The data acquisition module is used to obtain the initial point cloud data of the starting position after the robot starts the mapping mode;
[0014] A main direction extraction module, used to extract a first main direction for constructing an indoor global map from the initial point cloud data;
[0015] A data updating module, configured to control the robot to travel a preset distance after rotating the initial point cloud data according to the first main direction, so as to obtain updated point cloud data of the adjusted position;
[0016] The main direction extraction module is further used to extract a second main direction from the updated point cloud data;
[0017] The data updating module is further configured to, when the first main direction is different from the second main direction, control the robot to continue moving and mapping after rotating the acquired point cloud data according to the second main direction until the indoor global point cloud data is acquired;
[0018] The main direction extraction module is further used to extract the third main direction from the global point cloud data;
[0019] The map construction module is used to perform point cloud rotation and map conversion on the global point cloud data according to the third main direction to obtain an indoor global map when the second main direction is different from the third main direction.
[0020] In a third aspect, an embodiment of the present application provides a robot, comprising:
[0021] Laser radar, installed on the robot body, is used to collect point cloud data of the robot's environment;
[0022] a memory storing a computer program;
[0023] A processor is used to execute the computer program to implement the indoor map construction method.
[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed on a processor, implements the indoor map construction method.
[0025] The embodiments of the present application have the following beneficial effects:
[0026] The indoor map construction method of the present application performs a first main direction detection when the mapping mode is turned on, and controls the robot to move a certain distance after rotating to the first main direction, and then performs a second main direction detection; compares whether the two main directions are consistent, and adjusts the point cloud data for mapping acquired by the robot according to the second main direction when they are inconsistent; then, continues to move and build the map after adjustment until the indoor global point cloud data is acquired; finally, performs a third main direction detection using the global point cloud, and rotates and converts the global point cloud when it is confirmed to be different from the second main direction, so as to obtain an indoor global map for display, that is, by performing three main direction detection mechanisms at different times, the accuracy of the main direction of the global map constructed for terminal display can be ensured, and the constructed global map can be prevented from being tilted, which has a significant impact on the aesthetics of the constructed indoor map. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 A schematic diagram of the structure of a robot according to an embodiment of the present application is shown;
[0029] Figure 2 A flow chart showing the indoor map construction method according to an embodiment of the present application is shown;
[0030] Figure 3 A flow chart of straight line detection according to an embodiment of the present application is shown;
[0031] Figure 4 A schematic diagram of a point cloud straight line detection result according to an embodiment of the present application is shown;
[0032] Figure 5 A schematic diagram of clustering multiple candidate straight lines according to an embodiment of the present application is shown;
[0033] Figure 6 A schematic diagram of the initial global map constructed when the robot's starting position is at an angle to the overall main direction of the room is shown;
[0034] Figure 7 Shows the Figure 6 A schematic diagram of a global optimized map obtained after the initial global map shown is rotated in the third main direction;
[0035] FIG8(a) and FIG8(b) respectively show a schematic diagram of an initial global map obtained when the robot's starting position is consistent with the direction of a local room in the room and a schematic diagram of a global optimized map obtained after the main direction is adjusted using the method of the present application;
[0036] Fig. 9 A structural schematic diagram of an indoor map building device according to an embodiment of the present application is shown.
[0037] Description of main component symbols:
[0038] 10-robot; 11-processor; 12-memory; 13-sensing unit; 14-execution unit;
[0039] 100 - indoor map building device; 110 - data acquisition module; 120 - main direction extraction module; 130 - data update module; 140 - map building module. DETAILED DESCRIPTION
[0040] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0041] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0042] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0043] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0044] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0045] Figure 1 The figure shows a schematic diagram of the structure of a robot 10 provided in an embodiment of the present application. For example, the robot 10 may be a cleaning robot 10, a cruising robot 10, etc., and has an indoor mapping function. Exemplarily, the robot 10 includes a processor 11, a memory 12, and a sensing unit 13, wherein the sensing unit 13 is arranged on the robot 10 body, and is used to sense the external environment information where the robot 10 is located, and the memory 12 stores a computer program, and the processor 11 runs the computer program, so that the robot 10 executes the indoor map construction method in the embodiment of the present application, so as to ensure the accuracy of the main direction of the entire map, and avoid the global map displayed on the terminal from being tilted.
[0046] Among them, the processor 11 can be an integrated circuit chip with signal processing capabilities. The processor 11 can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or at least one of other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0047] The memory 12 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 12 is used to store a computer program, and the processor 11 may execute the computer program accordingly after receiving an execution instruction.
[0048] The sensing unit 13 may include, but is not limited to, laser radar, etc., wherein the laser radar can be used to obtain point cloud data of the external environment where the robot 10 is currently located, and then these point cloud data can be used to perform functions such as two-dimensional mapping, three-dimensional mapping, distance measurement, autonomous navigation, obstacle avoidance, etc., which are not limited here. Further optionally, the sensing unit 13 may also include, for example, a camera, an infrared sensor, etc. For example, an infrared sensor can be used to obtain distance information from the external environment, and a camera can be used to obtain image information of the robot 10 during walking, etc.
[0049] In addition, the robot 10 may also include some execution units 14 disposed on the robot 10 body, which may specifically include but are not limited to a walking mechanism for realizing movement, such as rolling wheels, mechanical legs, etc.; a cleaning mechanism for realizing a cleaning function, such as a spray washing component, a decontamination component, etc. It can be understood that the specific structure of the execution unit 14 can be determined according to actual needs, and will not be described in detail here.
[0050] It can be understood that the robot 10 can be used to perform indoor mapping. By implementing the indoor map construction method of the embodiment of the present application, that is, by extracting the main direction three times at different times to correct the main direction, the accuracy of the main direction when building the map can be improved, so that the global map can avoid the overall tilt phenomenon and reduce the problem of map jaggedness when displayed, so as to be more in line with the user's viewing habits. In addition, when rotating the main direction, the indoor map construction method of the embodiment of the present application can also convert the rotation of the global map into the rotation of the point cloud data, which can greatly reduce the time consumption of rotating the main direction of the whole map, while ensuring that the environmental information features are not lost.
[0051] The indoor map construction method is described below with reference to some specific embodiments.
[0052] Figure 2A flow chart of an indoor map construction method according to an embodiment of the present application is shown. Exemplarily, the indoor map construction method includes the following steps:
[0053] S110, after the robot 10 starts the mapping mode, it obtains the initial point cloud data of the starting position.
[0054] The mapping mode refers to a working mode pre-configured in the robot 10, which can be executed by the processor 11 or by a positioning and mapping module separately set in the robot 10, and is not limited here. In this mode, the robot 10 activates the laser radar to collect real-time point cloud data to obtain surrounding environment information, so as to achieve autonomous positioning, map construction, obstacle avoidance and other tasks.
[0055] It can be understood that each time the robot 10 acquires a frame of point cloud data (i.e., laser radar data), it will store the frame of point cloud data and record the position and posture information of the robot 10 at the current moment. Afterwards, based on the information of the detection point contained in the frame of point cloud data and the position and posture information, the coordinates of the detection point in the mapping coordinate system are determined to achieve positioning and mapping. It can be understood that the point cloud data collected by the robot 10 is based on the laser radar coordinate system, and the mapping coordinate system is the coordinate system referenced by the robot 10 when mapping indoors.
[0056] It should be noted that after the robot 10 starts mapping, it usually determines the mapping coordinate system used for indoor mapping based on its initial position information. Specifically, the initial position of the robot 10 is used as the origin of the mapping coordinate system, the initial orientation is the positive direction of the X axis, and the direction perpendicular to the initial orientation is the positive direction of the Y axis. Therefore, if the initial orientation of the robot 10 at the starting position is tilted or perpendicular to the length direction of the indoor wall, then the final generated global map will be tilted and the wall lines will appear jagged.
[0057] To this end, this embodiment proposes to use point cloud data acquired at different times to extract the main directions three times, and at the same time convert the rotation of the map into the rotation of the point cloud, so as to detect and correct the main direction, thereby improving the rotation accuracy and the accuracy of the main direction, and avoiding the overall tilt and jagged appearance of the constructed global map.
[0058] Exemplarily, after the robot 10 is placed at a certain position in the room (referred to as the starting position), the mapping mode is turned on, and the robot 10 rotates in place for one circle, while controlling the laser radar to emit laser outward during the rotation to obtain corresponding point cloud data. The point cloud data collected at this time is called initial point cloud data.
[0059] S120, extracting a first main direction for constructing an indoor global map from the initial point cloud data.
[0060] In this embodiment, the starting position is used as the first moment of extracting the main direction, mainly to determine whether the starting position is suitable for determining the main direction for indoor mapping. For example, if there are a variety of long-shaped ornaments (such as sofas, long tables, etc.) around the starting position of the robot 10 or its initial orientation is at a certain angle to the wall, the extracted main direction may be crooked or even invalid, which means that the main direction determined by the starting position is not suitable as the main direction for mapping.
[0061] Exemplarily, by first performing straight line detection on the initial point cloud data, a reference straight line is determined using the detected straight line, which is used as the main direction of the map. It is worth noting that the extraction method of the main direction each time in this embodiment can be the same, the only difference is that the point cloud data objects used for main direction extraction each time are different, namely the initial point cloud data obtained at the starting position, the updated point cloud data obtained at a short distance from the starting position, and the global point cloud data obtained after walking through the entire room.
[0062] Before performing the first main direction extraction, as an optional solution, it also includes: performing key frame splicing processing on the initial point cloud data to obtain spliced point cloud data, that is, using the spliced point cloud data as basic data for main direction extraction.
[0063] For example, by extracting key frames from the initial point cloud data, and then splicing these key frames, the spliced point cloud data is obtained. Among them, when extracting key frames, it can be selected according to a certain number of frames, or after walking a short distance, or after rotating a certain angle, etc., which is not limited here. The number of key frames used for splicing mainly depends on the angle at which the laser radar installed on the robot 10 body is blocked by other structures on the robot 10 (such as pillars, etc.). For example, when the blocking angle is small, 2 frames can be selected for splicing; if the blocking angle is larger, more frames can be selected.
[0064] It is understandable that the purpose of stitching is that, on the one hand, due to the installation position of the lidar, there is a problem of field of view obstruction, so 360-degree all-round data can be obtained by stitching point clouds from different angles; on the other hand, the stitched point cloud is denser, which is more conducive to the subsequent straight line detection processing.
[0065] The following uses the spliced point cloud data as an example to illustrate how to extract the main direction. It is understandable that the main direction can also be directly extracted using the initial point cloud data. Here is just an example of the main direction extraction process.
[0066] In one embodiment, if Figure 3 As shown in Figure 2, the main direction extraction process includes the following sub-steps:
[0067] S210, performing straight line detection based on the target point cloud data to obtain candidate straight lines.
[0068] It can be understood that the target point cloud data here is the initial point cloud data or the above-mentioned spliced point cloud data obtained based on the initial point cloud data. For example, a linear regression algorithm can be used to detect straight lines. Specifically, a random sampling consensus (RANSAC) algorithm and / or a least squares method can be used. Considering that there are a lot of point cloud data, the calculation speed is slow when the least squares method is used for calculation. In order to achieve lightweight calculations, this embodiment preferably combines RANSAC and the least squares method to perform fast detection of straight lines. Among them, RANSAC can always find the optimal solution when the model is determined and the maximum number of iterations is limited.
[0069] Exemplarily, a preset number of points are randomly sampled from the target point cloud as target samples, assuming that these target samples all belong to the same plane model. Then, the least squares method is used to fit the target samples to obtain the parameters of the plane model. Furthermore, when the plane model parameters are known, RANSAC is used to iterate the model parameters to obtain a plane model with the best parameters. The plane model with the best parameters includes the candidate straight lines obtained by fitting. For example, Figure 4 The figure shows one of the candidate lines L detected from the target point cloud.
[0070] Specifically, when iterating the model parameters, the distance from each point in the point cloud to the plane model under the current parameters is calculated, wherein the points whose distance is less than the preset threshold are taken as inner points to obtain the number of inner points of this sampling. Conversely, the points whose distance is greater than or equal to the preset threshold are taken as outer points. If the number of inner points of this sampling is greater than the number of inner points of the previous sampling, it means that the plane model under the current surface parameters contains more inner points, indicating that the model parameters calculated at this time are better, so it is necessary to iteratively update the current parameters of the plane model, and then repeat the above-mentioned random sampling operation and the operation of judging the number of inner points until the preset number of samplings is reached, and the optimal parameters of the plane model are output. It can be understood that by ensuring a certain number of samplings, the probability that multiple randomly selected points are all inner points can be made greater, and the value of the probability of outer points can be reduced accordingly.
[0071] The number of sampling times can be determined by calculating the probability that all n randomly selected points are interior points. If expressed by the formula, we have: P f =(1-W n ) k =1-p, where W n represents the probability that n randomly selected points are all interior points, P fis the probability of an external point, and k is the number of samplings. Therefore, taking the logarithm of the above formula, we can solve for the number of samplings k: k = log(1-p) / log(1-W n ).
[0072] S220, clustering all candidate lines to obtain at least one line set.
[0073] In this embodiment, a multi-line clustering method is used to detect the lines as the main direction. For example, the lines that are close to parallel and perpendicular are mainly classified into the same category, and then the category with the most lines constitutes a line set.
[0074] In one embodiment, all straight lines in the first direction that are parallel or approximately parallel, and straight lines in the second direction that are perpendicular or approximately perpendicular to the first direction among all candidate straight lines are classified into the same category to obtain a straight line set. The aforementioned approximately parallel straight lines or approximately perpendicular straight lines should satisfy that the angle between the two straight lines is within a preset angle range, for example, not exceeding 5 degrees to 10 degrees.
[0075] For example, for Figure 5 The candidate straight lines shown may classify the approximately parallel candidate straight lines L11-L14 and the straight lines L21-L26 perpendicular or approximately perpendicular to any one of L11-L14 into the same category to form a straight line set. Then, a main direction and an angle between the main direction and the horizontal direction or the vertical direction are determined from the straight line set.
[0076] Further, optionally, after obtaining the above-mentioned straight line set, the remaining straight lines in all candidate straight lines can be classified into another category to obtain another straight line set. Whether to obtain the another straight line set can be selected according to actual needs.
[0077] It can be understood that, considering that most of the walls in home scenes are vertical, in this embodiment, those that are nearly parallel and those that are nearly vertical are classified into one category, and especially those that are perpendicular to each other are classified into the parallel category, which can better solve the special scenes where there are right-angled triangles in the room. In fact, most of the existing solutions detect the longest straight line as the main direction, and then the hypotenuse will be taken. However, the actual situation is that it is often more reasonable to select two of the vertical sides as the main direction, and the total straight line length is also longer. Therefore, the above-mentioned multi-line clustering method can be used to detect the right-angled side as the main direction.
[0078] S230, finding a set containing the largest number of lines from at least one set of lines as a target set, determining a reference line where the main direction is located from the target set, and calculating the main direction angle using the reference line.
[0079] The main direction angle refers to the angle between the reference straight line as the main direction and the horizontal line (X-axis) or the vertical line (Y-axis), which can be used as the angle basis for subsequent map rotation or point cloud rotation, so that the global map used for display extends either horizontally or vertically.
[0080] Exemplarily, the main direction can be determined from the set of lines with the largest number of lines. For example, the line with the longest length can be used as a reference, that is, the reference line is selected as the main direction when building the map. The direction of the line to be selected can also be determined by looking at the ratio of the number of parallel lines to the number of perpendicular lines. For example, when there are many parallel or nearly parallel lines, the longest line is found from these lines as the reference line, the main direction, etc. It can be understood that the above are only some optional examples and are not intended to be the only limitation.
[0081] As an optional solution, after extracting the first main direction, the method further includes:
[0082] First, check whether the first main direction meets the preset conditions. If the preset conditions are not met, the first main direction is determined to be invalid. Then, after the second main direction is extracted, the point cloud data obtained for constructing the raster map is directly rotated to the second main direction. It can be understood that by first determining whether there is a large uncertainty in the first main direction, after the second main direction is extracted, there is no need to compare it with the first main direction, and the second main direction can be directly used as the latest main direction to perform subsequent operations.
[0083] The above-mentioned preset conditions include at least one of the following situations:
[0084] Case 1: The length of the longest straight line in the target set exceeds the preset length. It can be understood that if the longest straight line in the straight line set containing the most straight lines is shorter, it means that no straight line can be found or the straight line feature is not obvious. At this time, it can be confirmed that the main direction extracted for the first time is not suitable. Otherwise, the first main direction can be retained for subsequent comparison with the second main direction.
[0085] Case 2: The difference in the number of lines in at least two line sets exceeds the preset number. It can be understood that if two line sets are obtained, and the number of lines in each line set is similar, it means that the environment is not suitable for the main direction detection of the overall environment. For example, when the direction of the sofa, long table or other long objects in the home is inconsistent with the direction of the wall, the above phenomenon is likely to occur. At this time, it can also be confirmed that the main direction extracted for the first time is not suitable. On the contrary, the first main direction can be retained for subsequent comparison with the second main direction.
[0086] S130, after rotating the initial point cloud data according to the first main direction, controlling the robot 10 to travel a preset distance to obtain updated point cloud data of the adjusted position.
[0087] The preset distance refers to a short distance close to the starting position, for example, it can be set to no more than 1m, such as 20cm, 50cm, 70cm, etc., which is not specifically limited here.
[0088] Exemplarily, after the first main direction is determined, when there is an angle between the first main direction and the X-axis or Y-axis in the mapping coordinate system, it is necessary to rotate the initial point cloud data by the above angle according to the first main direction control to rotate the inclined reference line to a horizontal or vertical state, thereby avoiding jagged edges in the subsequently generated global map in pixels.
[0089] Then, the robot 10 is controlled to continue to move a short distance and then rotate in place, while the laser radar is used to collect point cloud data of the current environment, which is updated compared to the initial point cloud data, and is recorded as updated point cloud data. The reason for controlling the robot to move a short distance is to further determine the rationality of the starting position as the main direction extraction time by adjusting the position of the robot 10, and whether the adjusted current environment can be used as the new main direction extraction time when it is unreasonable.
[0090] S140, extracting the second main direction from the updated point cloud data. It can be understood that the second main direction extraction process can refer to the first main direction extraction method, the only difference is that the target point cloud data is the updated point cloud data, which will not be repeated here.
[0091] Optionally, before starting to calculate the second main direction, it is possible to further determine whether the updated point cloud meets the corresponding conditions to ensure that the point cloud data used for the second main direction extraction is appropriate. For example, the above-mentioned preset condition can be to detect whether the updated point cloud has obvious feature changes compared to the initial point cloud, which can be specifically reflected in the addition or change of new features exceeding a preset number. If so, the updated point cloud data can be used to extract the second main direction. If not, the second main direction extraction is not performed. Optionally, the second main direction extraction can be performed after advancing a short distance and when a large feature increase occurs.
[0092] Further optionally, before extracting the second main direction, the updated point cloud data can also be keyframe stitched to extract the main direction using the point cloud data after this stitching. The keyframe stitching can be implemented by referring to the implementation process of processing the initial point cloud data, which will not be described again here.
[0093] S150, when the first main direction is different from the second main direction, after rotating the acquired point cloud data according to the second main direction, the robot is controlled to continue moving and mapping until the indoor global point cloud data is acquired.
[0094] For example, the first two main directions are compared. If they are the same, it means that there is no need to adjust the main direction at present, and the map can be constructed along the current main direction according to the planned path until the global point cloud data of the room is obtained. If they are different, the obtained point cloud data needs to be rotated to the second main direction.
[0095] It can be understood that the rotated point cloud data here can be the collected updated point cloud data, or all the point cloud data obtained in the previous two times, or it can be the valid point cloud data required for mapping after all the point cloud data are processed to reduce the amount of data processing, which is not limited here.
[0096] Generally, after calculating the second main direction, in most cases, the accurate main direction can be achieved after the first two main direction detections and adjustments. However, there are exceptions. For example, in a home scene, a room is tilted compared to other rooms. If the robot 10 starts mapping in this room, the initial environment determines that the first two detections will inevitably make the main direction tilted with this room. When the mapping of the entire house is completed, the actual main direction of the whole will be inconsistent with the main direction extracted in the room or the initial environment. For another example, when the robot 10 is placed in a room, the main direction will be different from the main direction extracted in the room or the initial environment. Figure 6 The starting position shown (i.e. Figure 6 When the starting point is at the position marked by the arrow in the middle), it can be seen that there is an obstruction at the starting point that is inclined with the vertical wall. Even if the secondary main direction detection is performed, the final generated global map is still Figure 6 As shown, the global map is skewed and the wall lines appear jagged.
[0097] Therefore, to avoid the above situation, this embodiment adds a third main direction detection after collecting the global point cloud data of the entire room to determine the final main direction for building the map. In addition, this embodiment also replaces the key frame refresh method of the pixel image with the point cloud rotation method to implement the main direction rotation process, which can reduce the time consumption of the main direction rotation based on the global map and ensure that the environmental feature information is not lost.
[0098] S160, extracting the third main direction from the global point cloud data. It can be understood that the third main direction extraction process can refer to the first main direction extraction method mentioned above, the only difference is that the target point cloud data is the global point cloud data, which will not be described again here.
[0099] As an optional method, before extracting the third main direction, the global point cloud data can be used for map conversion to obtain an initial global map. For example, a global plane map with a preset pixel resolution can be obtained by plane projection of the global point cloud data, and the global plane map can be rasterized to obtain a global raster map. If the second main direction extracted subsequently is the same as the third main direction, the initial global map is used as the final indoor global map for display.
[0100] S170, when the second main direction is different from the third main direction, performing point cloud rotation and map conversion on the global point cloud data according to the third main direction to obtain an indoor global map.
[0101] Exemplarily, if the main direction mentioned based on the global point cloud data is different from the second main direction, it means that there is still a problem with the second main direction, and the third main direction needs to be used as the standard for mapping. Moreover, the main direction extracted from the global point cloud data is the most accurate. It can be understood that when the first two main directions are inconsistent, the movement and lidar detection are performed by rotating to the second main direction first. If the third main direction is inconsistent with the second main direction, the collected global point cloud data needs to be rotated to the third main direction to obtain an indoor global map that meets the requirements.
[0102] It is worth noting that, unlike the prior art, the embodiment of the present application achieves the purpose of map rotation by rotating the point cloud, so that most of the lines of the rotated global map are displayed in a horizontal and vertical state rather than a tilted state.
[0103] As an optional solution, when extracting the third main direction, it also includes: first sparse processing the global point cloud data to obtain sparse point cloud data; then extracting the third main direction from the sparse point cloud data, and using the third main direction to rotate the point cloud and convert the map.
[0104] For example, when performing the sparse processing, the global point cloud is firstly projected onto a plane to obtain a global plane map of a first pixel resolution, and then the global plane map is rasterized to obtain a grid map. Next, a point cloud in each pixel grid is retained, and this point cloud is used as the average value for constructing the current pixel. For example, in one embodiment, the average values of multiple point clouds in each pixel grid in the grid map can be calculated respectively, and the obtained average value is used as the position information of a single point cloud retained in the pixel grid. Alternatively, in another embodiment, the multiple point clouds corresponding to each pixel grid in the grid map can be clustered respectively, and the obtained cluster center value is used as the position information of a single point cloud retained in the pixel grid.
[0105] It is worth noting that the above-mentioned first pixel resolution can be higher than the pixel resolution usually used for indoor map display. Usually, the pixel resolution of indoor maps can be set to 0.025m / pix or 0.05m / pix, etc. For example, the first pixel resolution can be set to 0.01m / pix, etc., but it is not limited to this, as long as it is higher than the pixel resolution of the global map used for the final display. This is because the point cloud in each pixel grid is sparsely processed. By using a map with a higher pixel resolution, the integrity of the rotated features can be better guaranteed while reducing the large amount of calculation of the global point cloud. This can effectively solve the problems of low accuracy and large feature loss when rotating based on grid maps in existing solutions, as well as the time-consuming problem of updating the historical point cloud data to the map after rotating it to a corresponding angle.
[0106] In one embodiment, point cloud rotation and map conversion are performed using the third principal direction, including: rotating sparse point cloud data in a lidar coordinate system to the third principal direction to obtain rotated point cloud data in a mapping coordinate system, and performing planar projection on the rotated point cloud data to obtain an indoor global map of a second pixel resolution.
[0107] When rotating the point cloud, the coordinate position of each point cloud in the sparse point cloud data is multiplied by the rotation matrix generated based on the third main direction angle to obtain the rotated point cloud data after the position change, and finally the rotated point cloud data is projected on a two-dimensional plane, that is, converted into a global map of the second pixel resolution for display on the user terminal interface. The second pixel resolution can adopt the pixel resolution commonly used for map display.
[0108] It can be understood that the second pixel resolution here and the first pixel resolution mentioned above are both artificially set, and the two can be equal or unequal. Preferably, the above-mentioned first pixel resolution is usually higher than the second pixel resolution. For example, the first pixel resolution is set to 0.01m / pix and the second pixel resolution is set to 0.05m / pix, or the first pixel resolution is set to 0.025m / pix and the second pixel resolution is set to 0.05m / pix, etc. Of course, these are just a few optional examples.
[0109] With the above Figure 6 Taking the initial global map constructed as an example, after rotating to the third main direction, we can get Figure 7The adjusted global map shown. In addition, the indoor map construction method of the embodiment of the present application is also applicable to the scene when the starting position is consistent with the direction of the current room but is inclined with other areas. As shown in Figure 8(a), assuming that the robot 10 turns on the mapping mode in room 6, a global map with the room as the main direction can be obtained, but after the mapping is completed, it is found that other rooms are inclined. For this reason, after the three main direction adjustments and mapping display adjustments of the present application are adopted, a global map as shown in Figure 8(b) can be obtained. It can be seen that most of the straight lines in the global map are in a horizontal and vertical state. This is because the embodiment of the present application adopts a method of clustering multiple straight lines that are close to parallel and vertical and extracting the main direction from the set of straight lines with the most straight lines. Obviously, this method can obtain a more regular global map.
[0110] The indoor map construction method of the embodiment of the present application cleverly uses the mechanism of detecting the main direction at different times, and uses accurate point cloud data to detect the main direction. When the global map is rotated, in order to generate accurate point cloud data, the point cloud is sparsely processed and a raster map with higher pixel resolution is saved; then, the sparse point cloud is rotated and converted into coordinates, thereby obtaining an accurate rotated point cloud, and finally generating a global map for display on the terminal interface. The above series of operations effectively avoids the time-consuming problem of global map conversion through historical key frame point cloud data. In addition, since the above-mentioned multi-line clustering method is used to determine the main direction, the main direction of the global map can be guaranteed to be more accurate, so that the constructed global map greatly reduces the appearance of jagged lines, and the global map will not look tilted, achieving a better beautification effect.
[0111] Fig. 9 A schematic diagram of the structure of an indoor map construction device 100 according to an embodiment of the present application is shown. Exemplarily, the indoor map construction device 100 includes:
[0112] The data acquisition module 110 is used to acquire the initial point cloud data of the starting position after the robot 10 starts the mapping mode.
[0113] The main direction extraction module 120 is used to extract the first main direction for constructing the indoor global map from the initial point cloud data.
[0114] The data updating module 130 is used to control the robot to travel a preset distance after rotating the initial point cloud data according to the first main direction to obtain updated point cloud data of the adjusted position.
[0115] The main direction extraction module 120 is further used to extract a second main direction from the updated point cloud data.
[0116] The data updating module 130 is also used to control the robot to continue moving and mapping after rotating the acquired point cloud data according to the second main direction when the first main direction is different from the second main direction until the indoor global point cloud data is acquired.
[0117] The main direction extraction module 120 is further used to extract the third main direction from the global point cloud data.
[0118] The map construction module 140 is used to perform point cloud rotation and map conversion on the global point cloud data according to the third main direction when the second main direction is different from the third main direction, so as to obtain an indoor global map.
[0119] Optionally, the data updating module 130 is further configured to directly control the robot to continue moving and building a map when the first main direction is the same as the second main direction until the global point cloud data is acquired.
[0120] Optionally, the map construction module 140 is further used to perform map conversion using the global point cloud data to obtain an initial global map, and when the second main direction is the same as the third main direction, use the initial global map as an indoor global map for display.
[0121] Optionally, the data update module 130 is also used to determine whether the first main direction meets a preset condition after the main direction extraction module 120 extracts the first main direction; if the preset condition is met, detect whether the first main direction is the same as the second main direction; if the preset condition is not met, determine that the first main direction is invalid, and after the second main direction is extracted, rotate the acquired point cloud data to the second main direction.
[0122] Optionally, the main direction extraction module 120 is further used to perform sparse processing on the global point cloud data to obtain sparse point cloud data, wherein the sparse point cloud data is used for point cloud rotation and map conversion.
[0123] It can be understood that the device of this embodiment corresponds to the indoor map construction method of the above embodiment, and the options in the above embodiment are also applicable to this embodiment, so they will not be described repeatedly here.
[0124] The present application also provides a computer-readable storage medium for storing a computer program used in the robot 10. For example, the computer-readable storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0125] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0126] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0127] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the 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 smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application.
[0128] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A method for constructing an indoor map, characterized in that: include: After the robot starts the mapping mode, it obtains the initial point cloud data of the starting position; Extracting a first main direction for constructing an indoor global map from the initial point cloud data; After rotating the initial point cloud data according to the first main direction, controlling the robot to travel a preset distance to obtain updated point cloud data of the adjusted position; Extracting a second main direction from the updated point cloud data; When the first main direction is different from the second main direction, after rotating the acquired point cloud data according to the second main direction, controlling the robot to continue moving and mapping until the indoor global point cloud data is acquired; Extracting a third main direction from the global point cloud data; When the second main direction is different from the third main direction, point cloud rotation and map conversion are performed on the global point cloud data according to the third main direction to obtain an indoor global map.
2. The indoor map construction method according to claim 1, characterized in that: Also includes: When the first main direction is the same as the second main direction, the robot is directly controlled to continue moving forward and building a map until the global point cloud data is acquired.
3. The indoor map construction method according to claim 1 or 2, characterized in that: After obtaining the indoor global point cloud data, the method further includes: Using the global point cloud data to perform map conversion to obtain an initial global map; After extracting the third main direction from the global point cloud data, the method further includes: When the second main direction is the same as the third main direction, the initial global map is used as the indoor global map for display.
4. The indoor map construction method according to claim 1, characterized in that: The extraction of the main direction comprises: Performing straight line detection based on target point cloud data to obtain candidate straight lines; wherein the target point cloud data is the initial point cloud data, the updated point cloud data or the global point cloud data; Perform line clustering on all candidate lines to obtain at least one line set; A set including the largest number of lines is found from the at least one line set as a target set, a reference line where the main direction is located is determined from the target set, and the main direction angle is calculated using the reference line.
5. The indoor map construction method according to claim 4, characterized in that: The step of clustering all candidate lines to obtain at least one line set includes: Classifying all candidate straight lines that are parallel or approximately parallel to a first direction and straight lines that are perpendicular or approximately perpendicular to the first direction into the same category to obtain a straight line set; wherein the approximately parallel straight lines or the approximately perpendicular straight lines should satisfy that the angle between the corresponding two straight lines is within a preset angle range; After obtaining a set of straight lines, the method further includes: The remaining straight lines among all candidate straight lines are classified into another category to obtain another set of straight lines.
6. The indoor map construction method according to claim 4, characterized in that: After extracting the first main direction, the method further includes: Determining whether the first main direction meets a preset condition; If the preset condition is met, detecting whether the first main direction is the same as the second main direction; If the preset condition is not met, the first main direction is determined to be invalid, and after the second main direction is extracted, the acquired point cloud data is rotated to the second main direction; The preset condition includes at least one of the following: Case 1: the length of the longest straight line in the target set exceeds the preset length; Case 2: The difference between the numbers of straight lines in at least two of the straight line sets exceeds a preset number.
7. The indoor map construction method according to claim 4, characterized in that: The straight line detection based on the target point cloud data includes: The target point cloud data is subjected to straight line detection using a random sampling consistency algorithm and a least squares method, specifically including: Randomly sampling a preset number of points from the target point cloud data as target samples; According to the target sample, a least square method is used to perform straight line fitting to obtain parameters of a plane model; Calculate the distance between each point in the target point cloud data and the current plane model, and take the points whose distance is less than a preset threshold as inliers to obtain the number of inliers for this sampling; If the number of inner points in this sampling is greater than the number of inner points in the previous sampling, the parameters of the plane model are updated until the preset number of samplings is reached, and the latest parameters of the plane model are output; the plane model with the latest parameters includes multiple candidate straight lines obtained by fitting.
8. The indoor map construction method according to claim 4, characterized in that: Before performing point cloud rotation and map conversion on the global point cloud data according to the third main direction, the method further includes: The global point cloud data is subjected to sparse processing to obtain sparse point cloud data, wherein the sparse point cloud data is used for point cloud rotation and map conversion; wherein the sparse processing includes: Performing planar projection on the global point cloud data to obtain a planar map of a first pixel resolution, and performing rasterization processing on the planar map to obtain a raster map; Calculate the average value of multiple point clouds in each pixel grid in the grid map respectively, and use the obtained average value as the position information of a single point cloud retained in the corresponding pixel grid; or, Clustering is performed on multiple point clouds corresponding to each pixel grid in the grid map, and the obtained cluster center value is used as the position information of a single point cloud retained in the corresponding pixel grid.
9. The indoor map construction method according to claim 8, characterized in that: The performing point cloud rotation and map conversion on the global point cloud data according to the third main direction includes: The sparse point cloud data in the laser radar coordinate system is rotated to the third main direction to obtain rotated point cloud data in the mapping coordinate system, and the rotated point cloud data is plane-projected to obtain an indoor global map of a second pixel resolution; wherein the first pixel resolution is higher than the second pixel resolution.
10. An indoor map construction device, characterized in that: include: The data acquisition module is used to obtain the initial point cloud data of the starting position after the robot starts the mapping mode; A main direction extraction module, used to extract a first main direction for constructing an indoor global map from the initial point cloud data; A data updating module, configured to control the robot to travel a preset distance after rotating the initial point cloud data according to the first main direction, so as to obtain updated point cloud data of the adjusted position; The main direction extraction module is further used to extract a second main direction from the updated point cloud data; The data updating module is further configured to, when the first main direction is different from the second main direction, control the robot to continue moving and mapping after rotating the acquired point cloud data according to the second main direction until the indoor global point cloud data is acquired; The main direction extraction module is further used to extract the third main direction from the global point cloud data; The map construction module is used to perform point cloud rotation and map conversion on the global point cloud data according to the third main direction to obtain an indoor global map when the second main direction is different from the third main direction.
11. A robot, characterized in that: include: Laser radar, installed on the robot body, is used to collect point cloud data of the robot's environment; a memory storing a computer program; A processor, configured to execute the computer program to implement the indoor map construction method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer program is stored therein, and when the computer program is executed on a processor, the indoor map construction method according to any one of claims 1 to 9 is implemented.
Citation Information
Cited By
Grid map main direction calculation method, apparatus and device, and computer storage medium
CN119963629A
Indoor map construction method and apparatus, robot, and computer-readable storage medium
WO2026040296A1
