The Study of Mechanical Arm and Intelligent Robot

As an important part of the automation industrial system, mechanical arm robot plays an important role in service, exploration, automation engineering and other fields, and has a broad application prospect. The traditional mechanical arm and Sobel edge detection methods have some shortcomings: 1. The PID method is separated from the ontology model and only carries out simple and multiple calculations according to the code of the steering engine, which is not stable enough and will cause more time consumption; 2. In some complex environments, while Sobel edge detection is detecting the shape of objects, the separation between subject and background is not clear, which makes it impossible to obtain accurate object information. Therefore, this paper proposes a new PID method and Canny edge detection algorithm: 1. PID method combined with three-dimensional coordinate system modeling, to achieve a more stable, faster and more robust calculation formula, to complete the mechanical arm grasping function; 2. Using Canny edge detection and three-dimensional coordinate system to analyze the object image to obtain the accurate information of the target object.


I. INTRODUCTION
With the progress of science and technology, it is of great significance to study wheeled cars equipped with mechanical arms in today's informational and automated world. Through the camera mounted on the robot arm to collect images and image processing and target recognition, so as to control the robot arm to accurately grasp the target object. Therefore, it occupies an important position in maintenance, exploration, automation engineering and other fields, and has become an important part of the modern automation industry system, and has a broad application prospect [1]. As computer engineers, our duty is to make people's life easier. However, in all these studies and inventions, the main users are mostly normal people. A high-speed and lightweight badminton mechanical arm designed by Mori et al. [2], a writing mechanical arm designed by Potkonjak et al. [3] and a lower limb rehabilitation robot designed by c. Wang et al. [4] are good applications of the mechanical arm. But statistics show that there are more than 600 million disabled people in the world. With recent campaigns and foundations, technology is beginning to adapt to people with disabilities. This process of technological The associate editor coordinating the review of this manuscript and approving it for publication was Okyay Kaynak . adaptation is the main inspiration for us to carry out this research, bringing technological convenience to those who live in inconvenience [5].
In 2016, Ren c. Luo et al. designed a dynamic obstacle avoidance and three-dimensional target recognition intelligent seven-degree-of-freedom robot, and elaborated the method for evaluating the service quality of robot arm system. For this reason, a system structure of robot arm system is proposed. The realization of this system includes object recognition based on 3d model, grasping database of objects and online non-contact obstacle avoidance based on human-computer interaction security [6]. Over the years, object recognition technology for real world applications has developed rapidly. Object recognition based on vision uses 2D or 3D vision sensor [7] to extract object shape, edge or landmark features [8]. Object edge information is considered as the most important feature recognition object [9]. At the same time, according to the mechanical arm to grasp the object and then use the wheeled robot to move, complete the intelligent robot design.
Mechanical arms have been an active area of research. Several important studies including mastery planning, operations, and stability analysis have been completed. The complete capture process requires the integration of multiple aspects such as visual and PID control. Since vision can provide rich information about the shape and position of objects and control the ideal position of the fingers of a robot hand. As a result, there are many in the research on robot visual object recognition and locating provides more methods: in the IEEE mechanicals and automation international conference proposed a system USES Gordon and lowe's core algorithm, and through the model of alignment procedure, gesture automatic initialization steps of the registration and the combination of the mean shift clustering to extend this algorithm [10], [11], La tuanan and song zaibo suggested using the window method as one of the local feature descriptors and using SURF algorithm to select robust and intuitive visual servo features of objects [12], [13]. Kim et al. [9] proposed a visionbased multi-atypical object recognition method, including reflector objects or flexible shape objects. Neural network subdivision was used to train multiple objects of various types. Mario fritz proposed a unified object recognition framework based on robot vision, which first detects the target object, infers the grasping ability of the target object, and then performs robot operation to grasp the target object [14]. Dr. Amitabh Wahiet al. proposed a training method based on artificial neural network (ANN). The back propagation algorithm of feature data extracted from the rotating edge image is used to improve the accuracy of object recognition and reduce the operation time [15], [16]. At the same time, many scholars are studying the control and positioning of the robot arm: as for control, PID is a classical and robust control algorithm. Jingqing Han study the immunity PID transport operator control (the Active disturbance rejection control the ADRC) and the control process [17]; E. m. Jafarov et al. designed a PID controller applied to the mechanical arm and carried out simulation test [18]. Regarding the positioning of mechanical arm, hwi-su Kim et al. studied the positioning methods of telescopic mechanical arm in different situations [19], [20].
The intelligent robot proposed in this paper is a wheeled robot combined with a mechanical arm, and the vision through the camera is used to accurately grasp the target object. An automatic object grabbing system based on wheeled robot equipped with mechanical arm is studied. The image recognition [21] and calibration system processes arbitrarily complex target objects and is based on the basic features of a single image. It is robust to similar color composition, similar size, and light variation. It can detect multiple objects simultaneously in a single image to judge the target object and provide accurate size and distance estimation. Based on the information, PID algorithm is used to calculate the pose of the robot arm, and finally the object is grabbed and moved. Image processing combined with wheeled robot [22] and other technologies are used to improve the accuracy and operational efficiency of the mechanical arm to grasp the target object.

