An Automatic Grabbing Method of Manipulator Based on Monocular Ranging

Most existing studies on manipulator focus on the field of teaching and research. Other manipulators used for industrial production also have several disadvantages, including high cost, complicated control and low flexibility. Accordingly, in this paper, a simple automatic grabbing method of manipulator is proposed based on monocular ranging. The method is developed via the openmv vision platform. First, the target object is identified in the lens, the linear distance of the lens from the target object is calculated through monocular ranging, and then the inverse kinematics of the manipulator is exploited to calculate the rotation angle of each steering engine. Next, the contradiction between system speed and impact is balanced using the five-time curve trajectory optimization algorithm. The results of tests suggest that the method can achieve accurate capture of the target object in the grab range. The method, compared with the teaching and even the engineering manipulator system, is characterized by lower cost, simple and flexible control. Besides, it can be used to implement simple tasks in industry.


Introduction
With the advancement of science and technology and the advent of the Internet of Things era, the demand for robots and manipulators in various fields of China has been raising. The manipulator has become a vital tool to replace human work for its high production efficiency and low cost [1]. As a manufacturing country, a growing number of manipulators have been widely used in industrial production in China. However, the manipulators used at this stage are primarily teaching-type. Moreover, the operation before production should be demonstrated, and the working parameters should be recorded [2]. Other manipulators used for industrial production also have shortcomings (e.g. high cost, complicated structure and difficult control), which are not applicable to simple intelligent identification and capture tasks in industrial production. Thus, an automatic grabbing method of manipulator is designed based on monocular ranging. The method is simple in structure, low in cost and easy to control, capable of achieving accurate self-identification to capture the target object within the grasping range of the manipulator. Thus, it is very suitable for a simple object grasping task in The method adopts openmv as a visual platform, and balls of any color are taken as target objects. When the object to be tested reaches the grasping range of the manipulator, the target object can be identified by pattern recognition algorithm. Besides, the actual distance of the target object from the camera is obtained through monocular ranging. Subsequently, by building a cartesian coordinate system, the inverse kinematic geometric solution is employed to solve the required rotation angle of each steering engine based on the three-dimensional coordinates of the steering engine of the mechanical arm and the center point of the target object. To reduce the contradiction between the movement time and the impact amount, the grab trajectory of the manipulator is sampled using the five-curve trajectory optimization algorithm. Lastly, the sampled steering angle data is transmitted to the steering engine control board to achieve manipulator grabbing. The physical diagram and model diagram of the manipulator are illustrated in figure 1 and figure 2. The method block diagram is shown in figure 3.

Monocular ranging
Openmv is a powerful machine vision module with open sources and low cost. It has the core of the STM32F427CPU, outfitted with the OV7725 camera chip. On the small hardware module, the core machine vision algorithm is efficiently performed in C language, and the Python programming interface is created.
In this paper, openmv vision sensor is adopted as the monocular ranging implementation platform, primarily calculating the distance using geometric relations by single hole imaging. Because of its simple model, as early as the 20th and 70s, the United States and Germany followed the principle of monocular ranging in automatic highway driving [3].
The monocular ranging schematic is shown as: Figure 4. Schematic diagram of linear ranging. The schematic diagram suggests that: tan 1 = 2 1 (1) Where, A pix denotes the total number of pixels of the width of the image taken by the camera; B pix is the width pixel number occupied by the target object in the captured image; α 1 is half of the camera's perspective.
Moreover, the relationship between the right side of the camera of figure 1 is available: Equation (5) suggests that the result of * is a certain value, i.e., the distance of the object from the camera is inversely proportional to the width of the pixel occupied by the camera.

Mechanical arm inverse kinematics model
The inverse kinematics solution determines the angle of rotation of the four joint axes based on the given end position and position of the manipulator. At present, the common inverse kinematics of manipulator are primarily classified into three types (analytical method, iterative method and geometric method) [4]. Using the analytical method, the constraint equations are developed according to the structural composition characteristics of the mechanism. Various methods are adopted to eliminate the intermediate variables from the constraint equations. Besides, the single-parameter polynomial is obtained and then solved. This model has the advantage that all solutions can be obtained, whereas its disadvantage is that it has large difficulty and low versatility. The iterative method also has the problem that the whole solution cannot be obtained; the geometric method [5][6] has a small calculation amount for the simple structure of the manipulator; the calculation is simple; the four-degree-of-freedom manipulator used in the system is just right.
The motion model is illustrated as: Figure 5. Manipulator motion model. First, the x-axis deviation angle of the target object from the camera is calculated as: Where denotes the pixel point width coordinate of the center point of the target object; 2 is the maximum recognition angle of the camera.
Equation (5) and (6) The required corner angle of the arm servo is defined as: 2 = 4 − 3 (14) Based on the cosine theorem, the required corner angle of the elbow servo is expressed as: Where ℎ ℎ denotes the distance from the chassis steering engine to the bottom surface; is the distance from the boom joint to the target object; is the length of the boom; and is the length of the arm below the elbow joint.
Since the last joint aims to grab the object, the angle is determined by the size of the target object and does not vary with the movement of the object. Thus, it is not solved in this paper.
By solving the equation (6)

