Handling Four DOF Robot to Move Objects Based on Color and Weight using Fuzzy Logic Control

— Manipulators are increasingly used in industry to improve efficiency in jobs that require precision, long duration, and repetitive work. This research was conducted on a laboratory scale to control manipulators on a pick-and-place system in the product storage and packing area. The object of this research is a four-degree-of-freedom (4-DOF) manipulator controlled using a fuzzy logic system. The hardware used is a conveyor machine to model the product delivery process, Dobot Magician as a 4-DOF manipulator, HX711 load cell serves as a weight sensor, TCS-3200 serves as a color sensor, and Arduino Mega 2560 as a controller. The software used is Dobot Studio as the main program to control the movement of the robot and Matlab to develop the Fuzzy Logic Control (FLC) function, which is embedded in the Arduino. Fuzzy logic control processes weight variables and color variables read by sensors as information data to control the movement of the manipulator. The results showed that the manipulator was able to pick up and place objects according to the path-planning coordinates. The testing data states that the precision and accuracy of the average coordinates of product pick and place against the path planning has an error deviation of 1.8%.


I. INTRODUCTION
In recent decades, there has been a significant surge in the use of robots for industrial automation.This trend is a response to the challenges faced by industries to improve their production efficiency, accuracy, speed and capacity.The integration of robotics technology into industrial processes has enabled industries to address these issues effectively, leading to increased productivity and better results [1]- [4].In compliance with the demand for smart and efficient industrial machines, researchers are conducting extensive studies in the area of robotics.The goal is to augment the intelligence of robots and enhance their operational capacities [5]- [8].This research was conducted on a laboratory scale using the Dobot Magician manipulator as a model for the application of industrial robots in pick and place applications.This research aims to prove the application of fuzzy logic control on manipulators for pick and place functions with input parameters influenced by weight variables and color variables [9]- [12].

II. RELATED WORK
To realize this research, a study of related matters is carried out, including the specifications of the Dobot Magician as the main model in this study, the kinematics of the Dobot Magician, the Denafit Hartenberg method to express the relationship between Dobot Magician joints and the Fuzzy logic control system.

A. Dobot Magician
The Dobot Magician is a robotic arm that has four degrees of freedom (DOF).It is made up of a base, a shoulder, an elbow, and a wrist.The base, shoulder, and elbow are powered by a stepper motor, while the wrist is powered by a servo motor.The Dobot Magician's end Effector is compatible with a variety of attachments, such as suction cups, grippers, laser printers, 3D printing hot-ends, and pen holders for drawing graphs [12]- [15].The Dobot Magician has a structure diagram that consists of four joints, known as J1, J2, J3, and J4.The initial balance point is at J2, with coordinates of (0, 0, 0).The movement position is defined as (x, y, z).The Dobot Magician comes equipped with a power supply and active indicator lights.The manipulator's forearm length is 135 mm from the base, rear arm length is 147 mm, front arm length is 160 mm, and end effector length is 72 mm.Fig. 1 displays the mechanical structure diagram of Dobot Magician.Fig. 1 shows that the Dobot Magician operates on a mechanical structure that enables it to move rotationally.The rotation of the drive motors at J1, J2, J3, and J4 determines all the robot movements.Additionally, Fig. 2 displays the dimensions and working area of the Dobot Magician, providing a comprehensive understanding of its capabilities.Fig. 2. Dimensions and working area of Dobot Magician [2] In Fig. 2, the robot's working area range is described to have a radius of 320 mm.The rear arm is capable of movement up to 180 0 , while the base has a rotational range of ± 135 0 .The shoulder joint has a movement radius of up to 85 0 , and the front arm has a movement radius of -10 0 to 95 0 .Table II shows the joint axes and movements of each joint.-135 0 to 135 0 320 0 /s Joint 2 (Rear arm) 0 0 to 85 0 320 0 /s Joint 3 (Fore arm) -10 0 to 95 0 320 0 /s Joint 4 (Rotation servo) 90 0 to -90 0 480 0 /s

B. Robotic Kinematics
In the working mechanism of a manipulator, two types of analyses are commonly used: kinematics analysis and dynamics analysis [16]- [19].Kinematics analysis is defined as the study of robot movement in terms of speed, position, and acceleration while ignoring the forces that affect the robot [20], [21].The Robot kinematics system consists of two types of movement analysis: forward kinematics and inverse kinematics [22]- [27].Forward kinematics uses the angle of movement as a reference to obtain the position coordinates of the robot's end effector.Forward kinematic roles in determining the position of the end of the effector, planning the trajectory, and controlling joint movement [28]- [30].Inverse kinematics uses the position coordinate as a reference to obtain the angular value of the robot joint movement [31]- [33].Inverse kinematics has the role of controlling the position of the end of the effector, joint movement planning, and trajectory control [34].The robot kinematics system requires a control system as a driving force consisting of input or reference, controller system, and robot mechanical system.The input reference is in the form of position, velocity, or acceleration and is expressed in a vector coordinate of position (P) and orientation (x, y, z).The output is an angle  ( 1 ,  2 ,  3 …   ) where n is the number of joints on the robot.A control diagram of the robot kinematics system is shown in Fig. 3.

C. Denavit Hartenberg Method
The Denavit Hartenberg (DH) method is one of the most commonly used methods in determining robot kinematics parameters.DH parameters are used to describe the relationship between each joint on the manipulator.Without a description of the relationship between joints, robot kinematics cannot be implemented.In a four DOF manipulator with revolute joints  1 ,  2 ,  3 ,  4 , and  5 each connected by a link, it gives a kinematics picture that the manipulator has four links (link 1, link 2, link 3, and link 4), with the end-effector as an object that can be lifted and placed.[36]- [42].The DH method is expressed in four parameters: twisting angle   , length of link   , link offset   , and the joint angle [43]- [46].To describe the relationship between joints and links in the 4 DOF manipultor, it can be explained as follows: 1. First Joint ( 1 ): •  1 is the rotation angle along axis  0 (first joint rotation).•  1 is the distance along axis  0 to the first joint (link length 1).•  1 is the length of link 1 connecting the first joint to the second joint.•  1 is the angle between axis  0 and axis  1 .
•  2 is the distance along axis  1 to the third joint.
•  2 is the length of link 2 connecting the second joint to the third joint.•  2 is the angle between axis  1 and axis  2 .

Third Joint (𝜃 3 ):
•  3 is the rotation angle along axis  2 (third joint rotation).•  3 is the distance along axis  2 to the fourth joint (length of link 3).•  3 is the length of link 3 connecting the third joint to the fourth joint.•  3 is the angle between axis  2 and axis  3 .
•  4 is the distance along axis  3 to the end-effector.
•  4 is the length of link 4 connecting the fourth joint to the end-effector.•  4 is the angle between axis  3 and axis  4 (endeffector).Fig. 3.Control diagram of kinematics robot system [35] According to this parameter explanation, we can formulate a modification of the DH Dobot Magician parameter to obtain a homogeneous transformation matrix that represents the position and orientation of the goal frame with respect to the Dobot Magician reference frame [47]- [49].The setting of DH parameters allows the manipulator to pick and place objects with precision in pick and place applications frame.The DH parameter modification on Dobot Magician as intended is shown in Table III

D. Fuzzy Logic Control
Fuzzy logic control is used to map an input variable into a firm value at the output using a rule-based decision-making process that classifies the degrees of membership of fuzzy sets and fuzzy rules [53]- [56].The computational process of fuzzy logic can be divided into four main stages, namely: 1. Fuzzification, a process in fuzzy logic systems in which numerical inputs or data that are firm are converted into linguistic variables or fuzzy variables [57], [58].
2. Rule Base contains a set of fuzzy rules that serve to determine decisions, consisting of IF-THEN statements in fuzzy logic format.The statements in these fuzzy rules use connectors such as AND, OR, or NOT, and the degree of truth is calculated for the predicate set [59], [60].
3. A fuzzy inference engine is one of the core components in a fuzzy logic system that is responsible for making decisions based on the rules defined in the fuzzy rule base [60], [61].
4. Defuzziffication, the final stage is defuzzification, which involves returning the fuzzy calculation result (fuzzy set) into a variable that corresponds to its range in the real world.The defuzzifier also uses membership function to map fuzzy set values into real variables.This stage provides explicit information from the fuzzification process to be executed by the program [62].
The use of fuzzy logic in 4 DOF manipulator control research has many advantages, namely: 1. Able to convert input uncertainty into definite logic that allows the manipulator to respond appropriately.
2. Fuzzy logic is able to accommodate many input variables into a certain value making it easier for the manipulator to execute the program.