II. SYSTEM ARCHITECTURE
The hardware architecture of this study is shown in figure. 1, which is divided into micro control unit, input and output. 1) Arduino UNO: Arduino UNO is the MCU board of the system architecture, responsible for controlling the input and output of the system.
2) Rapsberry Pi 3B+: It is a new type of MCU board, which can be combined with Webcam, specially used in image processing, and can carry the analysis and calculation of visual images.

B. INPUT
1) Battery: The voltage is 7.4V, and the two groups of batteries are respectively used by wheeled robot and mechanical arm.
2) Sensors: HC-SR01 ultrasonic sensor and LXD3526 photosensitive resistor. The ultrasonic sensor is used for measuring the distance, and the photosensitive resistor controls the LED light according to the intensity of the external light. Front and back LEDs are used for lighting, and side LEDs are used for flashing.
C. OUTPUT 1) Four Ways DC Motor Driver Board: The type is L298N. The board can receive PWM control signal from MCU (Arduino) and integrate the power supply voltage to control the four dc motors.
2) Direct Current Motors: DC Motors are used to enable the wheeled robot's mobile functionality.
3) Six Way SE Driver Board: The type is LSC-32. The board receives the coded signal from the MCU (Arduino) and integrates the power supply voltage to control the steering engine operation of the mechanical arm. 4) Steering Engine: The type is LD-1501MG. As the joint of the robot arm, it completes the movement of the mechanical arm. 5) Display module: Aim is to show the surroundings.

D. INPUT & OUTPUT
1) WIFI Module: The type is ESP8266. The WIFI module completes the MCU and APP information sending and receiving function in full duplex mode. VOLUME 8, 2020 2) APP: This APP is developed on android platform. APP information transmission is realized according to TCP/IP protocol. It can send instructions to MCU (Arduino) through WIFI module to control robot movement and receive feedback information from robot.
3) Camera: Camera 5MP is used to obtain images of target objects.

III. METHODOLOGY
The Methodology of this paper can be divided into two parts: Mechanical arm and Image processing.

A. MECHANICAL ARM
The Methodology of Mechanical Arm can be divided into two parts: 3D Coordinate System Modeling and PID Algorithm.

1) 3D COORDINATE SYSTEM MODELING
3D coordinate system modeling of the mechanical arm is shown as figure 2, with the propose of obtaining the coordinate value at any position on the arm. Take the steering engine O as the origin of coordinates, already known that the length of the arm between the steering engine O and the steering engine A is L, the propose is to find the inclination Angle α, β and γ of L for the x-axis, y-axis and z-axis.
First, find the coordinate of the steering engine A. As shown as figure. 3: The origin of coordinates is O. Point M presents steering engine A. OQ presents the negative half of the x-axis. Project OM onto xOy plane, make NP perpendicular to the y-axis. Let the Angle between ON and the x-axis be δ, which is the angle of rotating table. Let the Angle between OM and ON be ζ , which is the angle of steering engine O (When calculating, both δ and ζ are reduced to acute angles). We can know that It can be known from the projection property that MN is perpendicular to ON, and the trig value of β can be obtained by three times of cosine calculation β H is the projection Angle of OM in plane xOy to y-axis, and β w is the projection Angle of OM in plane yOz to y-axis. The trig value of α can be obtained by combining (3) to (5) tan α = cos 2 ζ sin 2 δ + cos 2 ζ According to the formula (1) (2) (6), the coordinate value of the corresponding steering engine A can be obtained, which is (Lcosα, Lcosβ, Lcosγ ).
Next, find the coordinate of the steering engine A. Set steering A as the origin of coordinates called O . Make x, y, z-axis with the same direction as xyz-O coordinate system. Use the corresponding arm length L and the x, y, z-axis inclination of L calculated by the above steps, which are α', β', γ '. Then steering engine B's coordinate values in the xyz-O' coordinate system can be calculated, which is (L'cosα', L'cosβ', L'cosγ ). Transformation to the xyz-O coordinate system is (L'cosα'-Lcosα, L'cosβ'-Lcosβ, L'cosγ '-Lcosγ ). With the above process, the coordinate values of steering engine C and steering engine D can be obtained [23], [24].

