Disclosure of Invention
In order to solve the problems, the application provides a robot curve virtual wall implementation method based on a grid map, and the application provides a curve virtual wall mathematical model, wherein the curve virtual wall form supports a continuous function curve, the virtual wall with the curve form can be set according to a real environment, the application range of the method for realizing the virtual wall by an application software algorithm is improved, and the application range is wide. The specific technical scheme of the application is as follows:
a robot curve virtual wall implementation method based on a grid map comprises the following steps: s1: the robot sets a curve virtual wall based on the constructed grid map; s2: the robot builds a mathematical model on the curve virtual wall; s3: converting the grid coordinates of the current position into model coordinates of a mathematical model by the robot; s4: and the robot determines the states of the robot and the virtual wall according to the model coordinates. The robot can set the curve virtual wall according to the actual environment, so that the setting of the virtual wall is more flexible; the corresponding mathematical model is set according to the curve virtual wall, and the model can support continuous function curves and has high realization and functionality.
Further, in step S1, the robot setting a curved virtual wall based on the constructed grid map includes the steps of: the intelligent mobile terminal receives map information constructed by the robot and displays the map information through a screen; the intelligent mobile terminal detects a signal for setting a virtual wall and converts a touch signal on a screen into the virtual wall to be displayed in a map shown on the screen; and the intelligent mobile terminal transmits the map information provided with the virtual wall to the robot. The virtual wall information is displayed through the intelligent mobile terminal, so that the set virtual wall is simpler and more convenient to operate.
Further, in step S2, the robot builds a mathematical model comprising the steps of: the robot converts the curve virtual wall into a scattered point curve of the grid map; translating the center point of the scattered point curve to the origin of the coordinate system by taking the center point of the scattered point curve as a reference point, and rotating the scattered point curve to enable points on the scattered point curve to be distributed on two sides of an X axis; and translating the scattered point curve forward and backward along the Y axis by a preset value to divide the areas at two sides of the scattered point curve. The virtual wall is transformed into the scattered point curve to set the mathematical model, so that the robot can calculate conveniently.
Further, the robot dividing the area at both sides of the scatter curve comprises the following steps: the scattered point curves are translated forward and backward along the Y axis by a first preset value to form a touch area, and the virtual wall is positioned at the center of the touch area; the scattered point curves forward and backward translate a second preset value basic unit along the Y axis, and the scattered point curves after the second translation and the scattered point curves after the first translation on the same side form an early warning area respectively, so that the early warning areas are distributed on two sides of the touch area; setting the areas except the early warning area and the touch area as a safety area; the scattered point curve after the first translation comprises a first forward scattered point curve and a first reverse scattered point curve, the scattered point curve after the second translation comprises a second forward scattered point curve and a second reverse scattered point curve, and the second preset value is larger than the first preset value. Corresponding areas can be constructed through simple forward translation and reverse translation, operation data are less, and the operation speed of the robot is improved.
Further, in step S3, the robot converting the grid coordinates of the current position into model coordinates of the mathematical model includes the steps of: the robot determines grid coordinates of the current position of the robot, and translates and rotates the grid coordinates of the current position corresponding to the virtual wall to obtain model coordinates based on a mathematical model. The grid coordinates of the robot can be converted into corresponding mathematical model coordinates through simple translation, and the operation is simple and convenient.
Further, in step S4, the robot determining the states of itself and the virtual wall according to the model coordinates includes the following steps: the robot compares the model coordinates with the coordinates of corresponding scattered points of the scattered point curve after translation, determines whether the robot is in a safe area, an early warning area or a touch area on the mathematical model according to the comparison result, and if the robot is in the safe area, the robot judges that the robot and the virtual wall are in a safe state; if the robot is in the early warning area, the robot judges that the state of the robot and the virtual wall is in a close state; if the robot is in the touch area, the robot judges that the state of the robot and the virtual wall is a touch state; the translated scatter point curves comprise a first forward scatter point curve, a first reverse scatter point curve, a second forward scatter point curve and a second reverse scatter point curve. The state of the robot and the virtual wall is judged by the position of the robot in the mathematical model, so that the robot can conveniently set corresponding actions aiming at the state of the robot and the virtual wall.
Further, the robot comparing the model coordinates with coordinates of corresponding scattered points of the shifted scattered point curve comprises the following steps: making a straight line perpendicular to the X axis by passing through the model coordinates; if the straight line is not intersected with the translated scattered point curve, judging that the robot is in a safe area; if the straight line intersects with the translated scattered point curve, comparing the model coordinate with the Y-axis coordinate of the intersection point of the straight line and the translated scattered point curve; if the Y-axis coordinate of the model coordinate is larger than the Y-axis coordinate of the intersection point of the straight line and the second forward scattered point curve or smaller than the Y-axis coordinate of the intersection point of the straight line and the second reverse scattered point curve, judging that the robot is in a safety area; if the Y-axis coordinate of the model coordinate is larger than the Y-axis coordinate of the intersection point of the straight line and the first forward scattered point curve and smaller than the Y-axis coordinate of the intersection point of the straight line and the second forward scattered point curve, or smaller than the Y-axis coordinate of the intersection point of the straight line and the first reverse scattered point curve and larger than the Y-axis coordinate of the intersection point of the straight line and the second reverse scattered point curve, judging that the robot is in the early warning area; and if the Y-axis coordinate of the model coordinate is smaller than the Y-axis coordinate of the intersection point of the straight line and the first forward scatter curve and is larger than the Y-axis coordinate of the intersection point of the straight line and the first forward scatter curve, judging that the robot is in the early warning area.
Further, the robot determining coordinates of the straight line and the translated scatter curve comprises the following steps: determining coordinates of scattered points with the same X-axis coordinates as the model coordinates on a virtual wall in the mathematical model; the Y-axis coordinate of the intersection point of the straight line and the first forward scattered point curve is that the Y-axis coordinate of the scattered point is added with a first preset value; the Y-axis coordinate of the intersection point of the straight line and the first reverse scattered point curve is obtained by subtracting a first preset value from the Y-axis coordinate of the scattered point; the Y-axis coordinate of the intersection point of the straight line and the second positive scattered point curve is that the Y-axis coordinate of the scattered point is added with a second preset value; the Y-axis coordinate of the intersection of the straight line and the second reverse scatter plot is the Y-axis coordinate of the scatter minus a second preset value. The Y-axis coordinates of the scattered points used for comparison of the corresponding translated scattered point curves can be obtained through simple addition and subtraction conversion, so that the calculated data are less, and the operation speed of the robot is improved.
Further, if the robot determines that the robot is in the touch area, the robot moves to the nearest warning area.
Further, if the robot judges that the robot is in the early warning area, the robot continues to work and detects the position of the robot in real time. The robot performs corresponding operation according to actual conditions, so that the flexibility of the robot is improved.
Detailed Description
The following describes the technical solution in the embodiment of the present invention in detail with reference to the drawings in the embodiment of the present invention. It should be understood that the following detailed description is merely illustrative of the invention, and is not intended to limit the invention.
As shown in fig. 1, a method for realizing a robot curve virtual wall based on a grid map comprises the following steps: s1: the robot sets a curve virtual wall based on the constructed grid map; s2: the robot builds a mathematical model on the curve virtual wall; s3: converting the grid coordinates of the current position into model coordinates of a mathematical model by the robot; s4: and the robot determines the states of the robot and the virtual wall according to the model coordinates. The robot can set the curve virtual wall according to the actual environment, so that the setting of the virtual wall is more flexible; the corresponding mathematical model is set according to the curve virtual wall, and the model can support continuous function curves and has high realization and functionality. The execution subject of the method is a processor or a control chip of the robot, which is directly described as the robot for convenience of description. The robot may be a sweeping robot, a floor washing robot, an air purifying robot, a logistics robot, a weeding robot, a business service robot, or the like. First, the robot sets a virtual wall based on a map constructed when the robot walks by itself. The constructed map can be a grid map, a lattice map, a color block map or other types of maps, and can reflect the current environment condition of the robot. The embodiments of the invention are described by taking a grid map as an example. The virtual wall can be set in different modes, for example, the robot is controlled to walk once at the position where the virtual wall is required to be set, the coordinate positions and directions of the robot during walking are recorded, the coordinate positions are marked as virtual barrier units, and the virtual barrier units form the virtual wall. The virtual obstacle unit is a grid unit through which the robot can walk normally in practice, but cannot walk when walking according to map navigation. Or the user directly operates on the display terminal of the map, and marks the corresponding grid unit at the corresponding position in a mouse or touch mode, namely the grid unit marked as the virtual wall. The grid unit is the smallest unit cell constituting the grid map, and the robot sets a curved virtual wall based on the constructed grid map, comprising the steps of: the intelligent mobile terminal receives map information constructed by the robot and displays the map information through a screen; the intelligent mobile terminal detects a signal for setting a virtual wall and converts a touch signal on a screen into the virtual wall to be displayed in a map shown on the screen; and the intelligent mobile terminal transmits the map information provided with the virtual wall to the robot. The virtual wall information is displayed through the intelligent mobile terminal, so that the set virtual wall is simpler and more convenient to operate.
Further, in step S2, the robot builds a mathematical model comprising the steps of: the robot converts the curve virtual wall into a scattered point curve of the grid map; translating the center point of the scattered point curve to the origin of the coordinate system by taking the center point of the scattered point curve as a reference point, and rotating the scattered point curve to enable points on the scattered point curve to be distributed on two sides of an X axis; and translating the scattered point curve forward and backward along the Y axis by a preset value to divide the areas at two sides of the scattered point curve. The virtual wall is transformed into the scattered point curve to set the mathematical model, so that the robot can calculate conveniently. The robot divides the areas at the two sides of the scattered point curve, and comprises the following steps: the scattered point curves are translated forward and backward along the Y axis by a first preset value to form a touch area, and the virtual wall is positioned at the center of the touch area; the scattered point curves forward and backward translate a second preset value basic unit along the Y axis, and the scattered point curves after the second translation and the scattered point curves after the first translation on the same side form an early warning area respectively, so that the early warning areas are distributed on two sides of the touch area; setting the areas except the early warning area and the touch area as a safety area; the scattered point curve after the first translation comprises a first forward scattered point curve and a first reverse scattered point curve, the scattered point curve after the second translation comprises a second forward scattered point curve and a second reverse scattered point curve, and the second preset value is larger than the first preset value. Corresponding areas can be constructed through simple forward translation and reverse translation, operation data are less, and the operation speed of the robot is improved. In step S3, the robot converting the grid coordinates of the current position into model coordinates of a mathematical model includes the steps of: the robot determines grid coordinates of the current position of the robot, and translates and rotates the grid coordinates of the current position corresponding to the virtual wall to obtain model coordinates based on a mathematical model. The grid coordinates of the robot can be converted into corresponding mathematical model coordinates through simple translation, and the operation is simple and convenient.
Further, in step S4, the robot determining the states of itself and the virtual wall according to the model coordinates includes the following steps: the robot compares the model coordinates with the coordinates of corresponding scattered points of the scattered point curve after translation, determines whether the robot is in a safe area, an early warning area or a touch area on the mathematical model according to the comparison result, and if the robot is in the safe area, the robot judges that the robot and the virtual wall are in a safe state; if the robot is in the early warning area, the robot judges that the state of the robot and the virtual wall is in a close state; if the robot is in the touch area, the robot judges that the state of the robot and the virtual wall is a touch state; the translated scatter point curves comprise a first forward scatter point curve, a first reverse scatter point curve, a second forward scatter point curve and a second reverse scatter point curve. The state of the robot and the virtual wall is judged by the position of the robot in the mathematical model, so that the robot can conveniently set corresponding actions aiming at the state of the robot and the virtual wall. The robot comparing the model coordinates with the coordinates of the corresponding scattered points of the shifted scattered point curve comprises the following steps: making a straight line perpendicular to the X axis by passing through the model coordinates; if the straight line is not intersected with the translated scattered point curve, judging that the robot is in a safe area; if the straight line intersects with the translated scattered point curve, comparing the model coordinate with the Y-axis coordinate of the intersection point of the straight line and the translated scattered point curve; if the Y-axis coordinate of the model coordinate is larger than the Y-axis coordinate of the intersection point of the straight line and the second forward scattered point curve or smaller than the Y-axis coordinate of the intersection point of the straight line and the second reverse scattered point curve, judging that the robot is in a safety area; if the Y-axis coordinate of the model coordinate is larger than the Y-axis coordinate of the intersection point of the straight line and the first forward scattered point curve and smaller than the Y-axis coordinate of the intersection point of the straight line and the second forward scattered point curve, or smaller than the Y-axis coordinate of the intersection point of the straight line and the first reverse scattered point curve and larger than the Y-axis coordinate of the intersection point of the straight line and the second reverse scattered point curve, judging that the robot is in the early warning area; and if the Y-axis coordinate of the model coordinate is smaller than the Y-axis coordinate of the intersection point of the straight line and the first forward scatter curve and is larger than the Y-axis coordinate of the intersection point of the straight line and the first forward scatter curve, judging that the robot is in the early warning area. The robot determining the coordinates of the straight line and the translated scattered point curve comprises the following steps: determining coordinates of scattered points with the same X-axis coordinates as the model coordinates on a virtual wall in the mathematical model; the Y-axis coordinate of the intersection point of the straight line and the first forward scattered point curve is that the Y-axis coordinate of the scattered point is added with a first preset value; the Y-axis coordinate of the intersection point of the straight line and the first reverse scattered point curve is obtained by subtracting a first preset value from the Y-axis coordinate of the scattered point; the Y-axis coordinate of the intersection point of the straight line and the second positive scattered point curve is that the Y-axis coordinate of the scattered point is added with a second preset value; the Y-axis coordinate of the intersection of the straight line and the second reverse scatter plot is the Y-axis coordinate of the scatter minus a second preset value. The Y-axis coordinates of the scattered points used for comparison of the corresponding translated scattered point curves can be obtained through simple addition and subtraction conversion, so that the calculated data are less, and the operation speed of the robot is improved. If the robot judges that the robot is in the touch area, the robot moves to the nearest early warning area. If the robot judges that the robot is in the early warning area, the robot continues to work and detects the position of the robot in real time. The robot performs corresponding operation according to actual conditions, so that the flexibility of the robot is improved.
As shown in fig. 2, fig. 2 is a mathematical model constructed on a curve virtual wall by a robot, wherein L is a scatter curve of a grid map converted by the curve virtual wall, I is a first forward scatter curve of the grid map obtained by forward translating m basic units along the Y axis, I 'is a first reverse scatter curve of the grid map obtained by forward translating m basic units along the Y axis, U is a second forward scatter curve of the grid map obtained by forward translating n basic units along the Y axis, U' is a second reverse scatter curve of the grid map obtained by forward translating n basic units along the Y axis, n > m, and a region 2 'surrounded by U and I is an early warning region, and a region 1 surrounded by I and I' is a touch region. When judging the position of the robot, setting the current position of the robot as a point G (X, Y), and in a curve virtual wall relative coordinate system, making a straight line Q perpendicular to an X-axis by the current point G, and judging that the robot is in a safety area if the straight line Q has no intersection point with U, I, I 'and U'. If the straight line Q intersects U, I, I 'and U' at A, B, C, D with the scatter curves U, I, I 'and U', respectively, the following is determined: y > YA or Y < YD, the machine is not in any area, and the robot is judged to be in a safe area; y > YB ∈Y < YA, the robot is in the area 2, or Y > YD ∈Y < YC, the robot is in the area 2', and the robot is judged to be in the early warning area; y > YC ∈Y < YB, the robot is in region 1, and the robot is in the touch region. The states of the robot and the virtual wall can be represented by numbers when the robot is in different areas, for example, the robot is in an area 2, and the state of the robot is 1; the robot is in the area 2', and the state of the robot is-1; the robot is not in zones 1, 2 and 2', robot state is 2; in the area 1, the robot enters the area 1 from the area 2', and the robot enters the area-1. After the robot enters the area 1, judging that the virtual wall is triggered, and if the robot triggers the virtual wall, if the state is 1, the robot evading direction is the area 2; if the robot triggers a virtual wall, the state is-1, and the robot evading direction is area 2'. If the state of the robot changes from 1 to-1 or-1 to 1, it can be judged that the robot passes through the virtual wall, and the robot can return through the point G calculated in the area 2 or the area 2'.
It is obvious that the above-mentioned embodiments are only some embodiments of the present invention, but not all embodiments, and that the technical solutions of the embodiments may be combined with each other. Furthermore, if terms such as "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are used in the embodiments, the indicated orientation or positional relationship is based on that shown in the drawings, only for convenience in describing the present invention and simplifying the description, and does not indicate or imply that the indicated apparatus or element must have a specific orientation or be constructed and operated in a specific orientation, and thus should not be construed as limiting the present invention. If the terms "first," "second," "third," etc. are used in an embodiment to facilitate distinguishing between related features, they are not to be construed as indicating or implying a relative importance, order, or number of technical features.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. These programs may be stored in a computer readable storage medium (such as ROM, RAM, magnetic or optical disk, etc. various media that can store program codes). The program, when executed, performs steps including the method embodiments described above.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.