BallPerceptor - TJArk-Robotics/coderelease_2016 GitHub Wiki
#BallPerceptor
Table of contents
1.Description
2.fitball()
3.classifyBalls2()
1.Description
The BallPerceptor includes two function mainly: fitball() and classifyBalls2(). The fitball() function finds 24 edge points based on the ballspots and try to fit a circle using those edge points. If success, it saves the ballspot as a possible ball. Then all the possible balls are transferred to the second function called classifyBalls2(). classifyBalls2() is a classifier which uses some criteria to decide whether the possible ball is a valid ball. This classifier also assigns a score to those possible ball that meet the criteria, so that we can choose the most possible ball from them. These two function will be detailed as follow:
###First step: choose three points called guesspoint inside the circle whose center is ballspot and radius is calculated in BallSpotProvider. These three guesspoints should not be on a same line, so that the edge points found will not repeat. Then using these three guesspoints as start points to trace from the guesspoint to the region’s extrema. There are eight scan lines and they will finish when finding enough green pixels. The scan lines’ scanning directions and guesspoints are shown by the following figures:
guesspoint_1: guesspoint_2: guesspoint_3:
The edges found is as follows(which are yellow):
###Second step: After the first step, we get 24 edge points of a ballspot. In the second step we use these edge points to try to fit a circle. We use RANSAC algorithm to fit them. Since the method of least squares can be influenced by noise easily and the edge points found in the first step sometimes contain a few noise point, the RANSAC algorithm can get a better performance than the least squares method. Through these two steps descripted above, we get some possible ball. Then we re-calculate their center and radius and transfer them to classifyBalls2().
Score=tansig(ratio,0.3f)*0.2f + tansig(ratilTotal,1.2f)*0.4f + tansig(ratioGreen,0.7f)*0.4f
The tansig function can be seen in the BallPerceptor.cpp.
It is only confirmed to be a valid ball if all the 7 indexes above meet the requirements and the score exceeds the threshold. Finally, if no valid ball is confirmed, we can simply comprehend that as there’s no ball in the field of vision. If more than one ball is confirmed, we’ll take the one with the highest score as the convincing one.
The performance of this module is as follows:
near_circle_good:
goal_line: