Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
159 views

Simulation and Control of A Robotic Arm Using MATLAB Simulink and TwinCAT

Uploaded by

sindhushetty06
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views

Simulation and Control of A Robotic Arm Using MATLAB Simulink and TwinCAT

Uploaded by

sindhushetty06
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Simulation and Control of a Robotic Arm Using MATLAB, Simulink

and TwinCAT
Wei-chen Lee-IEEE Member, Shih-an Kuo

Abstract—It is challenging to develop robot applications IP. The toolbox contains functions such as forward and
without viewing the robot movement. Besides, it is tedious to inverse kinematics, point-to-point joint control, trajectory
establish motion paths and adjust controller parameters using generation, etc. González-Palacios et al. [6] proposed a
the real robot if there is no simulation program available. To simulation interface called SnAM (Serial n-Axis
resolve the issues for a low-cost robot, we developed a system Manipulators), which was developed under the ADEFID
that integrated kinematics and motion control simulation using (ADvanced Engineering platForm for Industrial Development)
MATLAB and Simulink. The system can then be connected to a framework to solve the forward kinematics and inverse
real robot by using TwinCAT to verify the simulation results. kinematics. It can help users complete tasks such as trajectory
Case studies were conducted to demonstrate that the system planning and collision avoidance. The integration of SnAM
worked well and can be applied to those robotic arms without and the adaptive prototype also can help test the performance
simulators. of serial manipulators of various designs. Mohammed Abu et al.
I. INTRODUCTION [7] proposed visualization software to solve the problem of
insufficient robots in schools. They combined
It is always beneficial for the users of robotic arms to be MATLAB/Simulink and AutoCAD to establish
able to first simulate the robotic behavior before deploying the forward/inverse kinematics and trajectory planning.
robotic arms in the product line. However, not all the robotic Dean-Leon et al. [8] proposed a new MATLAB modeling and
arms manufacturers can provide such simulation programs. In simulation toolbox that automated the modeling process.
the past, many scholars have developed techniques on robotic Users only needed to know the D-H (Devanit-Hartenberg)
arm simulation. Corke [1] proposed a toolbox for robotic arm parameters and basic linear algebra to be able to use the
simulation based on MATLAB. It contains the forward toolbox.
kinematics, inverse kinematics, and other functions. Breijs et
al. [2] proposed an automatic modeling and controller design For the controller design simulation, many researchers
environment in MATLAB/Simulink for robotic arms. Falconi proposed various robotic arm controllers. Piltan et al. [9]
et al. [3] developed a tool integrating MATLAB and Simulink realized the PUMA 560 manipulator position control
to help users quickly create a robotic arm simulation simulation through MATLAB/Simulink and designed the
environment. The MATLAB functions developed by Corke [1] manipulator controller based on the computed torque control
were also included in their tool. The kinematic and dynamic (CTC) methods. Through the test results, the authors
models of a robotic arm can be obtained using the tool and demonstrated that the PID-CTC controller was better than the
then simulated in Simulink. Gil et al. [4] proposed a PD-CTC controller in terms of the performance of overshoot,
MATLAB robotics toolbox for teaching students the basic steady-state error, and root mean square error. Jamali et al. [10]
concepts of robotics. Many robotic arms on the market were proposed a structure of modeling, simulation, and
available in the toolbox for easy implementation. In addition optimization based on SolidWorks, MATLAB, and
to the forward kinematics, inverse kinematics, and path Simmechanics, in which they optimized the controller to
planning, this toolbox can also be used to tune the PID reduce the joint errors by using the Genetic algorithm.
parameters of the controller for the joint control. Regarding the controllers, many researchers and
In addition to the simulation virtually, many studies have engineers have used TwinCAT, the windows control and
incorporated real robotic arms with the simulation results to automation technology, in related applications. Shuai et al.
demonstrate the streamline implementation. Chinello et al. [5] [11] proposed an elderly-assisted four-axis robotic arm based
established a MATLAB toolbox for the KUKA robotic arms, on Beckhoff’s industry PC. In their study, TwinCAT was used
integrated all functions into a user-friendly interface, and as a communication protocol between the PC computer and
connected to the KUKA controller from a computer via TCP / motor drivers to achieve the purpose of real-time control.
Proskuriakov [12] used TwinCAT to build a real-time control
This work was financially supported by the “Center for Cyber-physical environment for their hydraulic servo system. Fan et al. [13]
System Innovation” from The Featured Areas Research Center Program proposed a welding robot combining a computer and a virtual
within the framework of the Higher Education Sprout Project by the Ministry NC (Numerical Control) to design a device control layer
of Education (MOE) in Taiwan. through a Beckhoff controller and TwinCAT.
W. C. Lee is with the Department of Mechanical Engineering and the
Center for Cyber-physical System Innovation, National Taiwan University of Based on the discussion above, we can understand that
Science and Technology, Taipei, 10607, Taiwan, (phone: 886-2-2737-6478; integrating a simulator with a real robotic arm is still needed
fax: 886-2-2737-6464; e-mail: wclee@ mail.ntust.edu.tw). for those robotic arms without simulators. To address the issue,
S. A. Kuo is with the Department of Mechanical Engineering, National
Taiwan University of Science and Technology, Taipei, 10607, Taiwan,
the objective of this research was to develop a software system
(e-mail: M10603107@mail.ntust.edu.tw). to integrate robot simulation and robot control. The robot

Authorized licensed use limited to: UNIVERSITAETSBIBLIOTHEK CHEMNITZ. Downloaded on May 21,2024 at 18:04:55 UTC from IEEE Xplore. Restrictions apply.
manufactured by igus (Cologne, Germany) was used as our and devices were all built on the same PC. To facilitate the
control target, and we used TwinCAT as the software to management, Beckhoff ADS (Beckhoff Automation Device
control the robotic arm. Using the techniques proposed in this Specification) communication architecture was used for data
paper, we can quickly establish a simulator for a robotic arm, transmission. The motion control part adopted multi-axis
and use the output of the simulator to control the real one. independent control to reduce the impact of communication
delay and excessive calculation. The EtherCAT
II. ROBOT DESCRIPTION AND KINEMATICS communication architecture was used for the real-time
communication between the PC and the motor drivers.
A. Robot Description
This research used the RL-D-RBT-3322S-BC five-axis
robotic arm from igus as our simulation and control target.
This robotic arm is articulated and its five are all rotation axes.
To make the simulation more realistic, parameters such as the
weight, center of mass, and moment of inertia of each link was
measured or calculated.
Regarding the motor driver, the SVR-K112 stepper motor
drivers manufactured by Taiwan Pulse (Taichung, Taiwan)
were used. This stepper motor driver is a single-axis drive
with A and B two-phase design. It can be closed-loop Figure 1. Integrated structure of the proposed system.
controlled through the motor encoder’s feedback to reduce the
position errors. The communication the driver uses is
A. Simulation Environment
EtherCAT architecture for real-time control between the
server and the device. Devices in the network can be divided The visualization interface proposed by this research was
into master and slave. The controller of the channel is mainly divided into two parts as shown in Fig. 2. We used
responsible for sending packets to each slave to read slave’s MATLAB to perform kinematic simulation and Simulink for
data or control slave behavior. dynamic simulation. For kinematics simulation, it can be
further divided into joint simulation, endpoint simulation and
B. Forward Kinematics path planning simulation. The task simulation was to learn the
dynamic characteristics of the robotic arm by taking into
For the coordinate transformation of forward kinematics, consideration of the parameters such as the weight and the
D-H notation was used. First, the coordinate structure was moment of inertia of the links of the arm. We can also design
defined according to the length and rotation axis of each link and simulate the robotic arm controller in the environment.
of the robotic arm. Then the coordinate transformation
relationship was obtained through D-H notation, and the
homogeneous transformation matrix between two links was
obtained. Finally, the homogeneous transformation matrix of
each rotation axis was multiplied to obtain the coordinate of
the endpoint of the robotic arm.

