Navigation method and device, robot and storage medium
By judging the distribution of obstacles, the mobile robot enters an obstacle avoidance or escape mode, solving the problem of being trapped in an area surrounded by obstacles and enabling smooth navigation of the self-moving device.
Patent Information
- Application Number
- CN202511426357.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-30
- Publication Date
- 2026-01-23
AI Technical Summary
Mobile robots are easily misled in areas surrounded by obstacles such as stools, sofas, or tables, leading to repeated collisions and getting stuck, making it impossible for them to move normally.
By determining whether the distribution of obstacles meets the preset navigation conditions, the system enters the escape mode and navigates to the area outside the obstacle closest to the self-moving device, or enters the obstacle avoidance mode to avoid obstacles, using grid maps and image processing technology to determine the obstacle area and generate waypoints.
This effectively avoids collisions between mobile robots and narrow areas surrounded by obstacles, ensuring that they can escape successfully and move normally.
Smart Images

Figure CN121386752A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of robots, and in particular to a navigation method and device, a robot, and a storage medium. BACKGROUND
[0002] With the improvement of people's living quality, more and more mobile robots enter thousands of households. Mobile robots can autonomously plan paths, perceive environments, and complete specific tasks. For example, a sweeping robot or a mopping robot can autonomously scan the layout of a room, plan a cleaning path, and avoid obstacles such as furniture and wires, thereby liberating people from repetitive floor cleaning tasks.
[0003] When a mobile robot moves under an object such as a stool, sofa, or table, the area under the object is surrounded by legs of the table or stool, and the enclosed space can mislead the mobile robot, thereby causing the mobile robot to miss identifying obstacles. The mobile robot can stop moving after colliding with the legs of the table or stool multiple times in the area under the object, thereby causing the mobile robot to be trapped in the area under the object. SUMMARY
[0004] The present application provides a navigation method, device, robot, and storage medium, which aims to enable a mobile robot to escape from a narrow area surrounded by obstacles under an object such as a stool, sofa, or table.
[0005] In a first aspect, a navigation method is provided, comprising: In response to a preset collision condition being triggered, determining whether an obstacle in a target detection range satisfies a preset navigation condition, the target detection range being centered on a position of the self-moving device in a navigation map and being set based on a size of the self-moving device, and the preset navigation condition including that the obstacle in the target detection range is distributed in at least three target directions of the self-moving device, and an included angle between the at least three target directions is greater than or equal to 90°; If the obstacle in the target detection range satisfies the preset navigation condition, entering an escape mode, the escape mode being a mode for navigating to a path point outside a target obstacle region, the target obstacle region being a region of an obstacle closest to the self-moving device in the navigation map; If the obstacle in the target detection range does not satisfy the preset navigation condition, entering an obstacle avoidance mode, the obstacle avoidance mode being a mode for navigating to a path point on a movement route of the self-moving device In the technical solution, in response to the preset collision condition being triggered, it is determined whether the obstacles in the target detection range satisfy preset navigation conditions, the preset navigation conditions including that the obstacles in the target detection range are distributed in at least three target directions of the self-moving device, and the included angle between the at least three target directions is greater than or equal to 90°; if the obstacles in the target detection range satisfy the preset navigation conditions, it indicates that the self-moving device is in a narrow area surrounded by obstacles, and enters an escape mode, which can make the self-moving device navigate to an area outside the target obstacle region closest to the self-moving device, so as to make the self-moving device leave the narrow area surrounded by obstacles and thus escape; if the obstacles in the target detection range do not satisfy the preset navigation conditions, it indicates that the self-moving device is in an area that can be moved in a normal manner, and enters an obstacle avoidance mode, which makes the self-moving device navigate according to a normal obstacle avoidance route and thus move normally.
[0006] In combination with the first aspect, in a possible implementation manner, the navigation map is a grid map; the determining whether the obstacles in the target detection range satisfy the preset navigation conditions includes: judging whether there are obstacles in grids in a target grid set, the target grid set including at least four grids in the target detection range, the four grids being grids in the navigation map located in a left upper direction of the self-moving device, a right upper direction of the self-moving device, a left lower direction of the self-moving device, and a right lower direction of the self-moving device respectively; in a case where there are obstacles in at least three of the four grids, it is determined that the obstacles in the target detection range satisfy the preset navigation conditions; in a case where there are less than three grids with obstacles in the four grids, it is determined that the obstacles in the target detection range do not satisfy the preset navigation conditions.
[0007] The four grids in the navigation map located in the left upper direction, the right upper direction, the left lower direction, and the right lower direction of the self-moving device are judged for whether there are obstacles, in a case where there are obstacles in at least three of the four grids, it is determined that the obstacles in the target detection range satisfy the preset navigation conditions, and in a case where there are less than three grids with obstacles in the four grids, it is determined that the obstacles in the target detection range do not satisfy the preset navigation conditions, which is beneficial to quickly determining whether the obstacles in the target detection direction satisfy the preset navigation conditions, and thus quickly judging whether the self-moving device is in a narrow area surrounded by obstacles.
[0008] With reference to the first aspect, in a possible implementation manner, the entering the escape mode comprises: determining the target obstacle region; determining a target path point based on the target obstacle region, and controlling the self-moving device to move to the target path point, where the target path point is a path point outside the target obstacle region.
[0009] Since the target obstacle region closest to the self-moving device in the navigation map is usually a region corresponding to an obstacle surrounding the self-moving device, determining the target path point based on the target obstacle region is beneficial to avoiding the obstacle surrounding the self-moving device and reducing collision.
[0010] With reference to the first aspect, in a possible implementation manner, the determining the target path point based on the target obstacle region comprises: determining a target rectangle according to the target obstacle region, the target rectangle surrounding the target obstacle region, and each side of the target rectangle being greater than a preset distance from the target obstacle region; taking a midpoint of two short sides of the target rectangle as two candidate path points; and determining the target path point from the two candidate path points.
[0011] The target rectangle surrounding the target obstacle region and each side of the target rectangle being greater than a preset distance from the target obstacle region, a region in the target rectangle except the target obstacle region being a non-obstacle region, and the non-obstacle region being free of obstacles, taking the midpoint of the two short sides of the target rectangle as the two candidate path points, and determining the target path point from the two candidate path points, facilitate the self-moving device to move straight, thereby avoiding collision between the self-moving device and the obstacle in the obstacle region, and improving the possibility of the self-moving device escaping.
[0012] With reference to the first aspect, in a possible implementation manner, the determining the target path point from the two candidate path points comprises: determining, from the two candidate path points, a candidate path point closest to the self-moving device as the target path point.
[0013] Determining the candidate path point closest to the self-moving device as the target path point is beneficial to the self-moving device escaping in the shortest time.
[0014] With reference to the first aspect, in a possible implementation manner, the determining the target rectangle according to the target obstacle region comprises: extending a boundary of the target obstacle region outward, so that an area corresponding to the extended boundary is greater than an area of the target obstacle region; and determining an external rectangle of the extended boundary as the target rectangle.
[0015] The boundary of the target obstacle region is expanded, so that the area corresponding to the expanded boundary is larger than the area of the target obstacle region, which is beneficial to determine the non-obstacle region without obstacles, and further find the target path point for the self-moving device to escape.
[0016] With reference to the first aspect, in a possible implementation, the determining the target obstacle region closest to the self-moving device in the navigation map comprises: generating a first obstacle image according to the obstacles in the navigation map, the first obstacle image comprising all the obstacles in the navigation map, the size of the first obstacle image being the same as the size of the navigation map, and the background region other than the obstacles in the first obstacle image being a solid color region; performing binarization and opening operation on the first obstacle image to obtain a second obstacle image; extracting connected domains in the second obstacle image; and determining the target obstacle region according to the connected domains in the second obstacle image.
[0017] The first obstacle image with the background being a solid color region is generated according to the obstacles in the navigation map, and the binarization and opening operation are performed on the first obstacle image to obtain the second obstacle image, which can separate the obstacles from the image, and the connected domains in the second obstacle image are extracted, which is helpful to determine the obstacle region.
[0018] With reference to the first aspect, in a possible implementation, the determining the target obstacle region according to the connected domains in the second obstacle image comprises: performing negation on the second obstacle image to obtain a third obstacle image; and determining the connected domain closest to the self-moving device in the third obstacle image as the target obstacle region.
[0019] The negation is performed on the second obstacle image to obtain the third obstacle image, which can realize switching between the foreground and the background, and adapt to the algorithm requirement or processing requirement.
[0020] With reference to the first aspect, in a possible implementation, the method further comprises: setting a forbidden zone in the navigation map according to the target obstacle region, wherein the forbidden zone contains the target obstacle region, and the area of the forbidden zone is greater than or equal to the area of the target obstacle region.
[0021] Since the target obstacle region is usually a region corresponding to the obstacles surrounding the self-moving device, the forbidden zone is set according to the target obstacle region, which can prevent the self-moving device from entering the narrow region surrounded by the obstacles again in the subsequent working process, and avoid the self-moving device from being trapped.
[0022] The second aspect provides a navigation device, comprising: The condition judging module is configured to determine whether the obstacle in the target detection range meets a preset navigation condition in response to the preset collision condition being triggered, the target detection range being centered on the position of the self-moving device in the navigation map and being set based on the size of the self-moving device, and the preset navigation condition including that the obstacle in the target detection range is distributed in at least three target positions of the self-moving device, and the included angle between the at least three target positions is greater than or equal to 90°. The navigation module is configured to enter an escape mode if the obstacle in the target detection range meets the preset navigation condition, the escape mode being a mode of guiding navigation to a path point outside a target obstacle region, and the target obstacle region being the closest obstacle region to the self-moving device in the navigation map. The navigation module is further configured to enter an obstacle avoidance mode if the obstacle in the target detection range does not meet the preset navigation condition, the obstacle avoidance mode being a mode of guiding navigation to a path point on a moving route of the self-moving device.
[0023] In a third aspect, a robot is provided, including a memory and a processor, the memory being connected to the processor, the processor being configured to execute one or more computer programs stored in the memory, and the processor, when executing the one or more computer programs, causing the robot to implement the navigation method of the first aspect.
[0024] In a fourth aspect, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, the computer program including program instructions, and the program instructions, when executed by a processor, causing the processor to execute the navigation method of the first aspect.
[0025] The present application can achieve the following technical effects: if the obstacle in the target detection range meets the preset navigation condition, it indicates that the self-moving device is in a narrow region surrounded by obstacles, and the escape mode is entered to guide the self-moving device to navigate outside the target obstacle region closest to the self-moving device, i.e., to make the self-moving device leave the narrow region surrounded by obstacles and thus escape; if the obstacle in the target detection range does not meet the preset navigation condition, it indicates that the self-moving device is in a region that can be moved in a normal manner, and the obstacle avoidance mode is entered to guide the self-moving device to navigate along a normal obstacle avoidance route and thus move normally. BRIEF DESCRIPTION OF DRAWINGS In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative labor based on these drawings.
[0026] Figure 1 A flowchart of a navigation method provided by an embodiment of the present application is shown in FIG. 1; Figure 2 A schematic diagram of a navigation map and a target detection range provided by an embodiment of the present application is shown in FIG. 2; Figure 3 A schematic diagram of an obstacle image provided by an embodiment of the present application is shown in FIG. 3; Figure 4 A flowchart of extracting a connected domain provided by an embodiment of the present application is shown in FIG. 4; Figure 5 A structural diagram of a navigation device provided by an embodiment of the present application is shown in FIG. 5; Figure 6 A structural diagram of a robot provided by an embodiment of the present application is shown in FIG. 6. DETAILED DESCRIPTION
[0027] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0028] It should be noted that the various features in the embodiments of the present application can be combined with each other without conflict, and all fall within the scope of protection of the present application. In addition, although the functional modules are divided in the device schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from the module division in the device or the order in the flowchart. Furthermore, the "first", "second", "third" and the like used in the present application do not limit the data and execution order, but only distinguish the same items or similar items with basically the same function and effect.
[0029] The technical solution of the present application is applicable to the navigation scene of a self-moving device, and is particularly applicable to the navigation scene of a self-moving device in a narrow area surrounded by obstacles. The self-moving device refers to a device that can move autonomously to complete a certain task, and includes but is not limited to cleaning robots, transport robots, unmanned transport vehicles, and the like. The narrow area surrounded by obstacles refers to an area around which obstacles are distributed and the passable width of which is slightly greater than the width of the self-moving device. Taking a circular cleaning robot as an example, the passable width of the narrow area surrounded by obstacles is slightly greater than the diameter of the cleaning robot. When the self-moving device enters the narrow area surrounded by obstacles, the self-moving device may collide with the obstacles multiple times and stop moving due to the close distance between the self-moving device and the obstacles and being surrounded by the obstacles, resulting in the self-moving device being trapped in the narrow area surrounded by obstacles and being unable to work normally. The narrow area surrounded by obstacles is, for example, an area below a stool, an area below a table, and an area below a sofa, and the like, without being limited to the examples herein.
[0030] The technical solution of the present application aims to detect whether the self-moving device is located in the narrow area surrounded by obstacles, and to make the self-moving device escape when the self-moving device is located in the narrow area surrounded by obstacles. The technical solution of the present application can be applied to the self-moving device, or to a device connected to the self-moving device. For example, the self-moving device is a cleaning robot, and the device connected to the self-moving device can be a base station connected to the cleaning robot. The technical solution of the present application is described in detail below.
[0031] Referring to Figure 1 , Figure 1 A flowchart of a navigation method provided by an embodiment of the present application is shown in FIG. 1, and the method includes the following steps: Figure 1 S101, in response to a preset collision condition being triggered, determining whether the obstacles in a target detection range satisfy a preset navigation condition. S101, in response to a preset collision condition being triggered, determining whether the obstacles in a target detection range satisfy a preset navigation condition.
[0032] The preset collision condition is used to indicate that the self-moving device collides multiple times within a preset time. For example, the preset collision condition indicates that the self-moving device collides twice within a preset time. The preset time can be a fixed time. Alternatively, the preset time can also be a time generated by the self-moving device based on the actual environmental conditions or the device conditions of the self-moving device. For example, the preset time can be generated by the self-moving device according to the identification conditions of the current obstacle area, or adjusted by the self-moving device according to the travel speed of the self-moving device, without being limited to the examples herein. For the self-moving device, please refer to the foregoing description.
[0033] The target detection range is centered on the position of the self-moving device in the navigation map and is set based on the size of the self-moving device. The target detection range is slightly larger than the size of the self-moving device.
[0034] The navigation map refers to a map required by the self-moving device to realize autonomous positioning, path planning and obstacle avoidance. The navigation map can reflect the distribution of passable areas, obstacles and unknown areas, and the relative positional relationship between the passable areas, obstacles and unknown areas and the self-moving device. The passable area refers to an area that meets the traffic conditions, i.e., an area in which the self-moving device can freely pass through. The unknown area refers to an area in which it is not identified whether the self-moving device can pass through. The unknown area is an area other than the passable area and the obstacle.
[0035] Specifically, the navigation map can be a grid map, which represents the passability of the environment and the distribution of obstacles through grids. The grid map includes a plurality of grids, each of which is a square. In a specific example, the passable area can be represented as 0 in the grid map, the obstacle can be represented as 1 in the grid map, and the unknown area can be represented as 2 in the grid map, i.e., if the state value corresponding to the grid is 0, it means that the grid is a passable area, if the state value corresponding to the grid is 1, it means that the grid is an obstacle, and if the state value corresponding to the grid is 2, it means that the grid is an unknown area.
[0036] The target detection range surrounds the self-moving device in the navigation map, and the area of the target detection range in the navigation map is greater than the area of the self-moving device in the navigation map. The target detection range can be obtained by expanding the area of the self-moving device in the navigation map.
[0037] In a specific implementation scenario, the self-moving device is presented as a circle or an approximate circle in the navigation map, the position of the self-moving device in the navigation map is represented by a target grid, the target grid represents the geometric center of the self-moving device or the center of the base of the self-moving device, and the target detection range can include (2n-1) x (2n-1) grids centered on the target grid, n>d, d represents the number of grids corresponding to the radius of the self-moving device in the navigation map, for example, n=d+1.
[0038] Taking the grid accuracy of the grid map as 5 centimeters (cm) as an example, the length of each grid in the grid map represents 5 cm. Assuming that the radius of the self-moving device is 15 cm, the number of grids corresponding to the radius of the self-moving device in the navigation map is 3, and the target detection range includes 7 x 7 grids centered on the target grid. Exemplarily, the target detection range can be as shown in Figure 2 Figure 2 map in the above formula represents the navigation map, Figure 2 Sd in the above formula represents the target grid, Figure 2 F1 in the figure represents the target detection range.
[0039] The preset navigation conditions include: obstacles within the target detection range are distributed in at least three target locations of the self-moving device, and the angle between these at least three target locations is greater than or equal to 90°. These at least three target locations can be at least three of four locations forming a 90° angle with each other, for example, at least three of the following: the upper left, upper right, lower left, and lower right of the self-moving device. Alternatively, these at least three target locations can be three locations forming a 120° angle with each other, or they can be three locations forming a 110° angle, three locations forming a 100° angle, etc., and this application does not impose any limitations on this.
[0040] In one feasible implementation, the following steps A1-A3 are used to determine whether obstacles within the target detection range meet preset navigation conditions: A1. Determine whether there are obstacles in the grid cells of the target grid set.
[0041] Here, the target grid set includes at least four types of grids located within the target detection range. These four types of grids are the grid located in the upper left of the mobile device in the navigation map, the grid located in the upper right of the mobile device in the navigation map, the grid located in the lower left of the mobile device in the navigation map, and the grid located in the lower right of the mobile device in the navigation map.
[0042] Specifically, based on the location and size of the mobile device in the navigation map, four types of grids can be identified within the target detection range: the grid located in the upper left of the mobile device, the grid located in the upper right of the mobile device in the navigation map, the grid located in the lower left of the mobile device in the navigation map, and the grid located in the lower right of the mobile device in the navigation map.
[0043] For example, the target detection range is as follows Figure 2 As shown in F1, the radius of the automated mobile device corresponds to 3 grid cells in the navigation map. Within the target detection range, the 3×3 grid cells located to the upper left of the target grid are considered as the grid cells located to the upper left of the automated mobile device within the target detection range. The grid cells located to the upper left of the automated mobile device within the target detection range are shown below. Figure 2 As shown in Q1; within the target detection range, the 3×3 grids located at the upper right of the target grid can be considered as the grids located at the upper right of the mobile device within the target detection range. The grids located at the upper right of the mobile device within the target detection range are as follows: Figure 2Q2 in FIG. 6; the 3x3 grids located at the lower left of the target grid in the target detection range can be regarded as the grids located at the lower left of the self-moving device in the target detection range, and the grids located at the lower left of the self-moving device in the target detection range are as shown in Figure 2 Q3 in FIG. 6; the 3x3 grids located at the lower right of the target grid in the target detection range can be regarded as the grids located at the lower right of the self-moving device in the target detection range, and the grids located at the lower right of the self-moving device in the target detection range are as shown in Figure 2 Q4 in FIG. 6.
[0044] For each of the four kinds of grids in the target detection range, if there is an obstacle in any grid of the target category in the target grid set, it is determined that there is an obstacle in the grid of the target category. Taking the four kinds of grids in the target detection range as examples in Figure 2 Q1-Q4 in FIG. 6, if there is an obstacle in any grid of Q1, it is determined that there is an obstacle in the grid at the upper left of the self-moving device; if there is an obstacle in any grid of Q2, it is determined that there is an obstacle in the grid at the upper right of the self-moving device; if there is an obstacle in any grid of Q3, it is determined that there is an obstacle in the grid at the lower left of the self-moving device; and if there is an obstacle in any grid of Q4, it is determined that there is an obstacle in the grid at the lower right of the self-moving device.
[0045] A2, in the case that there is an obstacle in at least three of the four kinds of grids, it is determined that the obstacle in the target detection range meets the preset navigation condition.
[0046] Taking the four kinds of grids as examples in Figure 2 Q1-Q4 in FIG. 6, if there is an obstacle in at least three of Q1, Q2, Q3 and Q4, it is determined that the obstacle in F1 is distributed in at least three target positions of the self-moving device.
[0047] A3, in the case that the number of grids with obstacles in the four kinds of grids is less than three, it is determined that the obstacle in the target detection range does not meet the preset navigation condition.
[0048] In the above steps A1-A3, it is judged whether there is an obstacle in the four kinds of grids located at the upper left, upper right, lower left and lower right of the self-moving device in the navigation map, and in the case that there is an obstacle in at least three of the four kinds of grids, it is determined that the obstacle in the target detection range meets the preset navigation condition, and in the case that the number of grids with obstacles in the four kinds of grids is less than three, it is determined that the obstacle in the target detection range does not meet the preset navigation condition, which is beneficial to quickly determine whether the obstacle in the target detection position meets the preset navigation condition, so as to quickly judge whether the self-moving device is in a narrow area surrounded by obstacles.
[0049] Optionally, the target grid set can also include all grids in the target detection range, it can be judged whether there is an obstacle in the target grid set, the grids with obstacles in the target grid set are determined to obtain the obstacle grids, the direction vectors between the obstacle grids and the target grids are determined to obtain the direction vector set, the included angles between the direction vectors in the direction vector set are calculated, and it is judged whether there are at least three direction vectors with an included angle greater than or equal to 90° in the direction vector set. If there are at least three direction vectors with an included angle greater than or equal to 90° in the direction vector set, it is determined that the obstacle in the target detection range meets the preset navigation condition; otherwise, it is determined that the obstacle in the target detection range does not meet the preset navigation condition. The specific implementation of determining whether the obstacle in the target detection range meets the preset navigation condition is not limited in the present application.
[0050] In the case that the obstacle in the target detection range meets the preset navigation condition, it is indicated that the self-moving device is surrounded by obstacles and is close to the self-moving device, and the movement of the self-moving device is relatively limited, and step S102 is performed. In the case that the obstacle in the target detection range does not meet the preset navigation condition, it is indicated that the self-moving device is not surrounded by obstacles, and the movement of the self-moving device is relatively less limited, and step S103 is performed.
[0051] S102, enter the escape mode.
[0052] The escape mode is a mode of guiding to a path point outside a target obstacle region, the target obstacle region is the obstacle region closest to the self-moving device in the navigation map, and the target obstacle region is essentially a region formed by the connection of the obstacles surrounding the self-moving device.
[0053] Entering the escape mode specifically includes the following steps S1021-S1023: S1021, determine the target obstacle region.
[0054] In some embodiments, the target obstacle region is determined by the following steps B1-B4: B1, generate a first obstacle image according to the obstacles in the navigation map.
[0055] The first obstacle image includes all obstacles in the navigation map, the size of the first obstacle image is the same as the size of the navigation map, and the background region of the first obstacle image except the obstacles is a pure color region. The pixel value corresponding to the obstacle in the first obstacle image is a preset pixel value, and the preset pixel value is different from the pixel value corresponding to the pure color region. The difference between the preset pixel value and the pixel value corresponding to the pure color region can be greater than a preset segmentation threshold, and the preset segmentation threshold is a threshold value required for threshold segmentation of an image.
[0056] In an embodiment, the pure color region can be a white region, i.e., in the first obstacle image, the background region except the obstacle is a white region, and the obstacle is a foreground in the first obstacle image. A blank image with the same size as the navigation map can be created, and the obstacle can be added to the corresponding grid position of the blank image according to the position information of the obstacle in the navigation map, so as to generate the first obstacle image. For example, the navigation map includes MxN grids, the grid in the ith row and jth column of the navigation map represents an obstacle, and the position information of the obstacle in the navigation map is represented as (i, j). A blank image including MxN grids is created, and the obstacle is added to the grid in the ith row and jth column of the blank image, so as to generate the first obstacle image. In this embodiment, the pixel value corresponding to the grid in the ith row and jth column of the blank image can be set as a preset pixel value, so as to add the obstacle to the grid in the ith row and jth column of the blank image.
[0057] Exemplarily, the first obstacle image can be as shown in P1 in FIG. 1. Figure 2
[0058] It can be understood that the pure color region can also be a region of other colors, for example, the pure color region can also be a red region, a yellow region, a green region, a black region, etc., and the present application does not limit this. B2, binarizing and performing an opening operation on the first obstacle image to obtain a second obstacle image.
[0059] Binarizing the first obstacle image means converting the first obstacle image into an image containing only two pixel values, and the two pixel values can be a pixel value corresponding to black and a pixel value corresponding to white.
[0060] In an embodiment, the first obstacle image can be binarized based on the aforementioned preset segmentation threshold, i.e., the pixel value of a first pixel in the first obstacle image is modified to a first pixel value, the first pixel is a pixel with a pixel value greater than the preset segmentation threshold, and the pixel value of a second pixel in the first obstacle image is modified to a second pixel value, the second pixel is a pixel with a pixel value less than the preset segmentation threshold. The second pixel value is different from the first pixel value. For example, the first pixel value is a pixel value corresponding to black, and the second pixel value is a pixel value corresponding to white, or the first pixel value is a pixel value corresponding to white, and the second pixel value is a pixel value corresponding to black.
[0061] Alternatively, the first obstacle image can also be binarized based on the Otsu threshold algorithm or the Triangle threshold method. The present application does not limit the binarization method.
[0062] After binarizing the first obstacle image to obtain a binarized image corresponding to the first obstacle image, an opening operation is performed on the binarized image corresponding to the first obstacle image to obtain a second obstacle image. The image region representing the obstacle in the binarized image is eroded, and then the image region representing the obstacle in the eroded binarized image is dilated to obtain the second obstacle image.
[0063] Exemplarily, the second obstacle image can be as shown in P2 in FIG. 6. Figure 3
[0064] B3, extracting a connected domain in the second obstacle image.
[0065] The connected domain in the second obstacle image refers to a region formed by aggregation of multiple pixel points adjacent in position and having the same pixel value in the second obstacle image. All the pixels in the connected domain have the same pixel value. For example, all the pixels in the connected domain have the first pixel value or the second pixel value.
[0066] In a feasible implementation, the connected domain in the second obstacle image is extracted by the flow steps shown in FIG. 7, including the following steps a1-a8. Figure 3 a1, creating a connected domain as a current connected domain.
[0067] a2, traversing to obtain a pixel in the second obstacle image as a third pixel.
[0068] a3, judging whether the pixel value of the third pixel is a foreground pixel value.
[0069] The foreground pixel value is the first pixel value or the second pixel value.
[0070] If the pixel value of the third pixel is the foreground pixel value, it indicates that the third pixel is foreground, and step a5 is performed; if the pixel value of the third pixel is not the foreground pixel value, it indicates that the third pixel is background, and step a4 is performed.
[0071] a4, traversing to obtain a pixel adjacent to the third pixel and not traversed as a third pixel, and step a3 is performed.
[0072] a5, adding the third pixel into the current connected domain, and step a6 is performed.
[0073] a6, traversing to obtain a pixel adjacent to the third pixel and not traversed as a fourth pixel.
[0074] a7, judging whether the pixel value of the fourth pixel is the same as the pixel value of the third pixel.
[0075] If the pixel value of the fourth pixel is the same as the pixel value of the third pixel, it means that the fourth pixel is foreground, and step a8 is performed; if the pixel value of the fourth pixel is different from the pixel value of the third pixel, it means that the fourth pixel is background, and step a9 is performed.
[0076] a8, the fourth pixel is taken as the third pixel, and step a5 is performed.
[0077] a9, a new connected domain is created as the current connected domain, and step a10 is performed.
[0078] a10, pixels adjacent to the fourth pixel and not traversed are traversed as the third pixel, and step a3 is performed.
[0079] If all the pixels adjacent to the fourth pixel have been traversed, the pixels not traversed in the second obstacle image are determined as the third pixel, and step a3 is performed until all the pixels in the second obstacle image are traversed.
[0080] Through the above steps a1-a10, all connected domains belonging to the foreground can be extracted.
[0081] It should be understood that the connected domains in the second obstacle image can also be extracted by other methods, which are not limited in the present application.
[0082] B4, according to the connected domains in the second obstacle image, the target obstacle region is determined.
[0083] In a possible implementation, in the case that the foreground in the second obstacle image represents the obstacle, for example, in the binary image, the default white color represents the foreground, and the extracted connected region is the white region in the binary image, the white region in the second obstacle image represents the obstacle, and the connected domain closest to the self-moving device in the second obstacle image can be determined as the target obstacle region.
[0084] In another possible implementation, in the case that the background in the second obstacle image represents the obstacle, for example, the default white color represents the foreground, and the extracted connected region is the white region in the binary image, the second obstacle image is as shown in P2 of FIG. 8, the black region represents the obstacle, the second obstacle image can be inverted to obtain a third obstacle image, the white region in the third obstacle image represents the obstacle, and the third obstacle image can be exemplarily as shown in P3 of FIG. 8; the connected domain closest to the self-moving device in the third obstacle image is determined as the target obstacle region. Inverting the second obstacle image to obtain the third obstacle image can realize the switching between the foreground and the background, and adapt to the algorithm requirement or processing requirement. Figure 4 Figure 3
[0085] In steps B1-B4, the first obstacle image with a pure color background is generated according to the obstacles in the navigation map, and the first obstacle is binarized and subjected to an opening operation to obtain the second obstacle image, so that the obstacles can be segmented from the image, and the connected domains in the second obstacle image are extracted, which is helpful to determine the obstacle region.
[0086] In some embodiments, a forbidden area can also be set in the navigation map according to the target obstacle region, where the forbidden area refers to an area in which the self-moving device is prohibited from entering; the forbidden area contains the target obstacle region, and the area of the forbidden area is greater than or equal to the area of the target obstacle region. After the target obstacle region is determined, the target obstacle region can be set as the forbidden area in the navigation map, or the target obstacle region can be inflated, and the inflated target obstacle region can be set as the forbidden area in the navigation map. The present application does not limit this.
[0087] Since the target obstacle region is usually a region corresponding to the obstacles surrounding the self-moving device, the forbidden area is set according to the target obstacle region, which can prevent the self-moving device from re-entering the narrow area surrounded by obstacles in the subsequent working process, and avoid the self-moving device from being trapped.
[0088] S1022, determining a target path point based on the target obstacle region.
[0089] The target path point is a path point outside the target obstacle region, and can be understood as a passable path point outside the target obstacle region.
[0090] In some embodiments, the target path point is determined by steps C1-C3 as follows: C1, determining a target rectangle according to the target obstacle region.
[0091] The target rectangle surrounds the target obstacle region, that is, the target obstacle region is located within the target rectangle, and the shortest distance between each side of the target rectangle and the target obstacle region is greater than a preset distance. For example, the preset distance is the distance corresponding to 2 grids. For example, if the side length of a grid is 5 cm, the preset distance is 10 cm.
[0092] In a feasible implementation, the target rectangle can be determined by steps C11-C12 as follows: C11, expanding the boundary of the target obstacle region outward so that the area corresponding to the expanded boundary is greater than the area of the target obstacle region.
[0093] The distance between a position point on the expanded boundary and a position point on the unexpanded boundary can be the preset distance.
[0094] Specifically, the target obstacle region can be dilated to expand the boundary of the target obstacle region outward, so that the area corresponding to the expanded boundary is greater than the area of the target obstacle region. For example, the target obstacle region can be dilated by 2 grids to expand the boundary of the target obstacle region outward.
[0095] C12, determining the minimum circumscribed rectangle of the expanded boundary as the target rectangle.
[0096] Specifically, the minimum circumscribed rectangle of the expanded boundary can be calculated, and the minimum circumscribed rectangle is determined as the target rectangle.
[0097] In the above steps C11-C12, the boundary of the target obstacle region is expanded outward, so that the area corresponding to the expanded boundary is greater than the area of the target obstacle region, which is beneficial to determine the non-obstacle region without obstacles, and further find the target path point for the self-moving device to escape.
[0098] C2, taking the midpoints of the two short sides of the target rectangle as two candidate path points.
[0099] The two short sides of the target rectangle refer to the two sides of the target rectangle with shorter lengths.
[0100] For example, the two candidate path points can be as shown by points p1 and p2 in P4 in FIG. 4. Figure 3
[0101] Optionally, before taking the midpoints of the two short sides of the target rectangle as two candidate path points, the density of obstacles in the target rectangle along the long side direction (hereinafter referred to as the first density) and the density of obstacles in the target rectangle along the short side direction (hereinafter referred to as the second density) can be compared. If the first density is greater than the second density, the midpoints of the two short sides of the target rectangle are taken as the two candidate path points. If the first density is less than the second density, the midpoints of the two long sides of the target rectangle can also be taken as the two candidate paths, and step C3 is performed. The moving direction of the self-moving device is determined based on the density of obstacles, which improves the possibility of the self-moving device escaping.
[0102] C3, determining the target path point from the two candidate path points.
[0103] In a possible implementation, any one of the two candidate path points can be determined as the target path point.
[0104] In another possible implementation, the candidate path point closest to the self-moving device is determined as the target path point from the two candidate path points. The candidate path point closest to the self-moving device is determined as the target path point, which is beneficial to the self-moving device to escape in the shortest time.
[0105] In the steps C1-C3, the target rectangle is determined, the area in the target rectangle except the target obstacle area is a non-obstacle area, and there is no obstacle in the non-obstacle area, the midpoint of the two short sides of the target rectangle is taken as two candidate path points, and the target path point is determined in the two candidate path points, which facilitates the straight movement of the self-moving device, thereby avoiding collision between the self-moving device and the obstacle in the obstacle area, and improving the possibility of the self-moving device escaping from the trap.
[0106] S1023, controlling the self-moving device to move to the target path point.
[0107] After the target path point is determined, the position of the self-moving device in the navigation map can be taken as a starting point, and the target path point can be taken as a navigation path point. A path planning algorithm is used to determine a movement path from the starting point to the navigation path point. The self-moving device moves to the target path point according to the movement path.
[0108] S103, entering an obstacle avoidance mode.
[0109] The obstacle avoidance mode is a mode for guiding the self-moving device to move to a path point on a movement route. The movement route refers to a route planned by the self-moving device based on a conventional obstacle avoidance principle. The path point on the movement route is set according to different obstacle conditions, so that the self-moving device can move around the obstacle.
[0110] In the obstacle avoidance mode, the self-moving device can detect whether there is an obstacle in front of the self-moving device. If there is no obstacle, a path point in front of the self-moving device is determined as a navigation path point, and the self-moving device is controlled to move to the navigation path point. If there is an obstacle, the posture of the self-moving device is adjusted so that the self-moving device faces a direction without an obstacle or with a distant obstacle. Then, a path point in front of the self-moving device after the posture adjustment is determined as a navigation path point, and the self-moving device is controlled to move to the navigation path point.
[0111] In the above Figure 3In the corresponding technical solution, in response to the triggering of a preset collision condition, it is determined whether the obstacles within the target detection range meet the preset navigation conditions. The preset navigation conditions include that the obstacles within the target detection range are distributed in at least three target locations of the self-moving device, and the included angle between the at least three target locations is greater than or equal to 90°. If the obstacles within the target detection range meet the preset navigation conditions, it indicates that the self-moving device is in a narrow area surrounded by obstacles, and enters the escape mode. The escape mode allows the self-moving device to navigate to the area outside the target obstacle closest to the self-moving device, thus enabling the self-moving device to leave the narrow area surrounded by obstacles and escape. If the obstacles within the target detection range do not meet the preset navigation conditions, it indicates that the self-moving device is in an area that can be moved in a normal manner, and enters the obstacle avoidance mode. The obstacle avoidance mode enables the self-moving device to navigate along a normal obstacle avoidance route, thus moving normally.
[0112] The method of this application has been described above; the apparatus of this application will be described below.
[0113] See Figure 1 , Figure 5 This is a schematic diagram of the structure of a navigation device provided in an embodiment of this application; as shown... Figure 5 As shown, the navigation device 20 includes: The condition judgment module 201 is used to determine whether the obstacles within the target detection range meet the preset navigation conditions in response to the triggering of the preset collision conditions. The target detection range is centered on the position of the self-moving device in the navigation map and is set based on the size of the self-moving device. The preset navigation conditions include: the obstacles within the target detection range are distributed in at least three target directions of the self-moving device, and the included angle between the at least three target directions is greater than or equal to 90°. Navigation module 202 is used to enter an escape mode if obstacles within the target detection range meet the preset navigation conditions. The escape mode refers to a mode that navigates to a path point outside the target obstacle area. The target obstacle area is the obstacle area closest to the self-moving device in the navigation map. The navigation module 202 is also used to enter an obstacle avoidance mode if the obstacles within the target detection range do not meet the preset navigation conditions. The obstacle avoidance mode refers to a mode that navigates to a path point on the movement route of the self-moving device.
[0114] It should be noted that the navigation device 20 described above can execute the navigation method provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the embodiments can be found in the navigation method provided in the embodiments of this application.
[0115] SeeFigure 5 , Figure 6 Figure 6 is a structural schematic diagram of a robot provided by an embodiment of the present application. The robot 30 comprises a processor 301 and a memory 302. The memory 302 is connected to the processor 301, for example, connected to the processor 301 through a bus.
[0116] The processor 301 is configured to support the robot 30 to perform the corresponding functions in the methods in the above method embodiments. The processor 301 can be a central processing unit (CPU), a network processor (NP), a hardware chip or any combination thereof. The above hardware chip can be an application specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The above PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0117] The memory 302 is used to store program codes and the like. The memory 302 can include a volatile memory (VM), for example, a random access memory (RAM); the memory 302 can also include a non-volatile memory (NVM), for example, a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory 302 can also include a combination of the above kinds of memories.
[0118] The memory 302 is used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the navigation method in the embodiments of the present application. The processor performs various functional applications and data processing of the navigation method by running the non-volatile software programs, instructions and modules stored in the memory, that is, realizes the functions of the navigation method provided by the above method embodiments.
[0119] The memory 302 can include a program storage area and a data storage area, where the program storage area can store an operating system, application programs required by at least one function. The data storage area can store data created according to the use of the navigation device, etc. In some embodiments, the memory can include a memory remotely arranged with respect to the processor, which can be connected to the navigation device through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0120] The one or more modules are stored in the memory and, when executed by the one or more processors, perform the navigation method in any of the above method embodiments, for example, perform the method steps described in the above method embodiments, and realize the functions of the modules described in the above device embodiments.
[0121] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, the computer program comprising program instructions, the program instructions causing a computer to perform the method described in the above embodiments when the computer executes the program instructions.
[0122] Those of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be completed by a computer program instructing related hardware, and the program can be stored in a computer readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The storage medium can be a magnetic disc, an optical disc, a read-only memory (ROM), a random access memory (RAM), or the like.
[0123] The above disclosure is merely preferred embodiments of the present application, and of course cannot limit the scope of the rights of the present application, therefore the equivalent changes made according to the claims of the present application still fall within the scope of the present application.
Claims
1. A navigation method characterized by, The method comprises: in response to a preset collision condition being triggered, determining whether an obstacle in a target detection range meets a preset navigation condition, the target detection range being centered on a position of the self-moving device in a navigation map and being set based on a size of the self-moving device, the preset navigation condition comprising: the obstacle in the target detection range being distributed in at least three target directions of the self-moving device, and an included angle between the at least three target directions being greater than or equal to 90°; if the obstacle in the target detection range meets the preset navigation condition, entering an escape mode, the escape mode being a mode of guiding navigation to a path point outside a target obstacle region, the target obstacle region being a region of an obstacle closest to the self-moving device in the navigation map; if the obstacle in the target detection range does not meet the preset navigation condition, entering an obstacle avoidance mode, the obstacle avoidance mode being a mode of guiding navigation to a path point on a movement route of the self-moving device.
2. The method of claim 1, wherein, The navigation map is a grid map. The method further comprises: determining whether the obstacle in the target detection range meets the preset navigation condition comprises: judging whether a grid in a target grid set exists an obstacle, the target grid set at least including four grids located in the target detection range, the four grids being a grid located at a left upper direction of the self-moving device in the navigation map, a grid located at a right upper direction of the self-moving device in the navigation map, a grid located at a left lower direction of the self-moving device in the navigation map, and a grid located at a right lower direction of the self-moving device in the navigation map; in a case where the obstacle exists in at least three of the four grids, determining that the obstacle in the target detection range meets the preset navigation condition; 3. The method of claim 1, wherein, in a case where the obstacle exists in less than three of the four grids, determining that the obstacle in the target detection range does not meet the preset navigation condition. The method further comprises: entering the escape mode comprises:
4. The method of claim 3, wherein, determining the target obstacle region; based on the target obstacle region, determining a target path point and controlling the self-moving device to move to the target path point, wherein the target path point is a path point outside the target obstacle region. The method further comprises: based on the target obstacle region, determining a target path point comprises:
5. The method of claim 4, wherein, determining a target rectangle according to the target obstacle region, the target rectangle surrounding the target obstacle region, and a shortest distance between each side of the target rectangle and the target obstacle region being greater than a preset distance; taking a midpoint of two short sides of the target rectangle as two candidate path points; 6. The method of claim 4, wherein, determining a target path point from the two candidate path points. The method further comprises: from the two candidate path points, determining a target path point comprises: from the two candidate path points, determining a candidate path point closest to the self-moving device as the target path point. The method further comprises: determining a target rectangle according to the target obstacle region comprises: extending a boundary of the target obstacle region outward, so that an area corresponding to the extended boundary is greater than an area of the target obstacle region; An outer rectangle of the extended boundary is determined as a target rectangle.
7. The method of claim 3, wherein, The determining the target obstacle region comprises: generating a first obstacle image according to obstacles in the navigation map, the first obstacle image comprising all obstacles in the navigation map, the first obstacle image having the same size as the navigation map, and a background region in the first obstacle image other than obstacles being a solid color region; performing binaryzation and opening operation on the first obstacle image to obtain a second obstacle image; extracting a connected domain in the second obstacle image; determining the target obstacle region according to the connected domain in the second obstacle image.
8. The method of claim 7, wherein, The determining the target obstacle region according to the connected domain in the second obstacle image comprises: performing negation on the second obstacle image to obtain a third obstacle image; determining a connected domain closest to the self-moving device in the third obstacle image as the target obstacle region.
9. The method according to any one of claims 1 to 8, characterized in that, The method further comprises: setting a forbidden zone in the navigation map according to the target obstacle region, wherein the forbidden zone contains the target obstacle region, and an area of the forbidden zone is greater than or equal to an area of the target obstacle region.
10. A navigation device characterized by comprises: a condition judging module configured to determine whether obstacles in a target detection range meet a preset navigation condition in response to a preset collision condition being triggered, the target detection range being centered at a position of the self-moving device in a navigation map and being set based on a size of the self-moving device, and the preset navigation condition comprising that the obstacles in the target detection range are distributed in at least three target directions of the self-moving device, and an included angle between the at least three target directions is greater than or equal to 90°; a navigation module configured to enter an escape mode if the obstacles in the target detection range meet the preset navigation condition, the escape mode being a mode of guiding navigation to a path point outside a target obstacle region, the target obstacle region being an obstacle region closest to the self-moving device in the navigation map; the navigation module is further configured to enter an obstacle avoidance mode if the obstacles in the target detection range do not meet the preset navigation condition, the obstacle avoidance mode being a mode of guiding navigation to a path point on a moving route of the self-moving device.
11. A robot, characterized in that The robot comprises a memory and a processor, the memory being connected to the processor, the processor being configured to execute one or more computer programs stored in the memory, and the processor, when executing the one or more computer programs, causing the robot to implement the method according to any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, the computer program comprising program instructions, the program instructions, when executed by a processor, causing the processor to execute the method according to any one of claims 1-9.