Trajectory optimization
During the movement of the manipulator, a contradiction has always existed between the movement time and impact of the manipulator, and effective trajectory planning can ensure that the trajectory is smooth and accurate under the premise of satisfying the constraint conditions [7]. In response to this situation, a five-point curve point-to-point optimization algorithm is adopted to optimize the contradiction between the joint motion time and acceleration of the manipulator joint, and the system is simulated to find the system motion velocity and acceleration curve. It is inclined to be flat, and the impact is significantly weakened [8].
The conventional cubic curve trajectory optimization algorithm is characterized by 0 initial velocity and end velocity, as well as smooth interpolation in the middle of the curve, which is often cited in the curve trajectory optimization. However, the acceleration of the cubic curve at the start and end points is not zero, i.e., the system exhibits an impact phenomenon and low stability. Thus, this paper uses five times curve in the optimization of curve trajectory, which better overcomes the impact phenomenon of the system at the end point.
Set the starting point angle as and the end angle as , and the intermediate variable s(t) is yielded as: The speed of movement of the manipulator is defined as: The system impact(the acceleration) is yielded as:

Straight line distance reliability verification
According to the openmv camera parameter configuration, the QQVGA mode with the image resolution of 160*120 and the lens wide angle of 115° is selected, and the yellow ball with a radius of 1.5cm is adopted as the target object, then: r = 15mm = 160 1 = 57.5° (26) According to equation (5): The test ball is placed at a certain distance from the camera, and the pixel width is recognized, and the straight line distance is calculated by the principle of equation (5). Due to the randomness of camera recognition, the test was split into 10 groups, each group needs to calculate 10 times of data and obtain an average value. The data distribution curve is shown in figure 6 and figure 7.  Figure 7. Proportional ranging curve. According to the figure 6 and figure 7, the linear distance between the object and the camera is inversely proportional to the number of pixels in the width. The theoretical distance from the actual distance is approximately 3%, and the accuracy can reach the grab condition.

Inverse kinematics simulation analysis of manipulator
The target object has two position variables for the system: the angle φ 1 of the object from the camera and the linear distance L of the object from the camera. Accordingly, for different φ 1 and L, 20 different sets of data are employed to simulate the model and compare it with the real angle. The simulation diagram is given as follows: Figure 10. Elbow steering machine corner scatter plot.   consistent with the actual Angle. A certain error exists between the steering angle of the elbow steering engine and the actual rotation angle, which is nearly 3.64%. The thickness of the mechanical jaw is acceptable for the error.

Trajectory optimization effectiveness analysis
Assuming that a movement requires 6s to complete, according to equation (23), it yields: s(t) = 0.0463 3 − 0.0116 4 + 0.00077 5 (28) Subsequently, the system motion distance-speed-acceleration can be expressed, as shown in figure  11. Figure 11. System position-speed-acceleration curve. Figure 11 suggests that the system speed and acceleration curves are inclined to be smooth, thus better avoiding the impact phenomenon of the system. To verify the feasibility of the algorithm, the joint position (degrees) of the three joints at five different time points are selected as test data [9][10]. The joint velocity is constrained at the moment, and after interpolation five times, the simulation is performed with MATLAB to observe the system motion curve. The location points and speed constraints are listed in Table 1 Table 4. Scissor speed scatter plot. The simulation results are shown in the Figure 12:  Figure 12. Fifth-order curve interpolation simulation. This figure suggests that after interpolation using the five-time curve optimization algorithm, the curve of the system speed and acceleration is both continuous and smooth, no system impact phenomenon occurs, and then the result of the optimization system is achieved.

Conclusion:
In this paper, an automatic grabbing method of manipulator is implemented based on monocular ranging. First, the linear distance of the target object is obtained using the monocular ranging algorithm. Subsequently, the inverse kinematics of the manipulator is solved to yield the steering angle of each steering engine. Lastly, the five-time curve trajectory optimization algorithm is employed to optimize the system interpolation, and the object can be grasped more accurately within the allowable error of the manipulator.