C. Inverse Kinematics & Path Generation


We used algebraic approach to solve the inverse
kinematics for the robotic arm. When we wanted to generate Figure 2. Structure of the simulation.
the trajectory of the endpoint from the selected points, we
used the MATLAB function, cscvn, to generate cubic spline For the task simulation, the URDF (Unified Robot
curves from the selected points, and MATLAB function, Description Format) was used to define the relationship
ppval, to obtain the interpolated points among the selected between links in the virtual robotic arm. The 3D model with
points for a smooth path. Then the we solved the rotations for the coordinate system and the rotation axis set was converted
the axes for each of the interpolated points by using the into a URDF file through a SolidWorks to URDF exporter.
inverse kinematics. The equations derived from inverse After importing the converted URDF file into MATLAB
kinematics are similar to those in [7]. There may be multiple through the function, importrobot, in the Robotics System
solutions for the equations, and we need to limit the solutions toolbox, the information of RigidBodyTree was obtained.
for each axis within the physical limits so that we can obtain a RigidBodyTree is a data file representing the structure of the
unique solution. robot. It contains the parent-child relationship of each
rotational axis and the type of the rotational axis. It can also
include arm parameters such as the mass, center of mass, and
III. SYSTEM STRUCTURE
moment of inertia.
The system architecture of this study is shown in Fig. 1. It
The kinematics used in task simulation was completed
includes a visualization interface, TwinCAT server,
using the Robotics System toolbox, which contains kinematics
TwinCAT devices, stepper motor drivers, and a five-axis
and dynamics related functions. The Get Transform function
robotic arm. The visualization interface, TwinCAT server,
block mainly completed the forward kinematics task. For the

Authorized licensed use limited to: UNIVERSITAETSBIBLIOTHEK CHEMNITZ. Downloaded on May 21,2024 at 18:04:55 UTC from IEEE Xplore. Restrictions apply.
inverse kinematics, it was primarily done through the Inverse can control the robotic arm through the user interface directly.
Kinematics function block. We also needed to define the necessary parameters for
controlling the robotic arm in TwinCAT PLC. Finally, we
The PID Controller function block in Simulink mainly
connected the variables with the ADS communication
established the PID controller used in this research. The
program written in the MATLAB environment to complete
motion was completed by using the Stateflow toolbox. The
the control of the TwinCAT PLC variables from the
Chart function block was used to define and plan the
MATLAB environment.
movement flow of the virtual robotic arm. In addition to
setting the robotic arm movement, it can also design some We used four functions in the Tc2_MC2 library, which
complicated scenarios, such as adding other objects and were reading the state of the motor, enabling the motor,
working with the other robotic arm together. Also, the controlling the rotation of the motor, and resetting the
MATLAB functions were used to assist the simulation process. TwinCAT NC PTP state. Problems may occur at any time
In this study, the endpoint of the virtual robotic arm can move during the movement of the robotic arm. Therefore,
along the planned path. Because the endpoint obtained after monitoring can help users to obtain the current status. The
kinematics calculations did not exactly match the target path MC_ReadStatus function block was used to read the status of
point, it is necessary to define the tolerance, which was used to each axis of the robotic arm. The MC_Power function block
limit the calculation error. The virtual robotic arm can move was used to control the motor on/off. In the point-to-point
only when the difference between the calculated endpoint and motion control, the MC_MoveAbsolute function block for
the target point was within the difference. Otherwise, the position control was selected to construct the motor rotation
calculation continued until the tolerance requirement was met. control. Finally, the MC_Reset function block was used to
reset TwinCAT NC PTP.
For the communication between the MATLAB-based
simulation environment and TwinCAT-based hardware
equipment, we adopted the Beckhoff ADS communication IV. CASE STUDIES
architecture. This architecture can connect the TwinCAT
server to TwinCAT PLC, TwinCAT NC controller through A. Visualization Interface
TCP/IP communication protocol. For the proper connection, The visualization interface in the MATLAB environment
AdsPort needed to be set up. AdsPort represents the virtual is shown in Fig. 3. It was designed based on the interface
device for designated communication. There are three proposed by Peli [14]. This interface was established by using
communication methods between ADS devices: asynchronous, the MATLAB GUI. The functions are mainly divided into the
synchronous, and notification. In this study, the data reading visualization window, rotation axis movement, endpoint
part was written by using notification. The data receiving part movement, and path planning. robotic arm control, and task
established an ADS data stream to send the request to simulation. We used igus robotic arm to demonstrate the
TwinCAT, and a notification was set for the variable to operation and functions of the interface.
receive the updated value.

