# Robotic Grasping of Unknown Objects Based on Deep-Learning Based Feature Detection
## 2 Methodology
### Determination of Grasp Position from Parallel Edges  
With the key features and parameters of the object (straight edges, corners, perimeter, area, and centroid) extracted, the algorithm can then proceed to derive a grasp position. The algorithm determines a grasp position by identifying the two points where a two-fingered robot gripper should contact. From the features detected, the algorithm starts with a search for parallel straight edges closest to the object centroid to grasp while avoiding the corners. Figure 6: Feature detection and determination of abstract shape: The red boxes show the detected straight edges and the pink boxes show the detected corners. The yellow line shows the concave hull of all these detections, which provides the estimated perimeter and enclosed area of the object. The yellow circle shows the estimated centroid of the object derived from this concave hull. Figure 7: Image segmentation and parameter extraction: two objects with their geometric perimeter and centroid highlighted in blue. Figure 8a illustrates an example of an object with multiple detected features. For each \(E_{i}\in E\), the distance \(D_{i}\) from the object centroid \((x_{c},y_{c})\) is calculated as:  
\[D_{i}=\sqrt{(x_{c}-x_{E_{i}})^{2}+(y_{c}-y_{E_{i}})^{2})} \tag{6}\]  
All \(E_{i}\in E\) are then sorted in ascending order of \(D_{i}\). Starting with \(i=1\), \(E_{i}\) and \(E_{i+1}\) are compared to find a pair that is parallel by calculating the difference in angle \(\Delta\theta\) between the two edges:  
\[\Delta\theta\ =|\theta_{E_{i}}-\theta_{E_{i+1}}|\leq\theta_{max} \tag{7}\]  
where the initial threshold value \(\theta_{max}\) is user-defined. For example, an initial \(\theta_{max}=10^{\circ}\) can be considered as close to parallel. Figure 8b illustrates the comparison between two edges. \(\Delta\theta\) between these two edges is close to 90\({}^{\circ}\) and hence is larger than the threshold. As such, this pair is not chosen. Following this step, a series of checks ensure that the pair is properly aligned for grasping. This is accomplished by drawing a line between the center of the two detected edges \(x_{E_{i}},y_{E_{i}}\) and \(x_{E_{i+1}},y_{E_{i+1}}\). The acute angle \(\theta_{line}\) formed by the line and one parallel edge is then calculated. The line should have an angle difference with the angles of detections greater than a user-defined threshold \(\theta_{diff\_min}\):  
\[|\theta_{line}-\theta_{E_{i}}|\geq\theta_{diff\_min} \tag{8}\]  
for instance, \(\theta_{diff\_min}=60^{\circ}\). A poorly aligned pair of features, as depicted in Figure 8c, will likely be difficult to grasp. This pair is not selected, as the angle difference is less than 60\({}^{\circ}\) from the angles of the detections and is deemed unsuitable. The next check ensures that the distance between the two identified edges is not larger than the maximum opening of the gripper. This maximum opening \(d_{max}\) in pixels can be calculated as follows:  
\[d_{max}=m\times\frac{f}{d} \tag{9}\]  
where \(m\) is the measured physical maximum opening of the gripper in cm, \(f\) is the focal distance of the camera in pixels, and \(d\) is the measured physical distance of the camera from the workspace in cm. Figure 8d shows a shortlisted feature pair for grasping. Although they have a small \(\Delta\theta\) and are properly aligned, the distance between them is larger than \(d_{max}\) and hence is not graspable. As such, another pair with distance less than \(d_{max}\) is chosen, as illustrated in Figure 8e. After choosing a suitable pair of edges, some optimization is performed to account for the difference in lengths of the edges detected. If the algorithm determines the grasp position from the center of the bounding box without accounting for the differences in length, it results in a grasp position with a poor orientation, as illustrated in Figure 8e. It can be observed that the robot fingers do not have to be in the center of the detected bounding box; it can be anywhere along the length of the bounding box.