A. Implementation of the Denavit Hartenberg Method on Dobot Magician
The Denavit-Hartenberg (DH) method is an appropriate way to model manipulator link and joint parameters that can be used in kinematics and control calculations.Based on the homogeneous Denavit Hartenberg equations, it is possible to determine the kinematics of the manipulator, control the position and orientation of the end of effector, plan the path for the pick and place task on the manipulator, and interpolate the motion between coordinate points in the pick and place task.Through the Dobot Magician parameters as shown in Table I, Table II, and Table III, the Denavit Hartenberg homogeneous matrix is obtained in the equation ( 1) to (5).

B. Forward and inverse kinematics
• Forward Kinematics For a four Degree of Freedom (4-DOF) manipulator, forward kinematics plays a role in determining the position and orientation of the end of effector based on the joint rotation angles of the four manipulator joints.Forward kinematics requires closed-loop vector analysis to obtain position equations.The number of equations for a manipulator is determined by the joint count and arm length [67]- [69].Based on the homogeneous matrix equation of Dobot Magician shown in equation ( 6), the forward kinematic equation is obtained as (7).
• Inverse Kinematics Inverse kinematics is used to set the joint movement angle () of Dobot Magician.Inverse kinematics on a manipulator is always more complex than forward kinematics because the equations solved are non-linear and produce finite solutions.Inverse kinematics is process to calculate the joint angles required for the manipulator to achieve a certain position and orientation at the end-effector.Based on forward kinematics equation (7), the inverse kinematic parameter approach to obtain  1 ,  2 ,  3 , and  4 is follows.

Approach 𝜃 3
To make it easier to find the cosine equation, it is expressed as (10) to (13).
So, we get: then: By assuming the object is still within the working range of the Dobot then:  3 = ±√1 −  2  3 then:

Approach 𝜃 2
At the same time  2 is obtained with the following equation ( 15) and (16).

C. Manipulator Working System Diagram
This research combines two control systems, namely the Dobot Studio to control the movement of the manipulator, and the Arduino Mega 2560 which serves as a fuzzy program controller [74]- [76].The combination of dual control is possible on the Dobot Magician manipulator because the device is equipped with a communication interface that facilitates the Dobot can be controlled with additional external controls [69], [77]- [79].At the output of the system is Dobot Magician, a four DOF manipulator driven by stepper motors at the joint and servo motors at the End of the Effector.In this research, the end of the effector used is a suction cup model with a pneumatic vacuum working principle.The suction cup was chosen because it is most suitable for the surface contours of the object to be moved.The schematic diagram of the manipulator working system for picking up and placing objects based on weight and color is shown in Fig. 4. Based on Fig. 4, it can be explained that controlling the movement of the Dobot as an object mover based on the weight and color of the object requires an integrated control system consisting of input, control process, and output.In the input section consists of 3 sensors, namely: 1. HX711 loadcell: is a weight sensor that has a weight capacity of 1.5 kg.In this study, the weight of random objects is 50 g -750 g [43], [70].
2. Color sensor TCS-3200: capable of detecting 64 color gradations derived from the four main colors of red, clear, green, and blue.For this study, the workpiece is modeled in three dominant colors: red, green, and blue [71], [72].
3. Proximity sensors employ the principle of electromagnetic radiation to detect workpieces without direct contact [73].In this research, Proximity sensor to read products that come on the conveyor to the Dobot work area.
The control process is integrating Dobot Studio and Arduino Mega 2560 to produce a working mechanism algorithm for weight and color-based pick and place manipulators can be explained in Fig. 5. Fig. 5 describes the Manipulator's flowchart algorithm as product picking and placement, starting from the conveyor working to placing objects according to the weight and color categories of the object.The working mechanism of the weight-and color-based object-moving manipulator can be explained as: 1.The workpiece represents the production object, which will be randomly placed on the conveyor and delivered until it stops at the pickup point by the proximity sensor.
2. From the initial position the manipulator moves towards the pickup point to pickup the workpiece.
3. The workpiece picked up by the EoE of Dobot Magician will be placed on the color sensor to detect the object's color and then moved to the weight sensor area to weigh the object's weight.
4. EoF will move the object back to the place point based on the color and weight data.Place point is an area to store workpieces based on color and weight criteria.