B. Hardware Environment
In the hardware environment, it was mainly constructed
through a user interface, TwinCAT, and the motor drivers.
The three communicated with each other through
communication protocols to complete the entire process. First,
the user performed the user interface operation. Then,
according to the selected mode, the information such as the
rotational angle and the variables set in TwinCAT PLC were
transmitted to TwinCAT PLC using the ADS communication
architecture. After receiving the data, TwinCAT PLC
modified the corresponding function block value to turn
on/off the TwinCAT NC PTP function. Then the TwinCAT Figure 3. Visualization interface.
NC PTP gave instructions to the motor drivers to move the
robotic arm. It also read the driver data and sent the B. Case Study–Kinematics Simulation
information back to the user interface.
The 3D model of the igus robotic arm was used to realize
From the description above, we can understand that the the operation of the various functions on the visualization
user interface played the role of sending requests, TwinCAT interface. First, the target coordinates of the endpoint of the
PLC played the role of receiving requests and arranging the robotic arm were input and the rotation angles required to
control processes, while TwinCAT NC PTP gave the reach the target coordinates were calculated by using inverse
instructions to the motor drivers and the motor drivers kinematics calculated in MATLAB. Then the rotation angles
executed the instructions. were input in the visualization interface to obtain the actual
endpoint coordinates using forward kinematics. To
In this study, we used three functions in in TwinCAT PLC, demonstrate this, we first input the target coordinates [293,
which were motor enable, rotation, and reset. We needed to -123, 67] to the endpoint movement simulation interface. The
set the parameters in the MATLAB environment so that we rotation angle for each axis obtained through inverse