2) PID ALGORITHM
The PID algorithm implementation is shown as formula (7).
where, u(t) is the output signal of the regulator, specifically is the coordinate of the destination position; e(t) is the deviation signal of the regulator, specifically is the coordinate of the current position; Kp is the proportional coefficient, which is adjusted according to the actual situation. Ti is integral time; Td is the differential time; u 0 is the control constant [25]. This paper uses discrete PID controller, two formulas are presented according to the different functions of the use.
1) Grabbing process combined with the image processing After image processing by method B, position control method is used in the grabbing process, as shown in the following formula.
Current position output Last position output where, Kp, Ki, Kd and are the coefficients, and u(t) is the output control quantity. e(t) is the sum of the deviations in the past time. The position-type PID controller uses the accumulative sum and the difference of the deviation value to replace the integral and differential [26].
2) General control process The general control process is incremental output control, as shown in the following formula.
Formula (10) can be obtained from formula (8) and (9). Incremental formula is used for the control process of receiving general instructions for three reasons: 1. 2. u(t) is related only to recent deviations; 3. The calculation error has little influence on the calculation of control quantity. Therefore, the optimal control law can be obtained.

B. IMAGE PROCESSING
Image processing includes three parts: color recognition, Canny edge detection and distance measurement.

1) COLOR IDENTIFICATION
The color pictures obtained by the camera are converted into HSV color model space. H represents hue, s represents saturation, and v represents lightness. As shown in equation (11), lightness is equal to the maximum of three values of r, g and b; As shown in equation (12), when lightness is not equal to 0, saturation is equal to lightness minus the minimum of three values of r, g and b, otherwise it is equal to 0; In equation (13), if the value of lightness is equal to the value of r, as shown in the first case, if the value of lightness is equal to the value of g, as shown in the second case, and if the value of lightness is equal to the value of b, as shown in the third case, the value of hue can be obtained.
The value of the hue obtained in the above three cases is negative as shown in equation (14), otherwise the value of the hue will not change. Finally, the RGB value of the color image is converted into HSV value [27]. 2

) CANNY EDGE DETECTION
Smoothing the input image with a Gaussian filter, assuming that H(x,y)(15) represents a Gaussian function, and f(x,y) represents that the input image forms G(x,y) as a smoothed image by convolution of H(x,y) and f(x,y), as shown in equation (16); Any two points in the image are represented by a matrix (17), and then the amplitude (20) and direction (21) of the gradient are calculated by using the finite difference (18)(19) of the first derivative; ϕ(m, n) = ϕ 2 1 (m, n) + ϕ 2 2 (m, n) (20) The non-maximum suppression of gradient amplitude is continued, and the non-maximum element is further suppressed to determine the optimal edge region by searching for local maximum. The formula for suppressing N(x, y) is (22); In equation (22), M(x, y) is the current region and θ (x, y) is the suppression region. Finally, double threshold algorithm is used to detect and set two thresholds, as shown in equation (23); In the process of processing the image, the conversion value of pixels whose gradient value is less than th 1 is set to 0 to obtain the Figure 9. Then, the conversion value of the pixel whose gradient value is less than th 2 is set to 0 to VOLUME 8, 2020 obtain the Figure 10. Due to the higher threshold of Figure 10, most of the clutter is removed and fewer non-zero pixels are obtained. However, the threshold of Figure 9 is lower, and relatively more non-zero pixels will be obtained. We connect the edges of the image based on the Figure 10 and supplemented by the Figure 9. The connecting method is to scan the Figure 10. When a non-zero pixel p(x, y) is encountered, the contour line with p(x, y) as the starting point is tracked until the end point q(x, y) of the contour line. Contrast the 8 adjacent areas of q(x, y) in Figure 9, and the corresponding point s(x, y) in Figure 10. If non-zero pixels exist in the 8 neighborhood of the s(x, y) point, it is included in the Figure 10 as r(x, y). Starting from r(x, y), repeat the first step until it is impossible to continue. When the connection of the contour line containing p(x, y) is completed, the contour line is marked as accessed. Go back to the first step and find the next contour line. Repeat steps 1, 2, and 3 until no new contour line is found in Figure 10 [28], [29].

