AUTOMATION OF ROBOTIC ARM TOMÁŠ STANOVIČ Faculty of Materials Science and Technology, Slovak University of Technology, Trnava, Slovakia Abstract. This article includes informations about design 3D CAD model in Autodesk Inventor its translation into Matlab SimMechanics and its controlling. First part contains instructions how to design robotic arm. Specifically how to create individual parts and assembly them together. Another part describes way to translate CAD model into SimMechanics. Next part is about editting model and about connecting Simulink blocks to SimMechanics blocks. Last part informs about development of an algorithm for calculate amplitudes from coordinates. This part also includes informations about creating Graphical User Interface (GUI) to pass calculated amplitudes in to SimMehcanics. Keywords : CAD model, SimMechanics, GUI, amplitudes, algorithm. 1.Introduction Topic flows from current requirements of robotics for automated capabilities of modern robots to aimed robot at desired location, for the detection of objects in space, grasp objects and relocate them. For this purpose I used software Autodesk Inventor and Matlab. Autodesk Inventor contains tools suitable for 3D mechanical design, documentation and product simulation. SimMechanic is part of SW Matlab that provides a multibody simulation environment for 3D mechanical systems, such as robots, vehicle suspensions. SW allows to model the multibody system using blocks representing bodies, joints, constraints, and force elements, and then SimMechanics formulates and solves the equations of motion for the complete mechanical system. Models from CAD systems, including mass, inertia, joint, constraint, and 3D geometry, can be imported into SimMechanics. An automatically generated 3D animation lets user visualize the system dynamics. 2.Objectives 1. Design CAD model of robotic arm. 2. Translation CAD model into Matlab SimMechanics. 3. Edit SimMehcanics model in way, that it can receive input data from GUI. 4. Create GUI for calculate data to determinate desired location of arm. 3.Development Design CAD model I created robotic arm as a assembly consisted of 13 parts (base,cylinders for connection, gripping parts...). First part which I designed was base, I started with 2D sketch where I created circle. Afterwords I finished sketch and I transformed 2D into 3D by using function extrude. In the next step I made hole in base by using function with same name as feature that I wanted to create. I set placement of hole from the sketch, termination of hole as a distance (Figure 1). This was last edit at base. Similar procedure I used at every created part. Figure 1 Base After design parts I joined them together. I chose function constraint then I clicked at cylinder afterwords I clicked at bottom of hole in base, these two parts were conncected. In the next step I again used function constraint, I clicked at part 1 after at cylinder and to assembly joined another part. I continued by connecting parts to assembly untill I got whole assembly of arm (Figure 2). Figure 2 Assembly Translation CAD model into SimMechanics Translation consisted of two single steps. First step was to translate CAD file into XML file and second step was translate XML file into SimMechanics. To accomplish first step was neccessery to install add-on SimMechanics Link to CAD platform. After getting XML file I typed into Matlab command window following text „import_physmod('arm.xml.‘)“. Afterwords was created SimMechanics model of robotic arm in first generation in forward dynamics, shortcut of model is in the Figure 3. Figure 3 SimMehcanics model Parts were translated into body blocks as can be seen at figure with names 1:1, 3:1, 4:1, cyl:3. Body block is user- defined rigid body which is defined by mass properties and body coordinate systems. Mass properties includes body’s mass, which determines body response to translational forces and its intertia tensor, which determines its response to rotational torques. Body cooridnate systems define local cooridnate systems, one of them is CG – body’s center of gravity another are CS, they are asociated with joints to the body block. Constraints were translated into revolute blocks. Revolute block represents one rotational degree of freedom. The follower body rotates relative to the base body about a single rotational axis going through collocated body coordinate system origins. Sensor and actuator ports can be added. In model were twelve revolute blocks which represented 12 degrees of freedom (DoF). Edit SimMechanics model At first I reduced DoFs from twelve to six by changing revolute blocks which were connected to cylinders for weld blocks. Weld block represents joint between base and follower with zero degrees of freedom. To this block is possible to add a sensor but not an actuator. Afterwords I run a simulation. As shown in the Figure 4, individual parts of model were collided between themselfs during the simulation. Figure 4 Simulation First step to avoid collisons and also to solve main task which is to get arm at the desired location is adding sensor and actuator to every revolute block of model. Joint actuator actuates a joint block connected between two bodies with one of these signals: generalized force (force for translational motion along a prismatic joint primitive / torque for rotational motion about a revolute joint primitive), motion (translational motion for a prismatic joint primitive, in terms of linear position, velocity, and acceleration / rotational motion for a revolute joint primitive, in terms of angular position, velocity, and acceleration). The inport is the Simulink input signal. The output is the connector port which can be connect to the joint block in case of to want to actuate. A joint actuator block actuates one joint primitive at a time: primitive joint (prismatic or revolute) has only one primitive within the joint to actuate. composite joint has multiple joint primitives within and i tis neccessery to choose which of those primitives to actuate with the joint actuator. Joint sensor measures linear or angular position, velocity, acceleration, computed force or torque and reaction force or torque of a joint primitive. Outputs are Simulink signals. Multiple output signals can be bundled into one signal. To every sensor I conncted scope block which displays input signals with respects to the simulation time. To every actuator I joined one sine wave, two derivatvies, but to actuator can be connceted only one signal, so I these three signals connected to mux (Figure 5). Mux is used for combine many inputs into single output. Way of conncection is at figure. Sine wave block outputs a sinusoidal waveform. The block can operate in timebased or sample-based mode. In time-based mode is output of the sine wave determined by: y=amplitude×sin(frequency×time+phase)+bias. Time specify whether to use simulation time as the source of values for the time variable or an external source. If is specified an external time source, the block displays an input port for the time source.Amplitude defines the amplitude of the signal, default is 1. Bias poitns out the constant value added to the sine to produce the output of this block. Frequency is in radians per second, default is 1. This parameter appears only in condition of setting Sine type to time-based. Phase specify the phase shift in radians. The default is 0. This parameter appears only in case of setting Sine type to time-based. Derivative block approximates the derivative of the input signal u with respect to the simulation time t. Is possible to obtain the approximation of du/dt by computing a numerical difference Δu/Δt,where Δu is the change in input value and Δt is the change in time since the previous simulation (major) time step. This block accepts one input and generates one output. The initial output for the block is zero. Figure 5 Connection Before testing this conncection I clicked at Joint Actuator and changed „Actuate with“ from generalized forces to motion. Then I ran a simulation with default values from Sine Wave (amplitude, frequency = 1, bias,phase,sample time = 0). According to paramters formula of Sine Wave was changed into : y=amplitude×sin(frequency×time). In next step I clicked at scope and it showed behaviour of Revolute1 (Figure 6). From figure is possible to deduce that amplitude of Revolute1 moves in range <1;-> and time in which amplitude reach for first time value (-1) is 1.6 s. From that I calculated frequence by formula x = 1.6 / 10 (simulation time). After that I changed value of frequency at 0.16 (rad/sec) and again I run simulation and observed scope (Figure 7). I did this procedure with every revolute block in model. Figure 6 Scope1 Figure 7 Scope2 In the Figure 7 can be seen that amplitude is in range <0;1> so part of arm gets into desired value during simulation time and arm does not cross value bigger than value which is entered from sine wave block. According to this infromation is SimMechanics model ready to be controlled from Graphical User Interface. Create GUI Before creating GUI I had to find out values of amplitudes, in which individual parts collided between themselves and also I recalculated values of amplitudes into values of angles, for example revolute2 amplitude = 51,5 is the same as angle between base and part joined to the base. Value of this angle is 0 degrees. Then I developed an alortihm, that according to coordinates in carthesian coordinates system calculate ampliutudes in sine wave in every revolute block. First step was to determinate lenght of arm (Figure 8). Figure 8 Measurments Base, P1, and P2 are measurements from CAD model, but P3 is measurement, which is changing according to width of gripped object (Figure 9). Width of object(a), coordinatees (x,y,z) are entered from GUI, base, P1, P2, r and b are defined at the beggining of code in GUI. Figure 9 Gripper In Object is P3 calculated according to the formula: 𝑃3 = √r 2 − ( ( b−a 2 ) ) 2 In Object2 is P3 calculated according to the formula: 𝑃3 = √r 2 − ( ( a−b 2 ) ) 2 P3 is basically a distance from gripper to the object. For calculating angles I created an algorithm, which is shown in the Figure 10. Figure 10 Algorithm A In first step the algorythm calculate „f“ according to Phytagoras setnence : 𝑓 = √𝑥 2 + 𝑧 2 , afterwords it calculate angle „α“ with using goniometric function : 𝑧 𝛼 = sin 𝑓, this angle represents amplitude in Revolute1. Procedure of calculating of angles „β“ and „γ“ is explained in the Figure 11. Figure 11 Algorithm B It starts with calculating „o“ by formula : 𝑜 = √𝑓 2 + 𝑡 2 , it continues with computing β1 and β2 by : P12 +o2 −(P2+P3)2 β1 = cos ( 𝑡 β2 = sin . 𝑜 If y > base β = β1+ β2 else if β1 > β2 β = β1- β2 elseif β1< β2 β = β2- β1 2∗P1∗o ), else β = β1 = β2 „γ“ is computed according to cosine sentence : P12 −o2 +(P2+P3)2 γ = cos ( 2∗P1∗(P2+P3) ). „ γ“ represents Revolute3, „β“ represents Revolute5. Next step is computes angles in the gripper (Figure 12). Figure 12 Algorithm C Angle „ε“ is calculated according a fromula : 𝜀 = sin 𝑃3 𝑟 , if is „a“ bigger than „b“ it is computed by : 𝜀 = (cos 𝑃3 𝑟 ) + 90. „ε“ represents both revolute blocks involved into gripping (Revolute5,Revolute6). In next step it recalculates angles into amplitudes and it passes data into SimMechanics model. To check if are amplitudes correct, serve function „Check in 3D plot“. This function draws lines according to dimensions of arm and according to coordinates entered from GUI. It helps to check if is the postion of arm in SimMechanics that, as it should be. 4.Conclusion To demonstrate functionality of this work serves three figure. In the Figure 13 is design of GUI with cooridnates and with calculated amplitudes, in the Figure 14 is position arm in SimMechanics, and in the Figure 15 is 3D chcek plot. Figure 13 GUI Figure 14 Arm Figure 15 3D plot As can bee seen at figure 14, marked part has dimension 80 mm from the bottom of the base, so positon of arm is a few mm above that mark. At figure 15 is postion of arm at similar value. From that is can be deduce, that arm is possible to get at desired location and is also possible to set gripper which fits to the wide of object (Figure 15). References 1. www.mathworks.com 2. www.knowledge.autodesk.com