Authorized licensed use limited to: UNIVERSITAETSBIBLIOTHEK CHEMNITZ. Downloaded on May 21,2024 at 18:04:55 UTC from IEEE Xplore. Restrictions apply.
kinematics was used to obtain the endpoint coordinates as robotic arm placed an object on a conveyor belt. The conveyor
[293, -123, 66]. Fig. 4 shows the calculated results and the belt detected the object and then moved it to the designated
simulation of the robotic arm at the target position. location. When the object reached the location, the conveyor
stopped, and then the robotic arm was requested to pick it up
and move it according to the planned path to the other
conveyor. Then the object was moved by the conveyor until
the final location was reached.
To perform the simulation, we first tuned the controller for
each axis by using the information of the weight, moment of
inertia, and centroid location of each link. The PID parameters
of the first to fifth axes were turned to the same values, which
Figure 4. Case study: endpoint simulation result. were kp = 25, ki = 1.5, and kd = 0.15. In this setup, the virtual
robotic arm could move stably. We then established the
From the simulation results, it can be seen that the simulation environment consisting of two conveyors as
coordinates of the endpoint of the input and the final endpoint
mentioned previously. The weight of the object was set to 0.3
of the output differed by 1 mm in the z-direction, which was
kgf, and then the path for moving the object between the
caused by the numerical errors. Through the case and other
cases (not presented in this paper) we performed in the conveyors was divided into 30 points. The simulation
kinematics simulation, it can be concluded that both the environment and points along the path are shown in Fig. 6.
rotation axis simulation and the endpoint movement
simulation can reach the specified targets.
Then we connected the robot to our PC with
MATLAB/Simulink and TwinCAT so that we could use the
calculation results obtained in the MATLAB simulation
environment to control the real robotic arm. In the meantime,
the visualization interface could display the simulated posture
of the robotic arm, which was the same as the posture of the Figure 6. Case Study: Task Simulation environment (left) and the path
actual robot. Fig. 5 shows the endpoint movement in the (right).
simulated and real environment. The endpoint of the robotic
arm moved from [377, -171, 145] to [377, 171, 145] through a For the simulation of pick-and-place, we installed a virtual
planned path. It can be found that the simulated results were gripper at the end of the robotic arm, and the endpoint
identical to the actual robot movements. Fig. 5(b) also shows coordinates needed to be offset to the center of the gripper. In
that the movement was not smooth. This was due to the fact this case, it was set to be 140 mm from the endpoint. Then we
that not all the rotation axes started and stopped input the coordinates of the 30 points in the user interface, and
simultaneously. limited the movement range to reduce the calculation of
inverse kinematics. The range in the x-direction was from 38
mm to 400 mm, in the y-direction was from -410 mm to 0 mm,
and in the z-direction was from 100 mm to 240 mm. The
tolerance of the endpoint coordinates were set to ± 30 mm in
each of the three directions.
The simulation results are shown in Fig. 7. The blue curves
in Fig. 7 are the rotation angles of the five axes obtained by
using the equations derived from the inverse kinematics. The
orange curves are the rotation angles of the five axes obtained
by using the inverse kinematic function blocks in MATLB’s
robotics system toolbox and the PID controller in Simulink. In
Fig. 7, from 3.4 s to 4 s shows the motion while the robotic
arm is gripping the object, and from 7.8 s to 8.2 s shows the
motion while the robotic arm is placing the object. Comparing
these two curves, we can see that the calculation results using
Figure 5. Case study: path simulation result and robotic arm movement. (a)
Start position (b) Final position.
two different approaches are very consistent, which verifies
that the equations derived from inverse kinematics are correct
and can be used to calculate the rotation angle for each axis of
C. Case Study–Task Simulation the robotic arm.
The task simulation case was to carry out the simulation of
the production line environment in which a robotic arm and
two conveyors worked together. This was similar to the
simulation proposed by Miller [15]. In the simulation, first the