D. Fuzzy Logic Controller Manipulator
Fuzzy logic control is implemented with the Mamdani method, this method was chosen to facilitate setting membership values with the consideration that the value of each variable used is not linear.Input variables and output variables in fuzzy systems are needed to emphasize decisions between several uncertainty options of values and conditions.In this system, there are 2 input variables, WEIGHT and COLOR, and 1 output variable PLACE.Below is explanation of the input and output variables in this fuzzy logic control system: Based on the type data and parameter values of 2 input variables and 1 output variable, the fuzzy membership function can be calculated with the equation ( 22) and ( 23) [80], [81].
Membership functions are very important to provide certainty to the value of each fuzzification process so as to produce definite values in Fuzzy control applications.Based on equations ( 22) and ( 23), the membership function for each input variable and output variable in this system can be described.The weight membership function is shown in Fig. 6.In the output section, the membership function displays 3 place variables representing 3 color unit groups and 3 weight unit groups.This program is adapted to real conditions where there are 3 pallets for storing objects based on color and weight categories.The fuzzy graph of the output variables is shown in Fig. 8.By using 2 input variables and an output variable, an Aggregation graph can be created, which is the process of combining input variables and output variables through a fuzzy rule base.Fig. 9 shows the Aggregation graph in the pick and place process with the 4 DOF manipulator in this study.9 is the rule viewer obtained from the Aggregation process using 18 rules to represent 6 WEIGHT membership functions, 3 COLOR membership functions, and 9 PLACE membership functions.The rule editor uses AND connection so the rule base implementation is as follows: The 18 rules representing the values of 2 input variables and an output variable are organized in Table IV.Table IV, describes two inputs and an output in the mamdani fuzzy rule system.With this rule pattern, the movement of the robot arm will be precision according to the color and weight of the object.

A. Pick and Place Coordinate Board
Based on the working mechanism of this robot, there are several coordinates that determine the Dobot Magician trajectory, namely: 1. Coordinate 1: on the conveyor where the proximity sensor is placed.2. Coordinate 2: at the position of the color sensor 3. Coordinate 3: at the position of the weight sensor area 4. Coordinate 4: At the position of the product storage pallet, where there are 27 storage coordinates.Dobot Magician is trained to move at each of these coordinates through the teaching and playback mechanism.that is, how to train Dobot Magician by directing the end of effector at each coordinate it will pass through and store the coordinates in the memory of the Dobot Studio Program.At each destination position the coordinates are stored as shown in Fig. 10.Table V shows the X, Y and Z position coordinates targeted by the manipulator's work activities.Determination of these position coordinates is very important to limit the movement of the manipulator to positions that have been planned, such a model is also commonly called the path planning method.Determination of coordinates is done by the teaching and Playback method, which determines the position coordinates through movements guided by humans.Mechanically, each desired coordinate destination becomes the robot's stopping points in the key and is stored in the studio memory and from all these positions the manipulator is given work instructions so that the robot will pass through each position inputted from the program.Fig. 11 shows the teaching and playback mechanism on Dobot Magician.

B. Fuzzification Testing for Color and Weight
The fuzzification process produces data in a numerical format that represents the degree of membership of color and weight.Color and weight data is obtained through the Arduino output based on color sensor and loadcell readings.Arduino output is input data to the Dobot Magician control interface.With this mechanism, the movement trajectory of the Dobot Magician will be influenced by the defuzzification data generated from Arduino.The results of weight and color testing on the defuzzification process generated by Arduino are shown in Table VI.Table VI describes the defuzzification results processed inside the Arduino.For example, the table explains that when the WEIGHT value is 49.1 and the COLOR value is 146, the PLACE value is 1.5, while the value of 1.5 at the PLACE position is at the RED 30.0 coordinate.

C. Manipulator Movement Analysis
The movement of the Manipulator is mainly controlled through Dobot Studio.In this research, Dobot Studio processes the data generated by Arduino through the communication interface as information to program Dobot to perform movement activities according to the position of its final destination, PLACE.In this case, programming with the teaching and playback method was chosen because of its ease of executing the program.In practice, the robot arm has executed the program instructions with very good accuracy.This can be proven by comparing the difference between the coordinates in the program and the final destination coordinates.This comparison is calculated using Matlab Emmanuel Agung Nugroho, Handling Four DOF Robot to Move Objects Based on Color and Weight using Fuzzy Logic Control based on the forward kinematic approach based on equation (7).The accuracy test data of the robot arm movement is shown in Table VII.
With 12 samples of robot arm movements, the accuracy error of product placement on each pallet is 0.537 mm.This is still within the permissible placement position limits, meaning that if there is a position shift of 0.537 mm, the workpiece is still in the specified storage box.From each coordinate position shift to the path planning calculation in the table above, it can be calculated that the average deviation of product sample placement errors is 1.8%.Product placement accuracy is very important to avoid product accumulation in the same position or products placed outside the proper storage area.In Fig. 12, x, y, and z represent the position of Dobot Magician's end of effector in 3D space when getting a certain coordinate input.