3) DISTANCE MEASUREMENT
When judging the size information of the target object, the distance information between the object and the robot shall be calculated according to the three-dimensional coordinate system established by the steering gear of the hand-type robot as shown in Figure 4. In the figure, points A, B and E are perpendicular to the center line of the camera imaging direction, and CAB = Alpha, AE = H, BE = H. The robot heights AE and Alpha are known. The value of the height h of the object is obtained by image processing, as shown in equation (24), and then the distance between the robot and the object can be obtained by equation (25).

IV. FLOW CHART
As shown in figure. 5, the system flow chart can be divided into four parts: initialization, communication, image recognition and intelligent robot grasping.

A. INITIALIZATION
MCU (Arduino) starts to run, camera initializes and WIFI module works and connects mobile phone APP.

B. COMMUNICATIONS
It is the first time to judge whether an instruction from APP has been received. If it is received, it goes to the second judgment to judge whether there is a grab command. If there is a capture command, enter the image recognition; If it is not a grab command, the wheeled robot performs corresponding actions according to the command and then ends. If you do not receive instructions from APP, end.

C. IMAGE RECOGNITION
First, judge whether the external light is dark. If it is dark, turn on the illuminating LED lamp. Then the camera works to identify the object and obtain the size of the target object and the distance from the robot arm, which is sent to Arduino in numerical form. The description is as follows: (1) Original Image: The camera acquires the original image.
(2) Converting color pictures into HSV model space for output.
(3) Converting the HSV component range into a binary picture.
(4) Morphology: the binarized image is processed through erosion and expansion.
(5) Labeling the area that conforms to the color of the target object. (6) Clipping and outputting the area in the label through the coordinates of the label.
(7) Gaussian filter is used to smooth the output labels, and then the first derivative finite difference, non-maximum suppression and double threshold algorithm are used to detect the labels. Finally, a clear and complete image of object edge operator is obtained. (8) Using the coordinates of the object edge operator, the height and width values of the object are obtained.
(9) Comparing the height-width value of the object in the label with the target object.
(10) If a picture shows that the size of the object in the label is the same as that of the target object, the distance between the steering gear and the object is calculated according to the three-dimensional coordinate system of the steering gear. Otherwise, the robot moves to recapture the picture.
(11) According to the size and distance obtained by the above algorithm, the robot arm grasps the target object.

D. INTELLIGENT ROBOT GRASPING
(1) Arduino establishes a xOy rectangular coordinate system model according to the numerical values of large and small distances, and positions the palm and the target object in the rectangular coordinate system model. The coordinate point of the target object is the center point of the object, and the coordinate point of the palm is the palm. At the same time, the size information of the object is input, and the required opening and closing degree of the robot hand to grasp the target object is calculated.
(2) The first judgment in grabbing, judging whether the robot is within the grabbing range of the mechanical arm, and if not, driving the wheeled robot to move to the grabbing range.
(3) According to the specified grabbing time, the Period is selected for PID operation and the arm is moved according to the operation result. Each Period makes a judgment to determine whether the palm of the robot arm has reached the position of the object. If not, perform a Period PID operation again and move the arm according to the result of the operation. Until the position of the object is reached. This is the second judgment in grabbing.
(4) After reaching the position of the object, control the palm to close and grab the object according to the size of the object.
(5) After completing the grabbing process, the operator can control the wheeled robot to move through the mobile phone APP and transport the object to the designated position.