Authorized licensed use limited to: UNIVERSITAETSBIBLIOTHEK CHEMNITZ. Downloaded on May 21,2024 at 18:04:55 UTC from IEEE Xplore. Restrictions apply.
REFERENCES
[1] P. I. Corke, "A robotics toolbox for MATLAB," IEEE Robotics &
Automation Magazine, vol. 3, pp. 24-32, 1996.
[2] A. Breijs, B. Klaassens, and R. Babuška, "MATLAB design
environment for robotic manipulators," IFAC Proceedings Volumes,
vol. 38, pp. 373-378, 2005.
[3] R. Falconi and C. Melchiorri, "RobotiCad: an Educational Tool for
Robotics," IFAC Proceedings Volumes, vol. 41, pp. 9111-9116, 2008.
[4] A. Gil, O. Reinoso, J. M. Marin, L. Paya, and J. Ruiz, "Development
and deployment of a new robotics toolbox for education," Computer
Applications in Engineering Education, vol. 23, pp. 443-454, 2015.
[5] F. Chinello, S. Scheggi, F. Morbidi, and D. Prattichizzo, "KCT: a
MATLAB toolbox for motion control of KUKA robot manipulators," in
2010 IEEE International Conference on Robotics and Automation,
2010, pp. 4603-4608.
[6] M. A. González-Palacios, E. A. González-Barbosa, and L. A.
Aguilera-Cortés, "SnAM: a simulation software on serial
manipulators," Engineering with Computers, vol. 29, pp. 87-94, 2013.
[7] Q. Mohammed Abu, I. Abuhadrous, and H. Elaydi, "Modeling and
Simulation of 5 DOF educational robot arm," in 2nd International
Conference on Advanced Computer Control, pp. 2010, 569-574.
[8] E. Dean-Leon, S. Nair, and A. Knoll, "User friendly Matlab-toolbox for
symbolic robot dynamic modeling used for control design," in IEEE
International Conference on Robotics and Biomimetics (ROBIO), 2012,
pp. 2181-2188.
[9] F. Piltan, M. Yarmahmoudi, M. Shamsodini, E. Mazlomian, and A.
Hosainpour, "PUMA-560 robot manipulator position computed torque
control methods using MATLAB/SIMULINK and their Integration into
graduate nonlinear control and MATLAB courses," International
Journal of Robotics and Automation, vol. 3, pp. 167-191, 2012.
[10] P. Jamali and K. Heidari Shirazi, "Robot Manipulators: Modeling,
Simulation and Optimal Multi-Variable Control," Applied Mechanics
and Materials, vol. 232, pp. 383-387, 2012.
[11] G. Shuai, S. Zhuoyuan, W. Zhiyong, and M. M. Islam, "Beckhoff based
Figure 7. Case Study–Task Simulation result. Axis angle comparison arm control system design for Elderly Assisting Robot," in IEEE
between inverse kinematics and Simulink function in (a) joint 1; (b) joint 2; International Conference on Automation and Logistics, 2011, pp. 1-5.
(c) joint 3; (d) joint 4; (e) joint 5. [12] M. Proskuriakov, "Control of a hydraulic servo system using Beckhoff
real time data acquisition computer based on MATLAB/SIMULINK
platform," Master, School of Energy Systems, Mechanical Engineering,
Lappeenranta University of Technology, 2018.
V. CONCLUSION [13] L. Fan, J. Bai, F. Liu, C. Yang, and X. Qin, "Software Realization of
Gantry Welding Robot Control System with PC+ Soft NC Mode," in
This study presents a simulator that integrates a virtual
2nd IEEE Advanced Information Management, Communicates,
environment and actual control functions. The simulation Electronic and Automation Control Conference, 2018, pp. 251-255.
environment required for kinematics simulation was [14] Pasc Peli. (2016). Puma Robot Simulation. Available:
constructed by using MATLAB. The rotation axis simulation, https://www.mathworks.com/matlabcentral/fileexchange/59663-puma
-robot-simulation
endpoint simulation, and path simulation can be performed [15] Steve Miller. (2017). Robot Arm with Conveyor Belts. Available:
based on the forward kinematics and inverse kinematics https://www.mathworks.com/matlabcentral/fileexchange/61370-robot
equations. -arm-with-conveyor-belts
Besides, through the simulation environment constructed by
Simulink for the task simulation, the controller for the robotic
arm with its physical parameters can be designed and
simulated.
The outcome of the simulation can be used to control a real
robotic arm by using TwinCAT. We demonstrated that the
simulation of the motion of the robotic arm can be observed
on the real robotic arm. The results of this research can be
applied to any similar robotic arm to resolve the difficulties
for using them without simulators.

ACKNOWLEDGMENT
The authors would like to thank igus Taiwan (Taichung,
Taiwan) for providing the robotic arm for this research, and
Taiwan Pulse Motion (Taichung, Taiwan) for providing the
stepper motor drivers used to control the robotic arm.

Authorized licensed use limited to: UNIVERSITAETSBIBLIOTHEK CHEMNITZ. Downloaded on May 21,2024 at 18:04:55 UTC from IEEE Xplore. Restrictions apply.

You might also like