Dynamic edge path generation method, computer device, and storage medium
A dynamic edge path generation method includes: obtaining a static edge path; obtaining dynamic sensing information in real time, the dynamic sensing information comprising a device position and an obstacle edge; cutting out a preset length of path segment from the static edge path on the basis of the device position, and fitting path points contained in the path segment to obtain a fitted curve; determining, on the basis of the fitted curve and the obstacle edge, a moving direction corresponding to each fitted sampling point in the fitted curve; moving each fitted sampling point by a preset distance at least once on the basis of the corresponding moving direction so as to obtain each corresponding target path point; and obtaining a dynamic edge path on the basis of the target path points.
1 . A dynamic edge path generation method for controlling movement of a robot, comprising:
obtaining a static edge path from a server, the static edge path comprising a plurality of path points;
obtaining dynamic sensing information of the robot through an auxiliary device in real-time, the dynamic sensing information comprising a position of the robot and an edge of an obstacle;
cutting out, based on the position of the robot, a path segment of a preset length from the static edge path, and fitting the path points contained in the path segment to obtain a fitted curve;
determining, based on the fitted curve and the edge of the obstacle, moving directions respectively corresponding to fitted sampling points in the fitted curve;
moving, based on the corresponding moving direction, each of the fitted sampling points by a preset distance at least once, to obtain target path points respectively corresponding to the fitted sampling points; and
obtaining, based on the target path points, a dynamic edge path, wherein the robot is controlled based on the dynamic edge path, and adjusting the static edge path in real time based on the obtained dynamic sensing information which avoids the obstacle and makes the obtained dynamic edge path fit the edge of the obstacle;
wherein the dynamic sensing information further comprises an obstacle coverage region, and moving, based on the corresponding moving direction, each of the fitted sampling points by the preset distance at least once, to obtain target path points respectively corresponding to the fitted sampling points, comprises:
moving, based on the corresponding moving direction, each of the fitted sampling points by the preset distance, to obtain a corresponding reference path point; and
moving, in a case that there is no overlapping region between a pre-coverage region of the reference path point and the obstacle coverage region, the reference path point based on the corresponding moving direction and the preset distance again until there is an overlapping region between the pre-coverage region of the corresponding reference path point and the obstacle coverage region, and taking the corresponding reference path point obtained in previous movement as the corresponding target path point, the pre-coverage region of the reference path point being determined based on the reference path point and a coverage region of the robot.
2 . The method according to claim 1 , wherein cutting out, based on the position of the robot, the path segment of the preset length from the static edge path, and fitting the path points contained in the path segment to obtain the fitted curve, comprises:
calculating a distance from each of the path points in the static edge path to the position of the robot, and taking the path point closest to the position of the robot as a first path point to be fitted;
calculating, based on the first path point to be fitted, distances between two adjacent path points, respectively, accumulating the distances to obtain a cumulative length, and taking the path points contained in the cumulative length that is equal to the preset length as path points to be fitted; and
performing a fitting calculation on the path points to be fitted to obtain a fitting parameter, and obtaining, based on the fitting parameter, the fitted curve.
3 . The method according to claim 1 , wherein determining, based on the fitted curve and the edge of the obstacle, the moving directions respectively corresponding to the fitted sampling points in the fitted curve, comprises:
sampling the fitted curve at a preset sampling distance, to obtain a plurality of fitted sampling points;
calculating a distance from each of the fitted sampling points to the position of the robot, and taking the fitted sampling point closest to the position of the robot as a target fitted sampling point;
obtaining, from the edge of the obstacle, an edge point closest to the target fitted sampling point as a reference point;
determining, based on a vertical direction of a tangent line of the target fitted sampling point in the fitted curve, a vertical displacement of the reference point relative to the target fitted sampling point;
determining, based on the vertical displacement, a reference direction of a movement of each of the fitted sampling points; and
determining, based on the reference direction and tangential directions of the fitted sampling points on the fitted curve, the moving directions respectively corresponding to the fitted sampling points.
4 . The method according to claim 3 , wherein determining, based on the vertical displacement, the reference direction of the movement of each of the fitted sampling points, comprises:
determining, if the vertical displacement is greater than zero, the reference direction of 90 degrees; and determining, if the vertical displacement is less than zero, the reference direction of negative 90 degrees.
5 . The method according to claim 3 , wherein determining, based on the reference direction and the tangential direction of each of the fitted sampling points on the fitted curve, the moving directions respectively corresponding to the fitted sampling points, comprises:
determining, based on the fitted curve, the tangential directions of the fitted sampling points on the fitted curve through a direction operation, respectively; and
fusing the tangential directions of the fitted sampling points on the fitted curve with the reference direction, to obtain the moving directions respectively corresponding to the fitted sampling points.
6 . The method according to claim 1 , further comprising:
obtaining a size of the robot; and
obtaining, based on the reference path point and the size, the pre-coverage region where a geometric center of the robot is located at the reference path point.
7 . The method according to claim 1 , wherein in the case that there is no overlapping region between the pre-coverage region of the reference path point and the obstacle coverage region, the method comprises:
obtaining the pre-coverage region of the reference path point, the pre-coverage region being represented by a two-dimensional coordinate point set;
obtaining the obstacle coverage region, the obstacle coverage region being represented by a two-dimensional coordinate point set;
performing an intersection operation on the two-dimensional coordinate point set of the pre-coverage region and the two-dimensional coordinate point set of the obstacle coverage region, to obtain an intersection result; and
determining, if the intersection result is an empty set, that the pre-coverage region does not overlap with the obstacle coverage region.
8 . The method according to claim 1 , wherein obtaining the static edge path comprises:
obtaining an initial map of an operation region;
performing a dilation process and an erosion process on the initial map, to obtain a target image; and
obtaining, based on the target image, the static edge path.
9 . A computer device comprising a processor and a memory having a computer program stored therein, wherein the computer device is a robot, wherein the processor, when executing the computer program, implements:
obtaining a static edge path from a server, the static edge path comprising a plurality of path points;
obtaining dynamic sensing information of the robot through an auxiliary device in real-time, the dynamic sensing information comprising a position of the robot and an edge of an obstacle;
cutting out, based on the position of the robot, a path segment of a preset length from the static edge path, and fitting the path points contained in the path segment to obtain a fitted curve;
determining, based on the fitted curve and the edge of the obstacle, moving directions respectively corresponding to fitted sampling points in the fitted curve;
moving, based on the corresponding moving direction, each of the fitted sampling points by a preset distance at least once, to obtain target path points respectively corresponding to the fitted sampling points; and
obtaining, based on the target path points, a dynamic edge path, wherein the robot is controlled based on the dynamic edge path, and adjusting the static edge path in real time based on the obtained dynamic sensing information which avoids the obstacle and makes the obtained dynamic edge path fit the edge of the obstacle;
wherein the processor, when executing the computer program, further implements:
moving, based on the corresponding moving direction, each of the fitted sampling points by the preset distance, to obtain a corresponding reference path point; and
moving, in a case that there is no overlapping region between a pre-coverage region of the reference path point and the obstacle coverage region, the reference path point based on the corresponding moving direction and the preset distance again until there is an overlapping region between the pre-coverage region of the corresponding reference path point and the obstacle coverage region, and taking the corresponding reference path point obtained in previous movement as the corresponding target path point, the pre-coverage region of the reference path point being determined based on the reference path point and a coverage region of the robot.
10 . A non-transitory computer-readable storage medium having a computer program stored therein, wherein the non-transitory computer-readable storage medium implemented into a robot, wherein the computer program, when executed by a processor, causes the processor to:
obtain a static edge path from a server, the static edge path comprising a plurality of path points;
obtain dynamic sensing information of the robot through an auxiliary device in real-time, the dynamic sensing information comprising a position of the robot and an edge of an obstacle;
cut out, based on the position of the robot, a path segment of a preset length from the static edge path, and fit the path points contained in the path segment to obtain a fitted curve;
determine, based on the fitted curve and the edge of the obstacle, moving directions respectively corresponding to fitted sampling points in the fitted curve;
move, based on the corresponding moving direction, each of the fitted sampling points by a preset distance at least once, to obtain target path points respectively corresponding to the fitted sampling points; and
obtain, based on the target path points, a dynamic edge path, wherein the robot is controlled based on the dynamic edge path, and adjusting the static edge path in real time based on the obtained dynamic sensing information which avoids the obstacle and makes the obtained dynamic edge path fit the edge of the obstacle;
wherein the computer program, when executed by a processor, further causes the processor to:
move, based on the corresponding moving direction, each of the fitted sampling points by the preset distance, to obtain a corresponding reference path point; and
move, in a case that there is no overlapping region between a pre-coverage region of the reference path point and the obstacle coverage region, the reference path point based on the corresponding moving direction and the preset distance again until there is an overlapping region between the pre-coverage region of the corresponding reference path point and the obstacle coverage region, and taking the corresponding reference path point obtained in previous movement as the corresponding target path point, the pre-coverage region of the reference path point being determined based on the reference path point and a coverage region of the robot.
11 . The computer device according to 9 , wherein the processor, when executing the computer program, further implements:
calculating a distance from each of the path points in the static edge path to the position of the robot, and taking the path point closest to the position of the robot as a first path point to be fitted;
calculating, based on the first path point to be fitted, distances between two adjacent path points, respectively, accumulating the distances to obtain a cumulative length, and taking the path points contained in the cumulative length that is equal to the preset length as path points to be fitted; and
performing a fitting calculation on the path points to be fitted to obtain a fitting parameter, and obtaining, based on the fitting parameter, the fitted curve.
12 . The computer device according to 9 , wherein the processor, when executing the computer program, further implements:
sampling the fitted curve at a preset sampling distance, to obtain a plurality of fitted sampling points;
calculating a distance from each of the fitted sampling points to the position of the robot, and taking the fitted sampling point closest to the position of the robot as a target fitted sampling point;
obtaining, from the edge of the obstacle, an edge point closest to the target fitted sampling point as a reference point;
determining, based on a vertical direction of a tangent line of the target fitted sampling point in the fitted curve, a vertical displacement of the reference point relative to the target fitted sampling point;
determining, based on the vertical displacement, a reference direction of a movement of each of the fitted sampling points; and
determining, based on the reference direction and tangential directions of the fitted sampling points on the fitted curve, the moving directions respectively corresponding to the fitted sampling points.
13 . The computer device according to claim 12 , wherein the processor, when executing the computer program, further implements:
determining, if the vertical displacement is greater than zero, the reference direction of 90 degrees; and determining, if the vertical displacement is less than zero, the reference direction of negative 90 degrees.
14 . The computer device according to claim 12 , wherein the processor, when executing the computer program, further implements:
determining, based on the fitted curve, the tangential directions of the fitted sampling points on the fitted curve through a direction operation, respectively; and
fusing the tangential directions of the fitted sampling points on the fitted curve with the reference direction, to obtain the moving directions respectively corresponding to the fitted sampling points.
15 . The computer device according to 9 , wherein the processor, when executing the computer program, further implements:
obtaining a size of the robot; and
obtaining, based on the reference path point and the size, the pre-coverage region where a geometric center of the robot is located at the reference path point.
16 . The computer device according to claim 9 , wherein the processor, when executing the computer program, further implements:
obtaining the pre-coverage region of the reference path point, the pre-coverage region being represented by a two-dimensional coordinate point set;
obtaining the obstacle coverage region, the obstacle coverage region being represented by a two-dimensional coordinate point set;
performing an intersection operation on the two-dimensional coordinate point set of the pre-coverage region and the two-dimensional coordinate point set of the obstacle coverage region, to obtain an intersection result; and
determining, if the intersection result is an empty set, that the pre-coverage region does not overlap with the obstacle coverage region.
17 . The computer device according to claim 9 , wherein the processor, when executing the computer program, further implements:
obtaining an initial map of an operation region;
performing a dilation process and an erosion process on the initial map, to obtain a target image; and
obtaining, based on the target image, the static edge path.
18 . The non-transitory computer-readable storage medium according to claim 10 , wherein the computer program, when executed by a processor, further causes the processor to:
calculate a distance from each of the path points in the static edge path to the position of the robot, and take the path point closest to the position of the robot as a first path point to be fitted;
calculate, based on the first path point to be fitted, distances between two adjacent path points, respectively, accumulate the distances to obtain a cumulative length, and take the path points contained in the cumulative length that is equal to the preset length as path points to be fitted; and
perform a fitting calculation on the path points to be fitted to obtain a fitting parameter, and obtain, based on the fitting parameter, the fitted curve.