V. CONCLUSION
This research has proven that the performance of Dobot Magician can be improved with fuzzy logic control through the collaboration of the Dobot Studio program with Arduino Mega through the communication interface provided.Fuzzy Logic Control interference has improved the performance of Dobot Magician so that it is able to make smarter decisions in executing two input variables, namely the weight and color of objects.So far, Dobot Magician only works monotonously according to the sequential order of the program.Through the collaboration of fuzzy logic control, Dobot Magician can work based on different conditions according to the input parameters it reads.The collaboration of Dobot Studio control with a Fuzzy logic control system for pick and place applications based on object weight and object color variables is able to control the movement of Dobot Magician with very high positional accuracy.The test data states that the accuracy and precision of the average coordinates of the product pick and place against the path planning has an error deviation of 1.8%.The challenge that occurs in this research is the color reading of the product with the color sensor, which is caused by differences in the light intensity of the lamps used.but this can be solved by testing in a fixed room with a fixed light intensity.This research can be continued by developing a Vision system using a camera to replace the color sensor.

GLOSSARY Path Planning
Plan for the robot to move through Trajectory The route followed by the movement of the robot Kinematics Motion of objects and systems of objects without considering the forces that cause motion Fuzzification The process of converting an input from a firm (crisp) to a fuzzy (linguistic variable) form.

Rule Base
Rules that express causal relationships in fuzzy systems Defuzzification The process of converting a fuzzy output into a firm (crisp) value Aggregation Process of combining some fuzzy sets into 1 set ACKNOWLEDGMENTS The researcher is a lecturer at the mechatronics engineering technology study program of Indorama Purwakarta Polytechnic, currently pursuing a doctoral program at the faculty of mechanical engineering, Diponegoro University Semarang.This research is one of the mandatory research that must be carried out by students to complete the doctoral program.This research is supported by funding from the Indorama Education Foundation and independent funds.

Fig. 4 .
Fig. 4. Block diagram of the control system of the object-moving manipulator

Fig. 6 .
Fig. 6.Weight input variable Fig. 6 is the result of the membership function for the weight variable as input which consists of 6 membership functions.The weight membership value is 0 -700 grams and

Fig. 7 .
Fig. 7. Color input variable Fig. 7 shows the color membership function with a membership value range of 0 -1024 in RGB units.Each color has 512 membership values in the RGB system and uses a triangular membership function type.

Fig.
Fig.9is the rule viewer obtained from the Aggregation process using 18 rules to represent 6 WEIGHT membership functions, 3 COLOR membership functions, and 9 PLACE membership functions.The rule editor uses AND connection so the rule base implementation is as follows:

Fig. 10
Fig. 10 is one of the Dobot Studio monitor displays that stores each position coordinate that will be traveled by the robot.The complete coordinates of the pick and place position of the object are stated in Table V.

Fig. 10 .
Fig. 10.Coordinate determination with teaching and playback method

Fig. 11
Fig. 11 is the stage of determining the coordinate position of the Dobot Magician end of the effector.Each coordinate data stored in Dobot Studio will be called using the Arduino program, based on the fuzzy program instructions stored in Arduino.

D
. Manipulator Movement Trajectory Based on the kinematics equation of the Dobot Magician and the length parameter of each Dobot rigid body, the trajectory graph of the Dobot Magician end of the effector can be visualized using Matlab programming.This trajectory graph provides a visual representation of the Dobot Magician's crossing.This analysis helps to identify the route of movement to avoid the risk of collision with other objects around the manipulator area.The movement of the Dobot Magician manipulator in a sample coordinate X = 47.552,Y = -193.864and Z = 31.935 is expressed in the Matlab graph in Fig. 12.

Fig. 12 .
Fig. 12. Dobot Magician end of effector Trsjectory chart Table I displays the impressive specifications of the Dobot Magician.

TABLE II .
WORKING AREA AND WORKING SPEED OF DOBOT [52]-[52].Emmanuel Agung Nugroho, Handling Four DOF Robot to Move Objects Based on Color and Weight using Fuzzy Logic Control

TABLE IV .
INPUTS AND 1 OUTPUT FUZZIFICATION RULES

TABLE V .
PICK AND PLACE COORDINATE POSITION OF DOBOT MAGICIAN WORKING

TABLE VII .
TESTING THE MOVEMENT ACCURACY OF THE ROBOT ARM