Disclosure of Invention
Aiming at the defects existing in the prior art, the invention is mainly used for solving the problems that an industrial robot is interfered by adjacent workpieces and is difficult to acquire the optimal grabbing pose of the sorted workpieces when realizing sorting tasks, and provides a robot grabbing method considering adjacent interference of sorting targets.
The technical scheme of the invention is as follows:
step 1, acquiring a grabbing task RGB image and a depth image, identifying and extracting a workpiece by sorting the grabbing task RGB image, and determining an initial workpiece to be grabbed;
Step 2, combining the upper and lower states of the sorted workpieces and the depth images to determine the final to-be-sorted workpieces, the corresponding sorting target areas, the potential interference areas and the compensating heights of the gripping points of the clamping jaws;
Step 3, determining a grabbing point searching area and an actual interference area of the clamping jaw according to the sorting target area, the potential interference area and the clamping jaw structure;
Step 4, setting search constraint conditions, and carrying out capture pose detection according to the capture point search area and the actual interference area of the clamping jaw and combining the search constraint conditions and the compensation height of the capture points of the clamping jaw to obtain an optimal capture pose; if the optimal grabbing pose cannot be generated, the current workpiece to be grabbed cannot be grabbed, other workpieces to be grabbed in the current task RGB image are selected to serve as new workpieces to be grabbed, and the steps 2-3 are repeated and grabbing pose detection is carried out until the optimal grabbing pose is obtained;
and 5, repeating the steps 1-4, continuously collecting images and grabbing corresponding workpieces to be grabbed in each image until the workpieces in the images are grabbed, and completing robot grabbing.
The step 1 specifically comprises the following steps:
step 1.1, collecting a grabbing task RGB image and a grabbing task depth image;
And 1.2, carrying out target recognition on the RGB images of the grabbing task to obtain detection frames of all the sorted workpieces, taking the sorted workpiece with the detection frame closest to the clamping jaw of the robot arm as an initial workpiece to be grabbed, and ending grabbing if the workpiece is not recognized.
The step 2 specifically comprises the following steps:
Step 2.1, combining the upper and lower positions of the sorted workpieces, determining the final workpiece to be sorted and obtaining a sorting target area and each adjacent target area after performing upper and lower position judgment on the current workpiece to be sorted;
And 2.2, respectively judging the interference areas of the adjacent target areas based on the sorting target areas and the corresponding depth images to obtain the potential interference areas and the compensation heights of the gripping points of the clamping jaws.
The step 2.1 specifically comprises the following steps:
step 2.1.1, generating a nearest image area according to the current workpiece to be grabbed, further determining potential interference workpieces corresponding to the workpiece to be grabbed, and extracting target areas of the workpieces in the nearest image area;
Judging whether the current workpiece to be grabbed is in a lower state of physical stacking in a target area where the current workpiece to be grabbed is located, if so, marking the current workpiece to be grabbed as a non-grabbed workpiece, and taking the upper workpiece as a new workpiece to be grabbed;
And 2.1.3, repeating the steps 2.1.1 to 2.1.2 until the current workpiece to be grabbed is in the uppermost state, taking the final target area where the workpiece to be grabbed is positioned as a sorting target area, and taking the final target area where the potential interference workpiece is positioned as each adjacent target area.
The step 2.1.1 specifically comprises the following steps:
After expanding the periphery of a detection frame corresponding to the workpiece to be grabbed currently, obtaining an initial clamping jaw frame, if a detection frame intersected with the clamping jaw frame exists, expanding the clamping jaw frame, enabling the detection frame intersected with the clamping jaw frame to be contained in the expanded clamping jaw frame, taking the area where the final clamping jaw frame is located as a nearest image area, and then marking the workpiece corresponding to the detection frame except the detection frame where the workpiece to be grabbed currently in the nearest image area as a potential interference workpiece.
The step 2.2 specifically comprises the following steps:
Step 2.2.1, generating corresponding lattices by randomly taking points from the separation target area and each adjacent target area, and obtaining corresponding lattice depth information in the depth image after carrying out coordinate system conversion on all lattices by utilizing an internal and external mapping relation matrix of the depth camera so as to obtain corresponding lattice height information;
And 2.2.2, judging each adjacent target area as a potential interference area and a non-potential interference area according to the lattice height information corresponding to the sorting target area and each adjacent target area, and acquiring the compensation height of the gripping points of the gripping jaws.
The step 2.2.2 specifically comprises the following steps:
And 2.2.2.1, respectively calculating the height difference between each adjacent target area and the sorting target area according to the dot matrix height information corresponding to the sorting target area and each adjacent target area, wherein the calculation formula is as follows:
Wherein h t denotes a height difference between the i-th adjacent target area and the sorting target area, Representing the average height of the lattice corresponding to the sorting target area, and max { h i (x, y) } represents the maximum height of the lattice corresponding to the ith adjacent target area;
And 2.2.2.2, when the height difference between a certain adjacent target area and the sorting target area is smaller than or equal to a height difference threshold h T, judging the adjacent target area as a potential interference area, otherwise, judging the adjacent target area as a non-potential interference area, and calculating the compensation height of the gripping point of the clamping jaw according to the height information of all the non-potential interference areas.
The step 3 specifically comprises the following steps:
Step 3.1, generating a clamping jaw sliding window according to a clamping jaw structure, wherein two side areas of the clamping jaw sliding window corresponding to the tail end parts of the clamping jaw are recorded as grabbing shielding areas;
step 3.2, marking the minimum circumscribed rectangle of the sorting target area as a grabbing point searching area, expanding the periphery of the grabbing point searching area based on the related size of the clamping jaw sliding window, and forming a sliding window searching area;
And 3.3, screening all potential interference areas pixel by pixel, only reserving pixels existing in the sliding window searching area to form an actual interference area, and then setting different gray value marks for the sorting target area and the actual interference area in the sliding window searching area, wherein the other pixels are all pixels in a background area, and setting 0.
In the step 4, the search constraint condition specifically includes:
In the process of searching the grabbing point searching area pixel by pixel, when the grabbing pose of the clamping jaw is changed, pixels of the sorting target area but no pixels of the actual interference area are arranged in the corresponding sliding window of the clamping jaw, and only pixels of the background area are arranged in the grabbing shielding area.
In the step 4, a genetic algorithm is used for detecting the grabbing pose, when the interference area near one workpiece is too much in the process of detecting the grabbing pose, the total fitness of the population is 0, then the sorted workpiece where a detection frame closest to the clamping jaw of the robot arm is positioned in other workpieces to be grabbed in the RGB image of the current task is selected as a new workpiece to be grabbed;
When the gripping jaw sliding window corresponding to each individual has no sorting target area or interference area or the gripping shielding area has a non-background area, the individual satisfies directional extinction, and the fitness function of the genetic algorithm satisfies the following formula:
Wherein f (x ', y', theta ') is the fitness of each individual, x t′,yt' is two coordinate values of the mass center of the sorting target area in the sliding window, h is the jaw width of the parallel jaw, x ', y' is two coordinate values of the central point of the jaw sliding window, k j represents the span of the sorting target area in the sliding window range along the long side direction of the sliding window, and j represents different positions in the short side direction of the sliding window when the span is calculated; Represents the average value of all spans k j and is represented as absolute.
The beneficial effects of the invention are as follows:
According to the invention, only the grippable workpiece with the closest distance to the gripping jaw of the robot arm is subjected to the gripping pose detection in the nearest image area at each time, so that the sorting operation efficiency of the robot is ensured, and the calculation amount of the gripping pose detection is reduced;
According to the method, whether the potential interference workpieces in the adjacent target areas interfere with the classified target areas is judged, and the problem that the adjacent workpieces are easy to interfere when the grabbing frame is acquired is avoided by combining with the optimized search of the grabbing pose;
According to the invention, the possible interference of the adjacent target areas is considered, meanwhile, the easy grabbing property of the sorting targets is considered, the grabbing pose of the sorting targets is optimized, and the feasibility of the grabbing pose detection result is improved.
Detailed Description
The invention designs a robot grabbing method considering adjacent interference of sorting targets, and in order to make the above objects, features and advantages of the invention more obvious and understandable, the following detailed description of the specific embodiments of the invention is given with reference to the accompanying drawings.
The specific flow of the method is shown in fig. 1, and the robot arm is selected as a research object, the parallel clamping jaw is used as a tail end grabbing tool, and the ocean industry camera and the INTEL REALSENSE depth camera are used as image sensing equipment. The sorting workpieces comprise a cup head long bolt M4 (f-shaped workpiece), a stop washer M14 (n-shaped workpiece), a round washer M4 (i-shaped workpiece), a hexagonal bolt M4 (e-shaped workpiece), a shaft clamp spring M13 (o-shaped workpiece) and a cup head bolt M5 (c-shaped workpiece).
Step 1, an industrial camera and a depth camera respectively acquire a grabbing task RGB image and a depth image, and after the acquired grabbing task RGB image is subjected to identification and extraction of sorting workpieces, an initial workpiece to be grabbed is determined;
The step 1 specifically comprises the following steps:
step 1.1, collecting a grabbing task RGB image and a grabbing task depth image;
and 1.2, performing target recognition on the grabbing task RGB image by using a fast R-CNN, retinaNet, YOLO series target recognition network to obtain detection frames of all the sorted workpieces, taking the sorted workpiece with the detection frame closest to the clamping jaw of the robot arm as an initial workpiece to be grabbed, and ending grabbing if the workpiece is not recognized.
Step 2, combining the upper and lower states of the sorted workpieces and the depth images to determine the final to-be-sorted workpieces, the corresponding sorting target areas, the potential interference areas and the compensating heights of the gripping points of the clamping jaws;
The step2 is specifically as follows:
Step 2.1, combining the upper and lower positions of the sorted workpieces, determining the final workpiece to be sorted and obtaining a sorting target area and each adjacent target area after performing upper and lower position judgment on the current workpiece to be sorted;
step 2.1.1, generating a nearest image area according to the current workpiece to be grabbed, further determining potential interference workpieces corresponding to the workpiece to be grabbed, and extracting target areas of the workpieces in the nearest image area;
step 2.1.1 is specifically:
After expanding the periphery of a detection frame corresponding to a workpiece to be grasped by 1 clamping jaw, obtaining an initial clamping jaw frame, if a detection frame intersected with the clamping jaw frame exists, expanding the clamping jaw frame, enabling the detection frame intersected with the clamping jaw frame to be contained in the expanded clamping jaw frame, taking the area where the final clamping jaw frame is located as a nearest image area, taking the minimum value of the maximum value of the horizontal coordinate and the vertical coordinate of the clamping jaw frame and the range of the intersected detection frame as shown in (a) of fig. 2, determining the boundary frame range, intersecting the white clamping jaw frame with the c detection frame, the e detection frame and the o detection frame in the range, taking the minimum value of the maximum value of the horizontal coordinate and the vertical coordinate of the c detection frame in the range of the intersected detection frame, namely the horizontal coordinate corresponding to the right boundary of the clamping jaw frame, the horizontal coordinate corresponding to the left boundary of the clamping jaw frame, the vertical coordinate corresponding to the lower boundary of the o detection frame and the vertical coordinate corresponding to the upper boundary of the clamping jaw frame, and determining the boundary frame range. Otherwise, the area where the initial clamping jaw frame is located is directly used as a nearest image area, and then the workpiece corresponding to the detection frame except the detection frame where the workpiece to be grabbed is located in the nearest image area is recorded as a potential interference workpiece.
In the specific implementation, noise reduction, enhancement and inversion are carried out on the nearest image area, then a background area segmentation threshold value and a foreground area segmentation threshold value are obtained by using a maximum inter-class variance method, and based on the background area segmentation threshold value and the foreground area segmentation threshold value, an improved algorithm based on area segmentation and classification merging is used for extracting targets of detection frames where workpieces to be grabbed and potential interference workpieces are located, and corresponding sparse target areas are respectively output. The improved algorithm based on region segmentation and classification merging is that a fragmented watershed region is obtained through labeled watershed transformation, a preliminary segmentation stacking target effect is achieved, the fragmented watershed region is integrated into a larger clustering region through affinity propagation clustering, the attribution detection frames of region elements in a clustering region set are sequentially judged according to the membership relationship between the clustering region and the detection frames, and the regions attributed to the same detection frame are merged. The sparse target area is a sparse matrix for converting a binary image of which the pixels are marked with connected domains into COO format storage data, and a large amount of useless information is stored in a compressed two-dimensional array form.
Judging whether the current workpiece to be grabbed is in a lower state of physical stacking in a target area where the current workpiece to be grabbed is located, if so, marking the current workpiece to be grabbed as a non-grabbed workpiece, taking the upper workpiece as a new workpiece to be grabbed, otherwise, directly outputting the final workpiece to be grabbed, and obtaining a sorting target area and each adjacent target area;
And 2.1.3, repeating the steps 2.1.1-2.1.2 until the current workpiece to be grabbed is in the uppermost state, taking the target area where the final workpiece to be grabbed is positioned as a sorting target area, and taking the target area where the final potential interference workpiece is positioned as each adjacent target area, wherein the sorting target area corresponds to a cup head long bolt M4 (f-shaped workpiece) as shown in (b) of fig. 2, and the adjacent target areas 1, 2, 3, 4 and 5 correspond to a backing washer M14 (n-shaped workpiece), a round washer M4 (i-shaped workpiece), a hexagon bolt M4 (e-shaped workpiece), a shaft clamp spring M13 (o-shaped workpiece) and a cup head bolt M5 (c-shaped workpiece) respectively.
Step 2.2, based on the sorting target areas and the corresponding depth images, judging the interference areas of the adjacent target areas respectively to obtain the potential interference areas and the compensation heights of the gripping points of the clamping jaws;
Step 2.2 is specifically:
Step 2.2.1, generating corresponding lattices by randomly taking points from the separation target area and each adjacent target area respectively, and obtaining corresponding lattice depth information in a depth image after performing coordinate system conversion on all lattices by utilizing an internal and external mapping relation matrix of a depth camera obtained by adopting a nine-point calibration method as shown in (c) of fig. 2, so as to obtain corresponding lattice height information;
in step 2.2.1, the calculation formula of each dot matrix height information is as follows:
h(x,y)=d(x,y)-d0
Where h (x, y) is the height of the lattice with coordinates (x, y), d (x, y) is the depth of the lattice with coordinates (x, y), and d 0 is the average depth of the table without workpiece.
And 2.2.2, judging each adjacent target area as a potential interference area and a non-potential interference area according to the lattice height information corresponding to the sorting target area and each adjacent target area, and acquiring the compensation height of the gripping points of the gripping jaws.
Step 2.2.2 is specifically:
And 2.2.2.1, respectively calculating the height difference between each adjacent target area and the sorting target area according to the dot matrix height information corresponding to the sorting target area and each adjacent target area, wherein the calculation formula is as follows:
Wherein h t denotes a height difference between the i-th adjacent target area and the sorting target area, Representing the average height of the lattice corresponding to the sorting target area, and max { h i (x, y) } represents the maximum height of the lattice corresponding to the ith adjacent target area;
Step 2.2.2.2, when the height difference between a certain adjacent target area and a sorting target area is smaller than or equal to a height difference threshold h T, the adjacent target area is judged to be a potential interference area if the workpiece in the adjacent target area possibly interferes with the grabbing process of the target workpiece, the adjacent target areas 1,3 and 5 in the step (b) of fig. 2 finally form potential interference areas 1,2 and 3 shown in the step (d) of fig. 2, and the height of the workpiece in the 3 areas is close to or higher than that of the workpiece to be sorted, otherwise, in the grabbing process of the target workpiece, the workpiece in the adjacent target area can be prevented from being interfered by only raising a clamping jaw by a certain compensation height, the adjacent target area is judged to be a non-potential interference area, such as the adjacent target areas 2 and 4 in the step (b) of fig. 2, and the heights of the two areas are far lower than that of the workpiece to be sorted, and the compensation height of the clamping jaw grabbing point is calculated according to the height information of all the non-potential interference areas.
And calculating the compensation height delta h of the gripping point of the clamping jaw according to the height information of all the non-potential interference areas, wherein the specific formula is as follows:
Δh=max{hi′}+Δh′
Wherein h i 'is the maximum height of the lattice of the ith non-potential interference area, max { } represents the maximum value, and Δh' is the collision avoidance factor, so that the clamping jaw is prevented from colliding with the non-potential interference area.
In this embodiment, a height difference threshold h T =3 mm, and a collision avoidance factor Δh' =0.5 mm is set. The potentially interfering areas 1, 2, 3 of the long cup head bolt M4 (f-shaped workpiece) are shown in the image as (d) of fig. 2, with a grip compensation height Δh=1.5 mm.
Step 3, determining a grabbing point searching area and an actual interference area of the clamping jaw according to the sorting target area, the potential interference area and the clamping jaw structure;
the step 3 is specifically as follows:
Generating a rectangular clamping jaw sliding window according to a clamping jaw structure, wherein the size of the clamping jaw sliding window is (w+2b) multiplied by h, w, b and h are respectively the opening distance, the clamping jaw thickness and the clamping jaw width of a parallel clamping jaw, the center of the clamping jaw sliding window is the horizontal projection position of a clamping jaw grabbing point, two side areas corresponding to the tail end parts of the clamping jaw in the clamping jaw sliding window are marked as grabbing shielding areas, and the size of each grabbing shielding area on each side is multiplied by b multiplied by h;
step 3.2, marking the minimum circumscribed rectangle of the sorting target area as a grabbing point searching area, and expanding the periphery of the grabbing point searching area based on the related size of the clamping jaw sliding window In the specific implementation, the acute angle formed by the short side of the smallest circumscribed rectangle of the sorting target area and the positive direction of the x-axis is recorded as the direction angle theta of the smallest circumscribed rectangle, and the direction angle theta of the smallest circumscribed rectangle is used as the main grabbing direction, as shown in (a) of fig. 3 and (b) of fig. 3.
And 3.3, screening all the thinned potential interference areas pixel by pixel, only reserving pixels existing in the sliding window searching area to form an actual interference area, carrying out reverse grabbing main direction-theta rotation transformation on the thinned sorting target area and the interference area around the minimum circumscribed rectangle center to reform a matrix image form, then placing different gray value marks on the sorting target area and the actual interference area in the sliding window searching area, and placing 0 on the pixels of which the other areas are background areas.
Setting search constraint conditions, carrying out grabbing pose detection according to grabbing point search areas and actual interference areas of clamping jaws, combining the search constraint conditions and compensating heights of grabbing points of the clamping jaws to obtain an optimal grabbing pose, if the optimal grabbing pose cannot be generated, enabling a current workpiece to be grabbed to be non-grabbed, selecting other workpieces to be grabbed in an RGB image of a current task as new workpieces to be grabbed, repeating the steps 2-3 and carrying out grabbing pose detection until the optimal grabbing pose is obtained, further controlling clamping jaws of a robot arm to achieve grabbing of the workpieces to be grabbed, optimizing and saving time for searching sliding windows of the grabbing point search areas through a genetic algorithm, avoiding the interference areas, improving the easy grabbing property of the workpieces, and determining the optimal grabbing pose.
In step 4, the search constraint conditions specifically include:
In the process of searching the grabbing point searching area pixel by pixel, when the grabbing pose of the clamping jaw is changed, pixels of the sorting target area but no pixels of the actual interference area are arranged in the corresponding sliding window of the clamping jaw, and only pixels of the background area are arranged in the grabbing shielding area.
In the step 4, a genetic algorithm is used for detecting the grabbing pose, when the interference area near one workpiece is too many, namely the workpiece is not grabbed, and the situation of initial group extinction possibly occurs, the total fitness of the group is 0, then the sorted workpiece of other workpieces to be grabbed in the current task RGB image, which is closest to the clamping jaw of the robot arm, is selected as a new workpiece to be grabbed, then grabbing detection is carried out on the other workpieces in the current task RGB image, detection is stopped after the termination condition is reached in the natural selection process, the individual with the optimal fitness is taken as an optimal solution, the optimal clamping jaw sliding window pose is obtained, the optimal grabbing pose is output after the compensation height of the clamping jaw grabbing point is combined, and the clamping jaw of the robot arm is controlled to complete grabbing once.
In the genetic algorithm, when a sorting target area or an interference area is not arranged in a clamping jaw sliding window corresponding to each individual or a grabbing shielding area is provided with a non-background area, the individual can realize directional extinction, and the fitness function of the genetic algorithm meets the following formula:
Wherein f (x ', y', theta ') is the fitness of each individual, x t′,yt' is two coordinate values of the mass center of the sorting target area in the sliding window, h is the jaw width of the parallel jaw, x ', y' is two coordinate values of the central point of the jaw sliding window, k j represents the span of the sorting target area in the sliding window range along the long side direction of the sliding window, and j represents different positions in the short side direction of the sliding window when the span is calculated; Represents the average value of all spans k j and is represented as absolute.
The specific process of performing the optimal grabbing pose search through the genetic algorithm in this embodiment is as shown in fig. 4 (a) -4 (d):
Establishing a population, namely defining a clamping jaw sliding window as an individual, wherein the pose, namely the gene characterization, is (x ', y', theta '), wherein (x', y ') is the center point coordinate of the clamping jaw sliding window, and theta' is the rotation angle of the clamping jaw sliding window. On the basis of N xy groups (x ', y ') of gene characterization, the gene theta ' is subjected to discrete treatment, and values (-90 degrees, 90 degrees) separated by 30 degrees are selected from 6 values of { -60 degrees, -30 degrees, 0 degrees, 30 degrees, 60 degrees and 90 degrees, and the initial population size is N=6N xy.
The natural selection is that whether a sorting target area or an interference area exists in each individual sliding window or a non-background area exists in a grabbing shielding area is firstly checked, if so, the situation that the individual cannot grab the corresponding grabbing pose is indicated, namely the individual adaptability is equal to 0, the situation is defined as directional extinction, the grabbing position is as flat as possible and is not too large to fluctuate, the grabbing point is as close to the middle position of a target workpiece as possible, namely the smaller the arithmetic average difference of the span of the sorting target area in the sliding window range along the long-side direction of the sliding window is better, the smaller the Manhattan distance between (x ', y ') and the centroid coordinate (x t′,yt ') of the sorting target area in the sliding window is better, and the grabbing function of the grabbing pose is designed as the adaptability function of natural selection:
Before randomly selecting surviving individuals, carrying out group extinction judgment. If the interference area near one workpiece is too many, the condition of initial group extinction possibly occurs, the total fitness is 0 at the moment, the output is not grippable, the subsequent other workpieces are subjected to gripping detection, and the workpiece can be gripped after the surrounding interference workpiece is gripped.
Randomly selecting surviving individuals by adopting a roulette wheel selection method, wherein the probability P l that the first individual in the population can be selected to survive is the share of the fitness f l (x ', y ', theta ') in the total fitness of the population:
Before each selection, the individuals with the largest fitness are reserved, then N-1 surviving individuals are selected according to the probability, the individuals and the fitness thereof are saved, the reproduction link is entered, and the survival probability of the individuals with high fitness is larger.
Gene recombination in the previous round of surviving individuals, two individuals are randomly paired for gene recombination, and only one new individual is generated at a time. Offspring c propagated from both individuals a and b formed their new gene representation (x c′,yc′,θc') using arithmetical recombination:
xc′=ωxxa′+(1-ωx)xb′
yc′=ωyya′+(1-ωy)yb′
θc′=ωθθa′+(1-ωθ)θb′
Wherein the first-third recombination factors omega x,ωy,ωθ E [0,1] are randomly given by the system. In this embodiment, there is more than one optimal grabbing point, and the problem that the final individual fitness is concentrated in the local optimal solution does not occur, so that the gene mutation process is not required to be added.
And (3) terminating the condition and outputting, namely checking whether the natural selection times reach the set times or whether the total fitness and the total fitness change rate of the previous round are smaller than the set threshold value when each round of natural selection is finished, and outputting the individual gene representation with the highest current fitness, namely the optimal sliding window pose (x m′,ym′,θm').
And (x m′,ym′,θm') rotating and transforming the grabbing main direction theta around the minimum circumscribed rectangle center of the sorting target area to obtain the optimal sliding window pose (x m,ym,θm) under the pixel coordinate system of the industrial camera, mapping and transforming the optimal sliding window pose, adding the compensating height, and then converting the optimal sliding window pose into grabbing pose information under the workpiece coordinate system, and controlling the clamping jaw of the robot arm to complete grabbing.
And 5, repeating the steps 1-4, continuously collecting images and grabbing corresponding workpieces to be grabbed in each image, namely grabbing the stacked workpieces sequentially from top to bottom until the workpieces in the images are grabbed, and completing robot grabbing.
The foregoing is merely illustrative of the present invention, and the present invention is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.