Summary of the invention
It is an object of the invention to overcome deficiency in the prior art, propose a kind of based on binocular vision and ant group algorithm
Picking up table tennis ball robot operation method and equipment, realize the detection and positioning of table tennis, and carry out to the path cooked up
Redundancy route optimization further reduces the walking path of robot, has saved the time.
In order to solve the above technical problems, the present invention provides a kind of picking up table tennis ball machine based on binocular vision and ant group algorithm
Device people's operation method, characterized in that including following procedure:
Establish the global coordinate system in table tennis training place;
It obtains ground table tennis in the place of binocular camera shooting to be scattered the RGB image of situation, be detected from RGB image
Table tennis and obtain the coordinate position of each table tennis out;
The depth data for obtaining binocular camera, obtains distance of each table tennis apart from video camera;
According to the coordinate position of each table tennis and apart from the distance of video camera, the table tennis under global coordinate system is calculated
Coordinate point set;
Most short traverse path is carried out using ant group algorithm to coordinate point set to plan, obtains preliminary picking up course of action diameter;
The table tennis repeatedly passed through is removed from preliminary course of action diameter of picking up, obtains the path of no redundancy route.
Further, table tennis is detected from RGB image and obtains the detailed process packet of the coordinate position of each table tennis
It includes:
RGB image is converted into HSV image;
HSV image is changed into grayscale image, carries out Gaussian Blur;
Contour detecting is carried out using canny operator, obtains the profile of all objects in figure;
Using the circle in hough-circle transform detection figure, the table tennis in place can be detected out, and all table tennis are calculated
Coordinate position of pang the ball in figure.
Further, the distance according to the coordinate position of each table tennis and apart from video camera is calculated in global coordinate system
The coordinate point set of lower table tennis includes following procedure:
By the coordinate position of each table tennis and apart from the distance of video camera, it is transformed under camera three-dimensional system of coordinate, obtains
The coordinate point set of table tennis under camera measurements of the chest, waist and hips coordinate system;
Again by table tennis in the case where the coordinate under camera three-dimensional system of coordinate is transformed into robot coordinate system;
Finally table tennis is obtained in the case where the coordinate under robot coordinate system is transformed into global coordinate system in global coordinate system
The coordinate point set of lower table tennis.
Further, the coordinate position of each table tennis and distance apart from video camera are transformed under camera three-dimensional system of coordinate
Process include:
Establish camera three-dimensional system of coordinate XYZ, plane of delineation coordinate system xy;
The mapping relations of both camera measurements of the chest, waist and hips coordinate system midpoint P (X, Y, Z) and plane of delineation coordinate system midpoint p (x, y) are as follows:
Wherein, f is camera focus, and Z is the depth of the table tennis obtained from depth data, and x indicates plane of delineation coordinate
The x-axis coordinate of system, X indicate the X axis coordinate in camera three-dimensional system of coordinate;Y indicates the y-axis coordinate in plane of delineation coordinate system, Y table
Show the Y axis coordinate in camera three-dimensional system of coordinate;cxThe coordinate for being principal point in x-axis, cyFor the coordinate of principal point on the y axis, fxFor f
Pixel dimension in x-axis, fyFor the pixel dimension of f on the y axis;
The coordinate position of each table tennis is coordinate in plane of delineation coordinate system, and the distance apart from video camera is camera coordinates system
Three-dimensional coordinate P (X, Y, Z) of the table tennis in camera coordinates system is calculated according to above-mentioned formula in middle Z axis numerical value.
Further, table tennis is transformed into the process under global coordinate system in the coordinate under robot coordinate system are as follows:
Robot coordinate ties up to the origin of global coordinate system when starting, and coordinate is (x0, y0, th0)=(0,0,0), if machine
People movement speed V=(Vx, Vy, Vth), VxRefer to speed along the x-axis direction, VyRefer to speed along the y-axis direction, VthRefer to robot rotation
Rotary speed;Then after the dt time, coordinate of the robot coordinate system relative to world coordinates origin are as follows:
(x1, y1, th1)=(x0+(Vx*cos(th0)-Vy*sin(th0)) * dt, y0+(Vx*sin(th0)+Vy*cos
(th0)) * dt, th0+Vth*dt) (5)
According to the coordinate transformation relation for the robot coordinate system that formula (5) obtains, coordinate conversion can be carried out, in robot
Target table tennis spherical coordinates (X ', Y ') under coordinate system is transformed into the coordinate (X ", Y ") under global coordinate system are as follows:
(X ", Y ")=(x1+(X′*cos(th1)-Y′*sin(th1)),
y1+(X′*sin(th1)+Y′*cos(th1)))
The coordinate conversion for completing all tablees tennis, obtains the coordinate point set of the table tennis under global coordinate system.
Further, the table tennis for removing in course of action diameter and repeatedly passing through is picked up from preliminary, obtains the road of no redundancy route
Diameter includes following procedure:
Course of action diameter is picked up according to preliminary, it is assumed that robot is mobile to be moved to the 1st target table tennis from starting point,
Draw straight line b1、b2With d1、d2, b1、b2It is parallel to the line of starting point point and target table tennis two o'clock, and and machine
Device people is tangent in the minimum circumscribed circle of starting point;Straight line d1It is vertical with two o'clock line direction and and robot starting point minimum
The tail portion of circumscribed circle is tangent;Straight line d2It is vertical with two o'clock line direction and and minimum circumscribed circle of the robot in target point head
It is tangent;The rectangle that this four lines are constituted indicates robot region inswept from starting point to target point, calculates and obtains in four lines
All table tennis coordinate points in the rectangle of composition leave out these points from coordinate points concentration,
Then using this target point as starting point, next target point is chosen in course of action diameter from preliminary picking up, is carried out above-mentioned
Same operation;And so on, until the point for picking up all on course of action diameter is all disposed, finally obtaining one does not have redundancy road
The path of line.
Correspondingly, the present invention also provides a kind of computer readable storage medium for storing one or more programs, it is described
One or more programs include instruction, described instruction when executed by a computing apparatus so that the above-mentioned side of calculatings equipment execution
Method.
Correspondingly, the present invention also provides a kind of calculating equipment, including,
One or more processors, memory and one or more programs, wherein one or more programs are stored in institute
It states in memory and is configured as being executed by one or more of processors, one or more of programs include for executing
The instruction of the above method.
Compared with prior art, the beneficial effects obtained by the present invention are as follows being: the present invention is using binocular camera while realizing
The detection and positioning of table tennis, convenience and high-efficiency, while ensure that precision, so that it is more intelligent to pick up ball process;Ant colony is calculated
The path that method is cooked up carries out redundancy route optimization, further reduces the walking path of robot, has saved the time.
Specific embodiment
The invention will be further described below in conjunction with the accompanying drawings.Following embodiment is only used for clearly illustrating the present invention
Technical solution, and not intended to limit the protection scope of the present invention.
A kind of picking up table tennis ball robot operation method based on binocular vision and ant group algorithm of the invention, referring to Fig. 1 institute
Show, comprising the following steps:
Step 1, the map for obtaining table tennis training place, establishes global coordinate system.
Table tennis is obtained using the gmapping graph builder under laser radar and ROS (robot operating system) platform first
The static map of pang ball training court, then to map is denoised and is modified, and obtains available global static grating map, machine
Device people carries out navigation avoidance according to this map.As global coordinate system map, this coordinate system with rectangle training court some
Angle point is as origin, along the length-width direction of training court respectively as transverse and longitudinal coordinate axis.The table tennis detected below will
It is transformed under this coordinate system and shows.
Step 2, the RGB image for obtaining binocular camera, from detecting table tennis in RGB image and obtain it in figure
Coordinate points.
Binocular camera uses kinect, it has a RGB color camera and a depth camera.Binocular camera
It is mounted on robot front center position, visual angle head-up front takes 15cm to 40cm to be advisable apart from ground level.Robot is being picked up
Ball task start before shoot ground table tennis, in ROS platform simultaneously receive synchronization kinect RGB data and
Depth data guarantees that two data time stamps obtained are consistent.
As shown in Fig. 2, taking out the RGB image comprising several tablees tennis in the sometime place of kinect shooting, and will
Image is converted to HSV image, is filtered by the HSV numerical threshold of white table tennis, takes out white portion in image, that is, takes out
White object image including table tennis.Then HSV image is changed into grayscale image, carries out Gaussian Blur, allow image border
It is smoother.It reuses canny operator and carries out contour detecting, setting threshold value is 100 to 200, takes out the profile of all objects in figure.
Finally using the circle in hough-circle transform detection figure, the table tennis (coordinate of the table tennis in figure) in place can be detected out,
And the table tennis that coordinate point set of all tablees tennis in figure is calculated, and these are detected according to the sequence of detection from 1
It is numbered to N (table tennis number).
Step 3, the depth data for obtaining binocular camera obtains its corresponding depth according to the two-dimensional coordinate of table tennis and believes
It ceases (i.e. horizontal distance of the table tennis apart from camera), table tennis is calculated under robot coordinate system according to the depth information
Coordinate.
According to camera pinhole model, i.e., Utopian national forest park in Xiaokeng obtains two coordinate systems, and one as shown in Figure 3
Camera three-dimensional system of coordinate XYZ, wherein X-axis is parallel to ground and is parallel to the plane of delineation, Y-axis perpendicular to ground, Z axis perpendicular to
The plane of delineation;One is plane of delineation coordinate system xy, and the plane of delineation is perpendicular to ground;According to the intercept theorem in geometry, obtain
The mapping relations of both camera measurements of the chest, waist and hips coordinate system midpoint P (X, Y, Z) and plane of delineation coordinate system midpoint p (x, y) are as follows:
Wherein, f is camera focus, and Z is the depth of the table tennis obtained from depth data, and x indicates plane of delineation coordinate
The x-axis coordinate of system, X indicate the X axis coordinate in camera three-dimensional system of coordinate;Y indicates the y-axis coordinate in plane of delineation coordinate system, Y table
Show the Y axis coordinate in camera three-dimensional system of coordinate.
According to camera internal reference, above step is improved:
Due to actual difference, the principal point (origin of plane of delineation coordinate system) of each camera is different to establish a capital in image
Center;The pixel in the direction x and y is also variant, therefore above-mentioned formula (1) (2) are converted are as follows:
Wherein, cxThe coordinate for being principal point in x-axis, cyFor the coordinate of principal point on the y axis, fxThe amount of pixels for being f in x-axis
Guiding principle, fyFor the pixel dimension of f on the y axis.
As shown in flow chart 2.The internal reference matrix of calling interface function acquisition camera first, then according to above-mentioned formula (3)
(4) three-dimensional coordinate P (X, Y, Z) of the target table tennis in camera coordinates system is calculated, and (X, Y are obtained by calculated above, and Z is
The depth of the point, that is, horizontal distance of the table tennis apart from camera).Due to camera three-dimensional system of coordinate and robot coordinate system
(entitled base_link, using robot direction of advance as X-axis, the left side is Y-axis) direction is inconsistent, there are transformational relation, final table tennis
Coordinate of pang the ball under robot coordinate system is that (assuming that table tennis is whole on the ground, height coordinate is (X ', Y ')=(Z, X)
0) display in the RVIZ (ROS visualization tool), and under ROS platform.
Above procedure is repeated, the coordinate under robot coordinate system of table tennis composition all on ground in image is obtained
Point set.
Step 4: according to the transformational relation of robot coordinate system and global coordinate system, to the table tennis under robot coordinate system
Coordinate conversion is carried out, coordinate point set of the table tennis under global coordinate system is obtained.
The entitled map of global coordinate system, the entitled base_link of robot coordinate system.Base_link coordinate system exists when starting
(coordinate is (x to the origin of map coordinate system0, y0, th0)=(0,0,0), x, y, th respectively refer to x-axis coordinate, y-axis coordinate, two seats
The angle of mark system offset), if robot movement speed V=(Vx, Vy, Vth), VxRefer to speed along the x-axis direction, VyRefer to along y-axis
The speed in direction, VthRefer to robot rotation speed.Then after the dt time, base_link coordinate system is relative to world coordinates original
The coordinate of point are as follows:
(x1, y1, th1)=(x0+(Vx*cos(th0)-Vy*sin(th0)) * dt, y0+(Vx*sin(th0)+Vy*cos
(th0)) * dt, th0+Vth*dt) (5)
According to the coordinate transformation relation for the base_link coordinate system that formula (5) obtains, coordinate conversion can be carried out.By
Origin (the x of base_link coordinate system1, y1) and deflection angle th1The coordinate under global coordinate system can be calculated (by Fig. 4 institute
Show).The seat under global coordinate system map is transformed into target table tennis spherical coordinates (X ', Y ') under robot coordinate system base_link
It marks (X ", Y ") are as follows:
(X ", Y ")=(x1+(X′*cos(th1)-Y′*sin(th1)),
y1+(X′*sin(th1)+Y′*cos(th1)))
So far whole coordinate conversion works is completed.
Step 5: most short traverse path being carried out using ant group algorithm to obtained table tennis coordinate point set and is planned, is obtained preliminary
Pick up ball sequence.
Number order when first, in accordance with detection table tennis, calculates all tablees tennis distance between any two and is combined into two
Adjacency matrix Graph is tieed up, matrix row and column dimension is all the table tennis number N detected in figure, for carrying out shortest path
It calculates.Element in matrix is the distance between table tennis, such as row i and column j indicate between i-th of ball and j-th of ball away from
From.There is N number of table tennis, then the number of element is N in matrix2。
As shown in figure 5, the parameter alpha (weighted values of pheromones) of elder generation initialization with Ant colony algorithm when starting, β (visibility plus
Weight), ρ (evaporation raties of pheromones), Q (pheromones gain coefficient), initialization information element τ0, the number of iterations N.
Then table tennis is randomly choosed as starting point for each ant, and starting point is added to and is had already passed through
Point set C.Calculate separately current point to it is remaining without all the points (set O) probability P=τα*(γ)βWherein τ is two o'clock
Between pheromones pheromones, γ be distance between two points (distance is obtained from adjacency matrix graph) inverse.Using roulette
Method, select next point for each ant.A random number q is taken, the probability to first point is calculated, if it is less than q
Then continue to calculate next point;If the probability to some point is cumulative and is greater than q, the point is taken.For example, q=0.4, p1=
0.2, p2=0.3, p3=0.5, (pnIndicate the probability of n-th point of selection), then due to p1< 0.4, and p1+p2> 0.4, so taking
Second point is as next target.And so on all ants are moved to next target point, and the point is added to
In set through passing through (set C).
Above step is repeated, until all points are all added in the set having already passed through.Thus complete an iteration.
According to the path length that every ant of path computing of selection is passed by, i.e., according to path order, calculate table tennis it
Between distance and cumulative summation, such as path order is 2-1-3-4 (serial number in front demarcated by step), then path length is
Distance d of No. 2 tablees tennis to No. 1 table tennis1, in addition distance d of No. 1 ball to No. 3 balls2, in addition distance of No. 3 balls to No. four balls
d3, i.e. L=d1+d2+d3.All ants update the pheromones on each side: the information in each path between two o'clock after covering
Plain increment and the length in path where them are inversely proportional: add=Q/Lk(Q generally takes 50-100), wherein LkIndicate kth paths
Length, add indicate pheromones incrementss.Therefore updated pheromones are τ=(1- ρ) * τ0+Q/Lk。
Continue next round iteration using new pheromones;If (1) it is all complete to reach setting value N (50 times) for the number of iterations
At, or (2) pheromones increment add be less than certain threshold value (such as 0.01), then export traversal all the points approximate optimal solution (path
Length is most short).
Step 6: according to robot own form and the path come is cooked up, the table tennis that repeatedly passes through of removal, further
Shorten path length.
As shown in Figure 6 (in global coordinate system map), the sequence obtained according to step 5 path planning, it is assumed that robot is mobile
The 1st target table tennis be that (digital number indicates machine according to the table tennis sequential calibration identified in step 2, No. 0 point for No. 2 points
Current coordinate point of the device people when identifying table tennis, No. 2 points are the 2nd (number has been demarcated when detecting table tennis) identification
The coordinate points of table tennis out, it is used as the 1st target point in path planning), draw straight line b1、b2With d1、d2, b1、b2It is flat
Row in the line of No. 0 point and No. 2 point two o'clocks, and and robot No. 0 point minimum circumscribed circle (since robot shape may
Irregularly, robot can be enclosed in internal smallest circle completely and calls minimum circumscribed circle) it is tangent;Straight line d1With two o'clock line
Direction it is vertical and and robot it is tangent in the tail portion of the minimum circumscribed circle of starting point;Straight line d2It is vertical with two o'clock line direction and with
Robot is tangent on the head of the minimum circumscribed circle of No. 2 points;The rectangle that this four lines are constituted indicates robot from No. 0 o'clock to No. 2
The region that point is inswept (the considerations of for efficiency ignores for the unlapped part in four angles of rectangle).It calculates and obtains
All table tennis coordinate points in rectangle that four lines are constituted, i.e. point 4,7,15 in Fig. 4 delete these points from coordinate points concentration
It goes, because robot carries suction device or idler wheel ball picking up device, robot is in the process for being moved to No. 2 points from 0 point
In, these tablees tennis can be passed through, they all be picked up, i.e., machine artificially can will be within the scope of minimum circumscribed circle radial width
Ball, which is all picked up, to be come.It deletes these points and just reduces redundant traversal point, improve operational efficiency.
Then using No. 2 points as starting point, next target point is chosen from the path planning of step 5, to the two points
It is similarly operated according to the operating process of No. 0 point and No. 2 points.And so on, step 6 is repeated, until calculating in step 5
To path on all point be all disposed, finally obtain a path without redundancy route, this road is pressed by robot
Diameter pick up the efficiency of ball work than only using the path operation in step 5 efficiently, saves the time.
Correspondingly, the present invention also provides a kind of computer readable storage medium for storing one or more programs, it is described
One or more programs include instruction, described instruction when executed by a computing apparatus so that the above-mentioned side of calculatings equipment execution
Method.
Correspondingly, the present invention also provides a kind of calculating equipment, including,
One or more processors, memory and one or more programs, wherein one or more programs are stored in institute
It states in memory and is configured as being executed by one or more of processors, one or more of programs include for executing
The instruction of the above method.
It should be understood by those skilled in the art that, embodiments herein can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the application
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the application, which can be used in one or more,
The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces
The form of product.
The application is referring to method, the process of equipment (system) and computer program product according to the embodiment of the present application
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For member, without departing from the technical principles of the invention, several improvements and modifications, these improvements and modifications can also be made
Also it should be regarded as protection scope of the present invention.