Unmanned aerial vehicle obstacle avoidance route generation method based on monocular camera
Through the obstacle avoidance route generation method based on the monocular camera, using the improved Monodepth2 model and detection head network, the problem of large equipment limitations in the existing technology is solved, and the environment perception and obstacle avoidance capabilities of the UAV are realized, which is suitable for small Drones reduce costs.
Patent Information
- Application Number
- CN202410443040.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-12
- Publication Date
- 2024-08-23
AI Technical Summary
Existing UAV obstacle avoidance technology has great limitations on equipment. The method based on lidar is high in cost and the equipment scale is too large. The method based on binocular cameras is computationally intensive and has limited scope of application, making it difficult to apply to small UAVs.
The obstacle avoidance route generation method based on the monocular camera is adopted, and the improved Monodepth2 model and detection head network are used to obtain the video in real time for depth map and obstacle position information inference to generate the obstacle avoidance direction and obstacle avoidance distance of the UAV, forming Obstacle avoidance route.
It realizes the environment perception and obstacle avoidance capabilities of the drone during autonomous flight, reduces equipment restrictions and costs, and makes it more widely applicable.
Smart Images

Figure CN118534937A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of unmanned aerial vehicle obstacle avoidance, and in particular to a method for generating an unmanned aerial vehicle obstacle avoidance route based on a monocular camera. Background Art
[0002] In order to ensure the safe operation of the power system, transmission lines need to be inspected regularly. The traditional manual inspection method is inefficient and costly, and can no longer meet today's inspection needs. In order to solve this problem, more and more power grid companies are using drones to replace manual inspections of transmission lines. Combined with certain image processing technologies, drones can effectively give full play to their flexible and intelligent characteristics, and then clearly capture and determine whether the lines in the image are faulty. Using drones for transmission line inspections has the advantages of low cost, easy operation, and accurate capture of equipment and line faults.
[0003] Since most power transmission lines are located in complex environments, and drone inspections often require drones to fly at low altitudes, drones must have autonomous obstacle avoidance capabilities to avoid collisions with poles and tree obstacles on the inspection route. Existing technologies mainly use laser radar or binocular cameras to obtain information about the surrounding environment, and then generate obstacle avoidance routes based on this information to achieve autonomous obstacle avoidance for drones. Among them, the laser radar-based method uses laser ranging to generate a three-dimensional point cloud to reconstruct the surrounding environment, and then establish an obstacle avoidance model; the binocular camera-based method matches the feature points of the images of the left and right cameras, and directly obtains the depth information of the obstacle based on the principle of triangulation, and then generates an obstacle avoidance route.
[0004] Existing technologies can assist drone flights in different application environments. However, they have great limitations on drone equipment and a small scope of application: the lidar-based method is costly, and the equipment is too large and heavy, making it less suitable for small patrol drones. The binocular camera-based method is limited by the baseline length, which makes it impossible for some drones to carry binocular cameras for effective ranging. On the other hand, the binocular ranging algorithm has a large amount of computation and requires high computing power from edge computing devices. Summary of the invention
[0005] To solve the above problems, the present invention proposes a method for generating an obstacle avoidance route for a UAV based on a monocular camera based on a depth estimation model and an image processing algorithm. Compared with the prior art, this method has less restrictions on UAV equipment and only requires a front monocular camera and a lightweight edge computing device. It is suitable for most current UAVs and has a wider range of applications.
[0006] The technical solution adopted by the present invention is:
[0007] A method for generating an obstacle avoidance route for a UAV based on a monocular camera. The method uses the video acquired by the UAV in real time as the input of the method, uses the improved Monodepth2 model to output the depth map and the position of the obstacle in the image from each frame of the image, obtains the real attributes of the obstacle according to the depth and position information of the obstacle, and calculates the obstacle avoidance route based on the obstacle avoidance strategy.
[0008] The method for generating an obstacle avoidance route for a UAV comprises the following steps:
[0009] Step 1: Record the camera parameters, build the camera, gimbal and edge computing box on the drone, and start the drone to fly automatically according to the route information; Step 2: The camera collects video in real time, inputs the improved Monodepth2 model deployed in the edge computing box for inference, and outputs the depth map and obstacle detection results; Step 3: Perform obstacle avoidance judgment based on the depth map and obstacle position information, and generate the obstacle avoidance direction and distance of the drone; Step 4: Generate an obstacle avoidance route based on the obstacle avoidance direction and distance of the drone.
[0010] Furthermore, in step 1, the camera parameters are recorded including the camera focal length f and the physical size p of the camera pixel. s ; The optical center of the camera coincides with the gimbal rotation center, so that the pitch, yaw and roll angles of the gimbal are always 0; during automatic flight, the drone matches the waypoint coordinates according to the real-time RTK signal received, and flies stably to the transmission tower position preset in the route information. During the flight, the pitch and roll angles of the drone are always 0, and the flight altitude remains unchanged.
[0011] Furthermore, in step 2, the improved Monodepth2 model is to add a detection head network to the baseline Monodep th2 model, input the feature map output by the encoding network in the Monodepth2 model into the detection head network for feature mapping, and quickly output the location information of the obstacle on the image.
[0012] Furthermore, the detection head network consists of a 4-fold upsampling layer, 4 parallel convolutional layers with a convolution kernel size of 3×3, and 3 prediction branches, wherein the 3 prediction branches are a center point heat map branch, a center point offset branch, and an object size branch;
[0013] The feature mapping process of the detection head is as follows: First, the feature map size is enlarged by 4 times through the upsampling layer to obtain a size of The feature map is then sampled by four parallel convolutional layers with unchanged size. During the sampling process, the channels of the feature map are reduced to 256, reducing redundant channels. The output size is feature map; finally, the three prediction branches perform feature mapping to generate the detection result; where H and W represent the height and width of the input image respectively.
[0014] Furthermore, the output of the specific branch of the detection head network is as follows:
[0015] The output size of the center point heat map branch is Heat map of the center point Expressed as In the formula, 2 represents the channels corresponding to the two types of targets, [0,1] represents the confidence of each pixel in the heat map as an obstacle target; when a point on the heat map If the value of is greater than 0.5, the point is considered as an obstacle target point; where, is the horizontal pixel number of the point on the heat map, is the number of vertical pixels of the point on the heat map, and c is the number of channels of the point on the heat map; the set of n obstacle target points can be obtained through the center point heat map branch In the formula, n represents the number of obstacle targets; represents the center point coordinates of the i-th obstacle target, where Represents the number of horizontal pixels, Represents the number of vertical pixels;
[0016] The center point offset branch output size is The coordinate offset caused by the discrete step size during the convolution process In the formula, R represents Each offset element in can be any real number, including positive, negative and decimal numbers; then the coordinate offset of the i-th obstacle target point is expressed as In the formula, δ represents the increment or offset;
[0017] The object size branch outputs a size of The width and height of the predicted target size are expressed as Then the width and height of the i-th obstacle target are expressed as In the formula, Indicates the width of the target, Indicates the height of the target;
[0018] Combining the output results of the three prediction branches, the coordinates of the center point (u0, v0), the upper left corner point (u1, v1) and the lower right corner point (u2, v2) of the circumscribed rectangular box of each obstacle target on the image are calculated. The calculation formula is as follows:
[0019]
[0020]
[0021]
[0022] Wherein, u0 represents the horizontal pixel position of the center point of the target circumscribed rectangular box on the image; v0 represents the vertical pixel position of the center point of the target circumscribed rectangular box on the image; u1 represents the horizontal pixel position of the upper left corner point of the target circumscribed rectangular box on the image; v1 represents the vertical pixel position of the upper left corner point of the target circumscribed rectangular box on the image; u2 represents the horizontal pixel position of the lower right corner point of the target circumscribed rectangular box on the image; v2 represents the vertical pixel position of the lower right corner point of the target circumscribed rectangular box on the image.
[0023] Furthermore, in step 3, the obstacle avoidance judgment method is: calculate the horizontal distance between the obstacle and the optical center of the camera, and generate the obstacle avoidance direction and obstacle avoidance distance of the drone according to the safe passage range of the drone. The steps are as follows:
[0024] First, the drone obtains the depth map D and the depth value corresponding to the coordinates of the obstacle center point (u0, v0) like If the distance is less than or equal to 3 meters, the aircraft will avoid obstacles, otherwise the aircraft will continue to fly.
[0025] Next, the minimum horizontal vector distance d between the obstacle and the camera optical center is calculated according to the pinhole imaging model. h , according to the relationship between the position u0 of the obstacle center in the image and the image width W, different calculation methods are selected:
[0026] When the center point of the obstacle is on the left side of the image, that is, The calculation formula is:
[0027]
[0028] When the center point of the obstacle is on the right side of the image, that is, The calculation formula is:
[0029]
[0030] Where f is the focal length of the camera, p s is the physical size of the camera pixel, and the coordinate values u0, u1, and u2 represent the horizontal coordinates of the center point of the obstacle on the image, the horizontal coordinates of the upper left corner of the obstacle on the image, and the horizontal coordinates of the lower right corner of the obstacle on the image, respectively;
[0031] Then, the interval in which the drone can safely pass is defined as [-1,1]. Based on the judgment, the obstacle avoidance direction and distance of the drone are determined: when the center point of the obstacle is on the left side of the image, if d hIf it is less than -1, the drone will ignore the obstacle and continue to fly; otherwise, the drone needs to fly to the right to avoid the obstacle. The obstacle avoidance direction is AO θ For the right side, obstacle avoidance distance AO d |-1-d h |; When the obstacle center is on the right side of the image, if d h If it is greater than 1, the drone will ignore the obstacle and continue to fly; otherwise, the drone needs to fly to the left to avoid the obstacle, and the obstacle avoidance direction is AO θ For the left side, obstacle avoidance distance AO d =|1-d h |;
[0032] According to the above steps, the drone can determine in real time whether it needs to avoid obstacles and generate the corresponding obstacle avoidance direction AO. θ and obstacle avoidance distance AO d to avoid obstacles.
[0033] Furthermore, in step 4, generating an obstacle avoidance route according to the obstacle avoidance direction and obstacle avoidance distance of the drone includes the following steps:
[0034] Step I, calculate the width w of the obstacle o :
[0035] Use the upper left corner horizontal coordinate u1 and the lower right corner horizontal coordinate u2 of the obstacle on the image, as well as the depth map D obtained by the drone and the depth value corresponding to the coordinates of the obstacle center point (u0, v0) Calculate the width w of the obstacle o
[0036]
[0037] Step II, calculate the coordinates of the obstacle avoidance intermediate point P2 and the obstacle avoidance end point P3:
[0038] a. When the obstacle avoidance direction is AO θ = Right side:
[0039]
[0040] Where, β is the angle between the line between P1 and P3 and the line between P1 and P2, β is equal to the angle between the line between P1 and P3 and the line between P2 and P3, P1 is the starting point of the obstacle avoidance task; θ is the angle between the line between P1 and P3 and the x-axis; α is the angle between the line between the origin of the coordinate system and P1 and the y-axis; d is the vertical distance from P2 to the edge of the obstacle; x1, y1, z1 are the coordinates of the starting point P1 of the obstacle avoidance task; x2, y2, z2 are the coordinates of the intermediate point P2 of the obstacle avoidance task;
[0041]
[0042] Where θ′ is the angle between the line between points P2 and P3 and the y-axis; x3, y3, z3 are the coordinates of the obstacle avoidance endpoint P3;
[0043] b. When the obstacle avoidance direction is AO θ = Left side:
[0044]
[0045] Where θ is the angle between the line between points P1 and P3 and the y-axis; x2, y2, z2 are the coordinates of the obstacle avoidance middle point P2;
[0046]
[0047] Where θ′ is the angle between the line between points P2 and P3 and the x-axis; x3, Y3, and z3 are the coordinates of the obstacle avoidance endpoint P3;
[0048] Step III, forming an obstacle avoidance route:
[0049] The obstacle avoidance route consists of the drone hovering point P0, the obstacle avoidance starting point P1, the obstacle avoidance intermediate point P2 and the obstacle avoidance end point P3. Obstacle avoidance is achieved by flying along these four points in a straight line.
[0050] The beneficial effects of the present invention are:
[0051] In view of the problem that existing obstacle avoidance methods have great restrictions on UAV equipment, the present invention proposes a method for generating an obstacle avoidance route using only a monocular camera, designs an improved Monodepth2 model to infer the monocular image, obtains the depth information and position information of obstacles in real time, and then uses a simple and effective obstacle avoidance logic to generate the obstacle avoidance direction and distance of the UAV, and finally generates the obstacle avoidance starting point, obstacle avoidance middle point and obstacle avoidance end point according to the trigonometric function relationship to form an obstacle avoidance route. The method for generating an obstacle avoidance route for a UAV can enable the UAV to have environmental perception and obstacle avoidance capabilities while flying autonomously. Compared with existing methods, this method has fewer restrictions on UAV equipment and is low in cost, making it more applicable in practical applications.
[0052] The detection head network is used to improve the baseline monodepth2 model, so that the improved monodepth2 model can directly generate depth maps and obstacle location information by reasoning on monocular images, avoiding the problem of long reasoning time caused by introducing a complete obstacle detection model.
[0053] According to the location information of the obstacle, a simple and effective obstacle avoidance logic is used to make judgments, generate the obstacle avoidance direction and distance of the drone, and then use the trigonometric function relationship to generate the obstacle avoidance starting point, obstacle avoidance intermediate point and obstacle avoidance end point to form an obstacle avoidance route. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0055] in:
[0056] Figure 1 It is a flow chart of the overall process of the method for generating obstacle avoidance routes for unmanned aerial vehicles based on a monocular camera of the present invention;
[0057] Figure 2 A schematic diagram of the Monodepth2 model used in the method for generating an obstacle avoidance route for a UAV based on a monocular camera of the present invention;
[0058] Figure 3 The method for generating a drone obstacle avoidance route based on a monocular camera of the present invention is a route map for the drone to avoid obstacles to the right;
[0059] Figure 4 This is a route map for a drone to avoid obstacles to the left according to a method for generating a drone obstacle avoidance route based on a monocular camera of the present invention. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] This embodiment proposes a method for generating a drone obstacle avoidance route based on a monocular camera. The method uses the video acquired by the drone in real time as input, uses the improved Monodepth2 model to output the depth map and the position of the obstacle in the image from each frame, obtains the real attributes of the obstacle according to the depth and position information of the obstacle, and calculates the obstacle avoidance route based on the obstacle avoidance strategy. Figure 1 As shown, the method for generating an obstacle avoidance route for a UAV based on a monocular camera specifically includes the following steps:
[0062] Step 1: Record the camera parameters, install the camera and edge computing box on the drone, and start the drone to fly automatically according to the route information;
[0063] Step 2: The camera collects video in real time, inputs it into the improved Monodepth2 model deployed in the edge computing box for inference, and outputs the depth map and obstacle detection results;
[0064] Step 3: Make obstacle avoidance judgment based on the depth map and obstacle location information, and generate the obstacle avoidance direction and distance of the drone;
[0065] Step 4: Generate an obstacle avoidance route based on the obstacle avoidance direction and distance of the drone.
[0066] The obstacle avoidance route generation method for unmanned aerial vehicles only uses the obstacle avoidance route generation method of the monocular camera, designs an improved Monodepth2 model to infer the monocular image, obtains the depth information and position information of the obstacle in real time, and then uses a simple and effective obstacle avoidance logic to generate the obstacle avoidance direction and distance of the unmanned aerial vehicle. Finally, the obstacle avoidance starting point, obstacle avoidance intermediate point and obstacle avoidance end point are generated according to the trigonometric function relationship to form an obstacle avoidance route. The obstacle avoidance route generation method for unmanned aerial vehicles can enable the unmanned aerial vehicle to have environmental perception and obstacle avoidance capabilities while flying autonomously. Compared with the existing methods, this method has fewer restrictions on unmanned aerial vehicle equipment and lower costs, making it more applicable in practical applications.
[0067] The detailed process of step 1 is as follows:
[0068] Before the UAV performs a power line inspection mission, it is necessary to record the necessary camera parameters for the calculation of the obstacle avoidance algorithm, including the camera focal length f and the physical size p of the camera pixel. s , both parameters are in meters.
[0069] Fix the camera and edge computing box on the drone body, where the optical center of the camera coincides with the gimbal rotation center, so that the pitch angle, yaw angle, and roll angle of the gimbal are always 0.
[0070] Import the route information of the UAV's autonomous patrol into the UAV control software to start the UAV's automatic patrol. The UAV matches the waypoint coordinates according to the real-time RTK signal received, and flies stably to the transmission tower position preset in the route information. During the flight, the pitch and roll angles of the UAV are always 0, and the flight altitude remains unchanged.
[0071] The detailed process of step 2 is as follows:
[0072] The drone collects real-time video through the gimbal camera during autonomous flight, and inputs the image frame by frame into the improved Monodepth2 model deployed in the edge computing box for inference, outputting the depth map and obstacle detection results. The depth map is a single-channel map D with the same length and width as the input image, H×W. The value D of each pixel on the map is u,vrepresents the vertical distance between the point and the camera, u is the horizontal pixel number of the point on the image, v is the vertical pixel number of the point on the image, D u,v The unit is meter; the obstacle detection result is the location information of the obstacle on the image. The location of the obstacle is defined by the center point coordinates (u0, v0), the upper left corner coordinates (u1, v1) and the lower right corner coordinates (u2, v2) of the obstacle's circumscribed rectangle.
[0073] The reasons and ideas for improving the Monodepth2 model are:
[0074] The baseline Monodepth2 model can only output a depth map but cannot determine which areas in the image are obstacles, so additional identification and positioning of obstacles in the image are required. Since the baseline Monodepth2 model is trained using the large-scale street view image dataset CityScape, its encoding network can fully sample telephone poles and trees in the real world and generate semantically rich feature maps. Therefore, this patent directly adds a detection head network to the baseline Monodepth2 model, and inputs the feature map output by the encoding network in the Monodepth2 model into the detection head network for feature mapping, and quickly outputs the location information of obstacles in the image, avoiding the problem of long inference time caused by introducing a complete obstacle detection model. The schematic diagram of the improved Monodepth2 model is shown below. Figure 2 shown.
[0075] The detection head network consists of a 4x upsampling layer, 4 parallel convolutional layers with a kernel size of 3×3, and 3 prediction branches. The 3 prediction branches are consistent with the prediction branches in the CenterNet model, namely the center point heat map branch, the center point offset branch, and the object size branch.
[0076] The feature mapping process of the detection head is: For the Monodepth2 model, the size of the encoding network output is First, the feature map size is enlarged by 4 times through the upsampling layer to obtain a size of The feature map is then sampled by four parallel convolutional layers with unchanged size. During the sampling process, the channels of the feature map are reduced to 256, reducing redundant channels. The output size is feature map; finally, the three prediction branches perform feature mapping to generate the detection results.
[0077] Among them, the center point heat map branch outputs the center point heat maps of two types of targets: telephone poles and trees 2 represents the channels corresponding to the two types of targets. When a point on the heat map If the value of is greater than 0.5, the point is considered as an obstacle target point. is the horizontal pixel number of the point on the heat map, is the number of vertical pixels of the point on the heat map, and c is the number of channels of the point on the heat map.
[0078] Therefore, the set of n obstacle target points can be obtained through the center point heat map branch. The coordinate offset caused by the discretization of the step size during the output convolution of the center point offset branch The coordinate offset of the i-th obstacle target point is expressed as The object size branch outputs the predicted width and height of the target size. The size prediction result is expressed as The width and height of the i-th obstacle target are expressed as
[0079] Combining the output results of the three prediction branches, we can calculate the center point coordinates (u0, v0), upper left corner coordinates (u1, v1) and lower right corner coordinates (u2, v2) of the circumscribed rectangular box of each obstacle target on the image. The obstacle position information calculation formula is as follows:
[0080]
[0081]
[0082]
[0083] Wherein, u0 represents the horizontal pixel position of the center point of the target circumscribed rectangular box on the image; v0 represents the vertical pixel position of the center point of the target circumscribed rectangular box on the image; u1 represents the horizontal pixel position of the upper left corner point of the target circumscribed rectangular box on the image; v1 represents the vertical pixel position of the upper left corner point of the target circumscribed rectangular box on the image; u2 represents the horizontal pixel position of the lower right corner point of the target circumscribed rectangular box on the image; v2 represents the vertical pixel position of the lower right corner point of the target circumscribed rectangular box on the image.
[0084] The detection head network is used to improve the baseline monodepth2 model, so that the improved monodepth2 model can directly generate depth maps and obstacle location information by reasoning on monocular images, avoiding the problem of long reasoning time caused by introducing a complete obstacle detection model.
[0085] The detailed process of step 3 is as follows:
[0086] Through step 2, the drone obtains the depth map and obstacle position information in real time during autonomous flight. On the depth map D, the depth value corresponding to the coordinates (u0, v0) of the obstacle center point is plotted. As the vertical distance between the obstacle and the camera. If there is an obstacle depth in the image If the distance is less than or equal to 3 meters, the drone will hover at the current position through the flight control module to make obstacle avoidance judgments; if no obstacles are detected in the image, or the depth of all obstacles is If both are greater than 3 meters, the drone will continue to fly.
[0087] The obstacle avoidance judgment method is: calculate the horizontal distance between the obstacle and the optical center of the camera, and generate the obstacle avoidance direction and distance of the drone according to the safe passage range of the drone. The specific steps are as follows:
[0088] a). According to the pinhole imaging model, calculate the minimum horizontal vector distance d between the obstacle and the camera optical center h , can be calculated by the following formula:
[0089]
[0090] Where f is the focal length of the camera, p s is the physical size of the camera pixel, obtained in step 1; the coordinate values u0, u1 and u2 represent the horizontal coordinates of the center point of the obstacle on the image, the horizontal coordinates of the upper left corner of the obstacle on the image, and the horizontal coordinates of the lower right corner of the obstacle on the image, respectively, obtained in step 2; the depth Obtained in step 2;
[0091] W represents the width of the image, so when the center point of the obstacle is on the left side of the image, that is, The minimum horizontal vector distance is calculated based on the horizontal coordinate of the lower right corner of the obstacle and the midpoint of the image; when the center point of the obstacle is on the right side of the image, that is, The minimum horizontal vector distance is calculated based on the horizontal coordinate of the lower left corner of the obstacle and the midpoint of the image.
[0092] b). Since there is a certain distance between the drone wing and the optical center of the camera, it is necessary to define the interval in which the drone can pass safely. In this embodiment, the safe passage interval of the drone is set to [-1,1]. That is, when the center point of the obstacle is on the left side of the image, if d h If d is less than -1, the drone can ignore the obstacle and continue to fly. Otherwise, the drone needs to fly to the right to avoid the obstacle. When the center point of the obstacle is on the right side of the image, if d h If it is greater than 1, the drone can ignore the obstacle and continue flying; otherwise, the drone needs to fly to the left to avoid the obstacle.
[0093] c). If the drone is determined to need to avoid obstacles (Avoid Obstacle, AO) in step b, then the obstacle avoidance direction AO is generated θ and obstacle avoidance distance AO d When the obstacle center is on the left side of the image, AO θ =RIGHT,AO d =|-1-d h|; When the obstacle center is on the right side of the image, AO θ =LEFT,A d =|1-d h |.
[0094] The detailed process of step 4 is as follows:
[0095] When the drone needs to avoid obstacles through step 3, the origin O is taken as the take-off point of the drone. e Establish geodetic coordinate system X e Y e , X e The axis points east, Y e The axis points north.
[0096] The drone obtains the coordinates (x0, y0, z0) of the current hovering point P0 and the coordinates of point P0 and Y according to the received RTK signal. e The angle α between the axes. Let X d Represents the right side of the drone, Y d Point to the flight direction of the drone and set the starting point P1 of the obstacle avoidance task 2 meters away from the obstacle while keeping the flight direction unchanged. The coordinates of point P1 (x1, y1, z1) are calculated by the following formula:
[0097]
[0098] Among them, sinα is the sine value of angle α, and cosα is the cosine value of angle α.
[0099] Take point P1 as the obstacle avoidance starting point and follow the obstacle avoidance direction AO θ and obstacle avoidance distance AO d Generate an obstacle avoidance route, specifically:
[0100] a). Calculate the width w of the obstacle o :
[0101] Considering the cross-sectional outer contour of the electric pole and tree obstacles as a circle, the width w o It can be calculated by the following formula based on the horizontal coordinates u1 and u2 of the upper left corner and lower right corner on the image;
[0102]
[0103] b). When AO θ =RIGHT, the drone's route map to avoid obstacles to the right is as follows Figure 3 As shown, the obstacle avoidance intermediate point P2 (x2, y2, z2) and obstacle avoidance end point P3 (x3, y3, z3) are generated by the following formula:
[0104]
[0105]
[0106] Where, β is the angle between the line between P1 and P3 and the line between P1 and P2, β is equal to the angle between the line between P1 and P3 and the line between P2 and P3, P1 is the starting point of the obstacle avoidance task; θ is the angle between the line between P1 and P3 and X e The angle between the coordinate origin and point P1 and the Y axis; α is the angle between the coordinate origin and point P1 and the Y axis. e The angle between the axes; d is the vertical distance from point P2 to the edge of the obstacle; x1, y1, z1 are the coordinates of the starting point P1 of the obstacle avoidance task; x2, y2, z2 are the coordinates of the middle point P2 of the obstacle avoidance task; θ′ is the line between points P2 and P3 and Y e The angle between the axes; x3, y3, z3 are the coordinates of the obstacle avoidance endpoint P3;
[0107] c). When AO θ = LEFT, the drone's route map to avoid obstacles to the left is as follows Figure 4 As shown, the obstacle avoidance intermediate point P2 (x2, y2, z2) and obstacle avoidance end point P3 (x3, y3, z3) are generated by the following formula:
[0108]
[0109]
[0110] Where θ is the line between P1 and P3 and Y e The angle between the axes; x2, y2, z2 are the coordinates of the obstacle avoidance middle point P2; θ′ is the angle between the line between P2 and P3 and the X e The angle between the axes; x3, y3, z3 are the coordinates of the obstacle avoidance endpoint P3;
[0111] d). Form an obstacle avoidance route:
[0112] The obstacle avoidance route consists of the drone hovering point P0, the obstacle avoidance starting point P1, the obstacle avoidance intermediate point P2 and the obstacle avoidance end point P3. Obstacle avoidance is achieved by flying along these four points in a straight line.
[0113] Steps 3 and 4 of this method use simple and effective obstacle avoidance logic to make judgments based on the location information of the obstacle, generate the obstacle avoidance direction and distance of the drone, and then use the trigonometric function relationship to generate the obstacle avoidance starting point, obstacle avoidance intermediate point and obstacle avoidance end point to form an obstacle avoidance route.
[0114] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for generating an obstacle avoidance route for a UAV based on a monocular camera, characterized in that: The obstacle avoidance route generation method for drones uses the real-time video acquired by drones as the input of the method, and uses the improved Monodepth2 model to output the depth map and the position of obstacles in the image from each frame of the image. The real attributes of the obstacles are obtained according to the depth and position information of the obstacles, and the obstacle avoidance route is calculated based on the obstacle avoidance strategy. The method for generating an obstacle avoidance route for a UAV comprises the following steps: Step 1: Record the camera parameters, build the camera, gimbal and edge computing box on the drone, and start the drone to fly automatically according to the route information; Step 2: The camera collects video in real time, inputs the improved Monodepth2 model deployed in the edge computing box for inference, and outputs the depth map and obstacle detection results; Step 3: Perform obstacle avoidance judgment based on the depth map and obstacle position information, and generate the obstacle avoidance direction and distance of the drone; Step 4: Generate an obstacle avoidance route based on the obstacle avoidance direction and distance of the drone.
2. The method for generating an obstacle avoidance route for a UAV based on a monocular camera according to claim 1, wherein: In step 1, record the camera parameters including the camera focal length f and the physical size of the camera pixel p s ; The optical center of the camera coincides with the gimbal rotation center, so that the pitch, yaw and roll angles of the gimbal are always 0; during automatic flight, the drone matches the waypoint coordinates according to the real-time RTK signal received, and flies stably to the transmission tower position preset in the route information. During the flight, the pitch and roll angles of the drone are always 0, and the flight altitude remains unchanged.
3. The method for generating an obstacle avoidance route for a UAV based on a monocular camera according to claim 1, wherein: In step 2, the improved Monodepth2 model is to add a detection head network to the baseline Monod epth2 model, input the feature map output by the encoding network in the Monodepth2 model into the detection head network for feature mapping, and quickly output the location information of the obstacle on the image.
4. The method for generating an obstacle avoidance route for a UAV based on a monocular camera according to claim 3, wherein: The detection head network consists of a 4-fold upsampling layer, 4 parallel convolutional layers with a convolution kernel size of 3×3, and 3 prediction branches, which are a center point heat map branch, a center point offset branch, and an object size branch. The feature mapping process of the detection head is as follows: First, the feature map size is enlarged by 4 times through the upsampling layer to obtain a size of The feature map is then sampled by four parallel convolutional layers with unchanged size. During the sampling process, the channels of the feature map are reduced to 256, reducing redundant channels. The output size is feature map; finally, the three prediction branches perform feature mapping to generate the detection result; where H and W represent the height and width of the input image respectively.
5. The method for generating an obstacle avoidance route for a UAV based on a monocular camera according to claim 4, wherein: The output of the specific branch of the detection head network is as follows: The output size of the center point heat map branch is Heat map of the center point Expressed as In the formula, 2 represents the channels corresponding to the two types of targets, [0,1] represents the confidence of each pixel in the heat map as an obstacle target; when a point on the heat map If the value of is greater than 0.5, the point is considered as an obstacle target point; where, is the horizontal pixel number of the point on the heat map, is the number of vertical pixels of the point on the heat map, and c is the number of channels of the point on the heat map; the set of n obstacle target points can be obtained through the center point heat map branch In the formula, n represents the number of obstacle targets; represents the center point coordinates of the i-th obstacle target, where Represents the number of horizontal pixels, Represents the number of vertical pixels; The center point offset branch output size is The coordinate offset caused by the discrete step size during the convolution process In the formula, R represents Each offset element in can be any real number, including positive, negative and decimal numbers; then the coordinate offset of the i-th obstacle target point is expressed as In the formula, δ represents the increment or offset; The object size branch outputs a size of The width and height of the predicted target size are expressed as Then the width and height of the i-th obstacle target are expressed as In the formula, Indicates the width of the target, Indicates the height of the target; Combining the output results of the three prediction branches, the coordinates of the center point (u0, v0), the upper left corner point (u1, v1) and the lower right corner point (u2, v2) of the circumscribed rectangular box of each obstacle target on the image are calculated. The calculation formula is as follows: Wherein, u0 represents the horizontal pixel position of the center point of the target circumscribed rectangular box on the image; v0 represents the vertical pixel position of the center point of the target circumscribed rectangular box on the image; u1 represents the horizontal pixel position of the upper left corner point of the target circumscribed rectangular box on the image; v1 represents the vertical pixel position of the upper left corner point of the target circumscribed rectangular box on the image; u2 represents the horizontal pixel position of the lower right corner point of the target circumscribed rectangular box on the image; v2 represents the vertical pixel position of the lower right corner point of the target circumscribed rectangular box on the image.
6. The method for generating an obstacle avoidance route for a UAV based on a monocular camera according to claim 1, wherein: In step 3, the obstacle avoidance judgment method is: calculate the horizontal distance between the obstacle and the optical center of the camera, and generate the obstacle avoidance direction and distance of the drone according to the safe passage range of the drone. The steps are as follows: First, the drone obtains the depth map D and the depth value corresponding to the coordinates of the obstacle center point (u0, v0) like If the distance is less than or equal to 3 meters, the aircraft will avoid obstacles, otherwise it will continue to fly. Next, the minimum horizontal vector distance d between the obstacle and the camera optical center is calculated according to the pinhole imaging model. h , according to the relationship between the position u0 of the obstacle center in the image and the image width W, different calculation methods are selected: When the center point of the obstacle is on the left side of the image, that is, The calculation formula is: When the center point of the obstacle is on the right side of the image, that is, The calculation formula is: Where f is the focal length of the camera, p s is the physical size of the camera pixel, and the coordinate values u0, u1, and u2 represent the horizontal coordinates of the center point of the obstacle on the image, the horizontal coordinates of the upper left corner of the obstacle on the image, and the horizontal coordinates of the lower right corner of the obstacle on the image, respectively; Then, define the interval in which the drone can safely pass as [-1,1], and determine the obstacle avoidance direction and distance of the drone based on the judgment: when the center point of the obstacle is on the left side of the image, if d h If it is less than -1, the drone will ignore the obstacle and continue to fly; otherwise, the drone needs to fly to the right to avoid the obstacle. The obstacle avoidance direction is AO θ For the right side, obstacle avoidance distance AO d |-1-d h |; When the obstacle center is on the right side of the image, if d h If it is greater than 1, the drone will ignore the obstacle and continue to fly; Otherwise, the drone needs to fly left to avoid obstacles, and the obstacle avoidance direction is AO. θ For the left side, obstacle avoidance distance AO d =|1-d h |; According to the above steps, the drone can determine in real time whether it needs to avoid obstacles and generate the corresponding obstacle avoidance direction AO. θ and obstacle avoidance distance AO d to avoid obstacles.
7. The method for generating an obstacle avoidance route for a UAV based on a monocular camera according to claim 6, wherein: In step 4, generating an obstacle avoidance route based on the obstacle avoidance direction and obstacle avoidance distance of the drone includes the following steps: Step I, calculate the width w of the obstacle o : Use the upper left corner horizontal coordinate u1 and the lower right corner horizontal coordinate u2 of the obstacle on the image, as well as the depth map D obtained by the drone and the depth value corresponding to the coordinates of the obstacle center point (u0, v0) Calculate the width w of the obstacle o Step II, calculate the coordinates of the obstacle avoidance intermediate point P2 and the obstacle avoidance end point P3: a. When the obstacle avoidance direction is AO θ = Right side: Where, β is the angle between the line between P1 and P3 and the line between P1 and P2, β is equal to the angle between the line between P1 and P3 and the line between P2 and P3, P1 is the starting point of the obstacle avoidance task; θ is the angle between the line between P1 and P3 and the x-axis; α is the angle between the line between the origin of the coordinate system and P1 and the y-axis; d is the vertical distance from P2 to the edge of the obstacle; x1, y1, z1 are the coordinates of the starting point P1 of the obstacle avoidance task; x2, y2, z2 are the coordinates of the intermediate point P2 of the obstacle avoidance task; Where θ′ is the angle between the line between points P2 and P3 and the y-axis; x3, y3, z3 are the coordinates of the obstacle avoidance endpoint P3; b. When the obstacle avoidance direction is AO θ = Left side: Where θ is the angle between the line between points P1 and P3 and the y-axis; x2, y2, z2 are the coordinates of the obstacle avoidance middle point P2; Where θ′ is the angle between the line between points P2 and P3 and the x-axis; x3, y3, z3 are the coordinates of the obstacle avoidance endpoint P3; Step III, forming an obstacle avoidance route: The obstacle avoidance route consists of the drone hovering point P0, the obstacle avoidance starting point P1, the obstacle avoidance intermediate point P2 and the obstacle avoidance end point P3. Obstacle avoidance is achieved by flying along these four points in a straight line.