V. SIMULATION COMPARATIVE AND ANALYSIS
The simulation, comparison and analysis of this paper contain two parts: Improved PID algorithm and Image Processing.

A. SIMULATION AND COMPARISON OF IMPROVED PID ALGORITHM
Select the steering gear rotation transfer function as: The experimental simulation is performed in MATLAB Simulink, choosing incremental PID simulation. The structure diagram is shown as figure. 6.  It can be seen from the figure 7, that the simulated waveform is stable and close to the target value after the waveform oscillation of about 20% of 0.2s. Compared with the PID algorithm in [30], the response time required by this algorithm is shortened by nearly 60%, and the output is smoother. PID simulation waveform in [30] is shown as figure 8. Through the elaboration and analysis of Canny edge detection algorithm, the basic principle and implementation steps of the algorithm are mastered. In order to clearly compare the advantages and disadvantages of each algorithm, this paper VOLUME 8, 2020    uses python language through anaconda software to carry out edge detection algorithm and analysis on the original images containing various objects and single object images. The original picture of the experiment is shown in figure 9. Figure 10 is a picture of a single object; The test results are shown in figure 11. The test results of various edge detection are shown in Table 1.    Table 1 and the edge detection of the original picture and single object picture, the advantages and disadvantages of each algorithm are obtained. The edge detected by Sobel algorithm is thicker and fuzzy than that of other algorithms. The Laplace algorithm is relatively accurate in locating image edges, but its disadvantage is too much clutter. Compared with other edge detection operators, Canny algorithm obtains complete and continuous edges, and can keep balance between false detection and missed detection.   of Canny edge detection at different thresholds is shown in table 2.
From Table 2, it can be clearly seen that when the threshold is lower, there are more and fuzzy clutter, and when the threshold is higher, the edge information is incomplete. When the ratio of high and low thresholds is different from that shown in formula (23), the obtained edge detection picture is fuzzy and noisy, and the ratio of high and low thresholds is the same as that shown in formula (23), the obtained edge detection picture is complete and clear.

VI. EXPERIMENTAL RESULT
The experimental results in this chapter are divided into two parts: robot arm grasping the target object and image processing. A. The APP interface designed in this paper is shown in figure 13. APP communicates with MCU by entering IP number and PORT number of WIFI module.  The target object of this experiment is a red object. First, the camera takes pictures to obtain the original image of the target object, as shown in figure (c). Then raspberry party carries out image processing on the target object and labels the target object (red), as shown in figure (d). Calculate the relevant data of the target object: size, distance and angle of the robot, etc. As shown in figure (e).
According to the data obtained, the robot points its arm at the target object, as shown in figure (f). And extend the arm to determine whether the target object is within grasp range, as shown in figure (g).
As shown in figure (g), the target object is out of grasp range. Control the robot to move to the grasping range, as shown in figure (h) and figure (i).
As shown in figure (i), the target object has entered the grasping range of the robotic arm, then grasps the object according to the data obtained from image processing. The grasping process is shown in figure (j) and figure (k).
As shown in figure (k), the robotic arm has captured the target object and transported it to the placement point. The robot turns right and moves towards the placement point, as shown in figure (l) and figure (m).
After the robot moves to the placement point, the APP controls the robotic arm to place the object in the placement Similarly, change the target object to black tape. Once again, the object is captured and transported. After obtaining the data, the robotic arm grasps the target object. The grasping process is shown in figure (a) and figure (b).
The robot moves to the placement point and places the object in the placement point. The placement process is shown in figure (c), figure (d), and figure (e).

VII. CONCLUSION
This paper presents an intelligent robot with improved PID algorithm and image recognition. It can complete the whole process from identifying the target object, moving to the target object, automatically grabbing the object and transporting the object, and has high intelligence. The experimental results show that the improved PID algorithm has a shorter response time when reaching the target position compared with the traditional PID algorithm. At the same time, the combination of image processing technology makes the robot more accurate and fast in acquiring the positioning and size information of the target object. In the future, the robot can be used in industrial production, logistics and transportation, exploration and other fields.