0% found this document useful (0 votes)
125 views

Representation of Robots in MatLAB

Publication about the representation of robots in matlab employing an specific library

Uploaded by

Warclu Herm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Representation of Robots in MatLAB

Publication about the representation of robots in matlab employing an specific library

Uploaded by

Warclu Herm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

International Journal of Software Engineering

and Knowledge Engineering


Vol. 29, No. 1 (2019) 23–42
#.c World Scienti¯c Publishing Company
DOI: 10.1142/S0218194019500025

Research Notes
Representation of Robots in Matlab

Antonio Sanchez*, Luis Gracia†,‡, Ricardo Morales* and Carlos Perez-Vidal*


*Universidad Miguel Hernandez
Avda. de la Universidad s/n,
03202 Elche, Spain

Instituto IDF, Universitat Polit
ecnica de Val
encia
Camino de Vera s/n,
46022 Valencia, Spain

luigraca@isa.upv.es

Received 29 May 2017


Revised 24 February 2018
Accepted 19 March 2018

This paper presents a new software tool, namely RoboClass, to include and manage realistic
robots and elements of the environment in Matlab simulations. These elements are loaded from
CAD models using an STL-¯le and can be as detailed as desired. All the steps involved in the
process are explained in detail. Furthermore, two illustrative examples are considered to show
the e®ectiveness and versatility of the proposed approach: the ABB-IRB120 industrial robot
and the CSA research robot. The developed tool is especially useful both for robotics research
and teaching.

Keywords: Robot simulation; Matlab; STL importation.

1. Introduction
Nowadays, software tools are used in many engineering areas [1–3]. Matlab is a
technical software environment that has become a standard in many ¯elds of engi-
neering and education, including control systems and robotics [4]. This software
allows the user to program using a high-level language specially designed for nu-
merical computation, statistical analysis and data visualization. To this aim, Matlab
includes a high amount of mathematical libraries and toolboxes that work fast and
keep the code clear. In this sense, some toolboxes and open source code can be found
for robotics although none of them are especially devoted to improve the visualiza-
tion quality of the elements involved.
This paper presents a new open-source software tool, namely RoboClass, devel-
oped to improve the appearance of serial robots to get a much more realistic

23
24 A. Sanchez et al.

representation environment in computer simulation, which is useful both for research


and educational purposes. Each one of the di®erent pieces is stored in a di®erent
Stereo-Lithographic ¯le (STL) that the class will load to visualize as a whole. This
allows the class to load 3D models from ASCII STL-¯les, that are easily readable by
the user, or binary STL with short load times. With di®erent con¯guration ¯les, it is
possible to generate di®erent robots as objects with the capability of operating in-
dependently in the same simulation. Thus, RoboClass is beyond educational pur-
poses and can be adapted to act as a general driver able to control and model the
behavior of any serial robot using Matlab. Furthermore, it is possible to create
multiple objects within the same workspace for research purposes like master–slave
control algorithms or kinematic and dynamic simulation of parallel robots, amongst
others.
A realistic simulation is especially useful for some applications of robotic research,
like surgical interventions [5] or virtual reality [6], where the environment and the
user perception are relevant.
The structure of the paper is as follows. Section 2 describes the libraries related
with this work, while Sec. 3 describes the proposed method and the procedure to use
it. Section 4 illustrates the use of the class for an industrial robot and a research
robot. Finally some conclusions are presented in Sec. 5.

2. Libraries Related with RoboClass


The Toolbox by Corke for Matlab [7] includes a set of functions to deal with
the robot system, whereas its visualization is based on a wired drawing, see Fig. 1.

Fig. 1. Representation of a robot using the Robotic Toolbox by Corke.


Representation of Robots in Matlab 25

This toolbox was the ¯rst one of its type and is still a reference for robotics research
and teaching. In fact, it is probably the most used library in robotics nowadays all
over the world and, typically, new contributions in this area are compared with it.
The Kuka Control Toolbox [8] integrates a good amount of functions for robot
simulation but only Kuka robots can be involved. The IGES Toolbox [9] is designed
to load Initial Graphics Exchange Speci¯cation (IGES) format ¯les to Matlab and
operate with models. To do that, it adds commands and utilities to perform plots,
transformations and projections. The Puma project [10] simulates a six degrees-of-
freedom (DOFs) 3D Puma 560 robot with pre-loaded easy models to help the user on
the visual comprehension of the robot position. In addition, it includes a GUI with
slides to move the joints. This approach has inspired other practice program projects
[11], where students are encouraged to choose a robot and build a simulator to better
understand the kinematics related to it. Dynamics can be simulated using SimMe-
chanics [12], which is a library in SolidWorks software to model mechanical systems
and that uses Simulink toolbox to perform the control of the systems. Simbad [13] is a
Java 3D robot simulator dedicated to help researchers and programmers at study of
situated arti¯cial intelligence, machine learning, and arti¯cial intelligence algorithms
but, like other robot simulators as [14, 15] is focused on teaching purposes and not to
use it in an actual environment.

3. Description of the Files and Con¯guration


As mentioned above, this work presents an open-source class to simulate serial robots
in realistic Matlab environments. The class loads the STL-¯les of the robot (com-
mercial robot or custom made robot) establishing the mechanical restriction for each
joint. Joints can be de¯ned as rotational or prismatic with a maximum of seven
joints, although the class can be easily modi¯ed to consider robots with more than
7-DOFs. RoboClass has a wide group of functions to set and move the robot, see
Figs. 2 and 3. These functions allow adjusting of the simulation view, computing the
forward and inverse kinematics of the robot and operating with the robot dynamics.

Fig. 2. Class information schematic.


26 A. Sanchez et al.

Fig. 3. Description of ¯les included in RoboClass.

Moreover, the class also includes many functions of the Robotics Toolbox [7] to
improve its versatility.
RoboClass creates robot objects from an external con¯guration ¯les, therefore, it
is possible to build di®erent robots in the same workspace, perform cooperative
simulations or even include realistic elements of the environment loading STL-¯les as
well.
RoboClass has been developed for serial arms, but it is feasible to use it with other
kinematic architectures such as parallel robots. In this case, the class should be
modi¯ed to use it with this kind of mechanism but it will generate a di®erent class for
that particular mechanical structure.
As public information, a ¯le called RoboClass.zip can be downloaded from the
website: http://personales.upv.es/luigraca/RoboClass/code.htm.
This ¯le contains all the information regarding the class itself, Robotics Toolbox
Matlab functions, several samples of use and many STL-¯les for di®erent robots. The
Representation of Robots in Matlab 27

general procedure to work with a serial robot is described in four basic steps: (1)
Generation or downloading the STL-¯les; (2) Editing of the con¯guration ¯le; (3)
Creation and use of functions; (4) Visualization. In next section, the procedure to
deal with these basic steps is detailed.

3.1. Generation of STL-¯les


The STL-¯le format can be generated by many mechanical software packages from a
CAD model. It is widely used for rapid prototyping, 3D printing and computer-aided
manufacturing. STL ¯les describe only the surface geometry of a 3D object without
any representation of surface texture, color or other model attributes. An STL ¯le
describes a raw unstructured triangulated surface by vertices. STL ¯les contain no
scale information, and the units are arbitrary.
As far as this ¯le is only used for display and not to perform the calculations, a low
quality model results in an image with fewer triangles, which will reduce the load
time and improve the frame-rate of the image in the simulation. The class loader can
load both ASCII and binary ¯les, although the latter are loaded considerably faster.
However, the ASCII ¯les' information is readable for the user, which is useful to
hand-edit it. All the STL-¯les must be placed in the same folder. This path will be
indicated in a ¯eld at the con¯guration ¯le. With all the ¯les ready, open Matlab and
select the folder that contains RoboClass as Current folder.

3.2. Con¯guration ¯le


The con¯guration ¯le creates a structure with all the parameters related to the
robot behavior and the information about the STL-¯les to load. This data structure
is sent as an argument to the constructor function to create a robot object. Thus,
multiple di®erent robots can be simulated in a single workspace. The parameters
contained in the data structure of the con¯guration ¯le are divided into di®erent
¯elds.

. General parameters: Robot name and paths.


. Kinematics: Degrees-of-freedom (DOFs), Denavit–Hartenberg (DH) parameters
and joint vector.
. Dynamics: link dynamic properties.
. STL info: Link number, ¯le name of the elements of the link and their colors.
. View info: Axes range limits and camera position.

The data structure has another ¯eld called Real. The purpose of this ¯eld is
containing the drivers to manipulate an actual robot. Thus, this ¯eld will have the
Matlab conversion of the manufacturer commands, which are di®erent for each robot
brand. The development related to this ¯eld is not included in this work and remains
as future work.
28 A. Sanchez et al.

Next, the ¯ve ¯elds indicated above for the con¯guration ¯le are explained.
General Parameters. The user must introduce the name of the robot model. If the
main path has the pwd command, it will detect automatically the class path. In
stlpath specify the folder where the STL-¯les are.
nameRobot ¼ <'robotName'>;
path ¼ pwd;
stlpath ¼ <STL files path>;
Kinematics. Robot kinematics describes the motion of the rigid bodies related to the
robot joint angles. The kinematic parameters of the con¯guration ¯le are: the robot
DOFs, the DH parameters and a vector with the rotational or prismatic character for
each joint as shown below:
dof = <degrees of freedom>;
originTr = <placement matrix>;
joinType = <joints vector>;
theta = <DH theta vector>; % theta is the kinematic joint angle
d = <DH d vector>; % d is the kinematic link offset
a = <DH a vector>; % a is the kinematic link length
alpha = <DH alpha vector>; % alpha is the kinematic link twist [2]

Dynamics. Robot dynamics describes how the robot moves in response to the ac-
tuator torques or forces. Dynamic vectors and the Jacobian matrix of each joint
de¯nes this information. Dynamic parameters must be given by the manufacturer in
order to perform dynamic calculations, as can be seen in Fig. 4.
STL Info. The STL structure contains a ¯eld for each of the N-links of the robot.
Each link has a ¯eld with the number of the previous joint and other M-¯elds, one for

Fig. 4. Dynamics of the robot.


Representation of Robots in Matlab 29

each element composing the link. Each element ¯eld has the name and color of one
STL-¯le.
LinkN.Link ¼ <linkNumber>; LinkN.robot ¼ [];
LinkN.element1.name ¼ <'nameStlFile'>;
LinkN.element1.color ¼ <color in [r g b] format>;
...
LinkN.elementM.name ¼ <'nameStlFile'>;
LinkN.elementM.color ¼ <colorin[rgb]format>;
View Info. The view ¯eld contains the plot values: maximum and minimum limit of
each axis and the angles of the camera (azimuth, i.e. horizontal rotation, and the
vertical elevation).
minX ¼ <minimum value axis X>;
maxX ¼ <maximum value axis X>;
minY ¼ <minimum value axis Y>;
maxY ¼ <maximum value axis Y>;
minZ ¼ <minimum value axis Z>;
maxZ ¼ <maximum value axis Z>;
cameraAZ ¼ <azimuth>;
cameraEL ¼ <elevation>;

3.3. Handling functions


To create robot objects it is necessary to call the constructor with the con¯guration
¯le as parameter. To do that, the line below must be written in Matlab command
window.
 MyRobot ¼ Robot(config());
Once the robot is created, it is possible to use all their functions. As shown in
Figs. 2 and 3, most of the functions of the Robotics Toolbox [2] are included to help
the robot handling. Figure 3 shows the complete set of functions contained in
@Robot folder together with the functions to con¯gure and test this Class. The ¯les
contained into the External Classes folder de¯ne the data structure, meanwhile the
STL-¯les are in separate folders. In the application examples shown in Secs. 4 and 5
there are some examples of use. The function showRobot places the robot in a plot. If
the function is called without arguments, the robot will be showed in the export
position or con¯guration.
 MyRobot.showRobot();
If the function is called as a vector argument with the i angles of the joints, the
robot will be showed in the con¯guration de¯ned by the vector.
 MyRobot.showRobot([1 2 3 4 5 6]);
30 A. Sanchez et al.

In order to visualize a robot in movement insert this function within a for loop.
The function con¯gView can adjust the viewing parameters. If the p does not receive
parameters, it adjusts the plot view to a standard.

 MyRobot.configView();

If this function receives a vector v, it can adjust the view of the plot. This vector
can have three di®erent sizes: azimuth (Az) and vertical elevation (El), the XYZ axes
limits, or all of them.

v ¼ [Az El]
v ¼ [XMIN XMAX YMIN YMAX ZMIN ZMAX]
v ¼ [XMIN XMAX YMIN YMAX ZMIN ZMAX Az El]
 MyRobot.configView(v);

The user can simulate the interaction between the robot and other objects. To
insert objects in the workspace use the external class LoadObject (<¯leName>,
<color>, Tr):

 MyObject ¼ LoadObject(`box', [1 0 0], eye(4));

To create and show the axes of the reference system use the external class
RefSystem:

 SR ¼ RefSystem();

Note that it is required to add the External classes folder to the Matlab path in
order to create objects of these classes. To do this, in Matlab interface, click with the
right button of the mouse on the folder you want to add and select Add to
Path ! Selected Folders.

3.4. How to make a GUI


It may be interesting to create a visual interface to modify the position of the robot.
This section explains the general procedures to create a GUI and how to adapt it to a
robot. The applied steps are shown for the ABB application example in this work.
The steps required to get a GUI are described below:

. Type the command guide in the Matlab console and the quick start window will
appear. In that window, select Blank GUI and press OK button. In the editing
window add a slider object for each of the robot joints. Click on the image of each
slide with the second mouse button to open the properties. To be able to identify
what slide is linked to each joint, rename the ¯eld slider of each slide with the name
of the joint that the slide will change. Edit Max and Min ¯elds with maximum and
minimum rotation for each joint too. Save the ¯le as guideRobot.m and open that
¯le with the text editor.
Representation of Robots in Matlab 31

. Execute the function robotGuide OpeningFcn after the guide is opening. That
function must create the robot and a vector to handle the angles from the slides.
 handles.MyRobot ¼ Robot(configFile());
 handles.q ¼ zeros(1,handles.MyRobot.kinematics.dof);
. Link each slide to the robot joint angles. To do that, it is necessary to add some
code under the callback function of each slide. The code must get the angle from
the slide, set the robot position and save the values with guidata function.
 handles.q(<jointN>) ¼ get(hObject,'Value');
 handles.MyRobot.plot(handles.q);
 guidata(hObject, handles);
. Follow the step above to add as much elements as needed. The general guide is
described below:
 show with the slides,
 add an element in the editing window,
 open the guide ¯le,
 add the code linking the robot parameters with the object values.

3.5. Denavit–Hartenberg parameters


The DH parameters have to be properly de¯ned to use the proposed method for
graphically representing the robot system. These parameters are used for attaching
reference frames to the links of a spatial kinematic chain or robot. The procedure to
obtain the DH parameters is depicted in Fig. 5 and it is composed of the following
steps:

(1) Identify links and joints: Links are numbered from 0 (base) to n (end-e®ector).
Joints are numbered from 1 to n. In this version of the procedure, joint i connects
links i  1 and i.
(2) De¯ne the reference frames for the internal links: Locate zi axis along the axis of
joint i þ 1. The origin of the frame Oi is positioned along joint i þ 1 axis. If the
z-axes are parallel, Oi is arbitrarily chosen. Otherwise, it is located in the in-
tersection between zi and the common normal to zi1 and zi . yi axis is chosen to
compose a right-hand frame.
(3) De¯ne the reference frames for the extremit links: z0 is located along the axis of
joint 1. x0 and y0 are arbitrary. xn axis is normal to the joint n axis, while yn and
zn are arbitrarily de¯ned.
(4) Identify the DH parameters for each link: ai is the distance between zi1 and zi .
di is the distance between xi1 and xi . ai is the angle between zi1 and zi
measured along xi , while yi is the angle between xi1 and xi , measured along zi .
(5) Determine the homogeneous transformation matrices for each joint.
32 A. Sanchez et al.

Joint i Joint i+1


i-1
Joint i-1 Link i
Link

z’i y’i yi i z i
i
O’i x’i xi
yi-1 z i-1 Oi
x i-1
Oi-1

Fig. 5. Graphical representation of the Denavit–Hartenberg parameters.

(6) Determine the overall homogeneous transformation matrix by premultiplication


of the individual joint transformation matrices.

The homogeneous transformation matrix i1 Ai mentioned in Step 5 can be seen as


a composition of rotations and translations by the DH parameter values in order to
move a frame coincident to frame i  1 until it coincides with frame i [1]. Its complete
form is in Eq. (1), where c and s correspond to the trigonometric functions cosðÞ and
sinðÞ, respectively. The overall transformation matrix is de¯ned in Eq. (2), where
0 R and 0 p represent the orientation (in rotation matrix form) and the position,
n n
respectively, of the robot end-e®ector.
2 3
c0i cxi s0i cxi s0i ai c0i
6 s0i cxi c0i sxi c0i ai s0i 7
i1
Ai ¼ 6
4 0
7 ð1Þ
sxi cxi di 5
0 0 0 1
0 
R n 0 pn
0
An ¼ 0 A1 1 A2    n1 An ¼ ð2Þ
0 1

4. Application Examples
Two examples are shown below to illustrate the applicability of the proposed class.
The ¯rst one is referred to the ABB-IRB120, see Fig. 6, which is a 6-DOFs
commercial industrial robot. It will be shown how to export the links of the IRB120
robot from Autodesk Inventor, to set the con¯guration ¯le to consider its behavior, to
use the basic functions and to make a GUI to move each joint.
Representation of Robots in Matlab 33

Fig. 6. Representation of the ABB-IRB120 robot with a guide (visual interface).

4.1. Export STL-¯les


One of the available options to generate the STL-¯les is through Autodesk Inventor
although the process is analog for any other CAD modeling tool. Once the robot links
and any other possible objects are loaded on the workspace, the robot base frame has to
be located at the axes origin and the auxiliary frames for each robot link must be located
according to the DH convention. Then, each piece is exported individually to a ¯le.
STL-¯les can be exported in ASCII mode or binary mode. To export each ¯le in
Autodesk Inventor, uncheck the visibility ¯eld of all the pieces of the robot except the
one to be exported. To do this, select all the pieces to hide and click with the right mouse
button. In the emergent menu, uncheck the visibility parameter. With only one piece in
the workspace, select File ! Export ! Cad model. The export window speci¯es the
name and type of the ¯le to be created, in this case STL. If you click on the options
button, you can select the ¯le type and the resolution of the new model.
First, the CAD ¯les (STEP type) have been downloaded from the ABB website
[16]. The representation of this robot is made of seven ¯les. The ¯rst ¯le has the base
model of the robot. The base must be placed on the origin of the coordinates system.
The other six links will be placed according to the DH convention. To export the
base model in a STL-¯le Autodesk Inventor software, amongst others, can be used
following the next steps. Uncheck the visibility ¯eld of the other pieces but not
the robot base. To do this, select all the models of the robot and then unselect the
base model. Click with the right mouse button on the selected group of pieces and
uncheck the visibility parameter. With only the base model in the workspace, select
File ! Export ! Cad format.
34 A. Sanchez et al.

Fig. 7. STL options ¯le window.

In the export window shown in Fig. 7, introduce the name of the ¯le to be created,
and select STL-¯le in the type ¯eld. Click on options button, select binary format and
set the resolution of the model. It is possible to check the export resolution clicking on
the preview button. Note that less resolution results in a model with fewer faces. This
impacts directly on the appearance of the link/s, see Fig. 8 and the performance of
the simulation, see Fig. 9.

(a) 862 faces IRB120 Link 3 model (b) 43.146 faces IRB120 Link 3 model

Fig. 8. Di®erences between model qualities.


Representation of Robots in Matlab 35

(a)

(b)

Fig. 9. Load time versus Number of faces. (a) ASCII ¯les. (b) Binary ¯les.

Di®erent simulations have been done to compare the load time of STL ASCII and
binary ¯les depending on the number of triangles. Table 1 shows load times for a
complete robot. Loading binary ¯les is always faster than loading ASCII ¯les.
However, as the complexity of the model increases, the di®erence between load times
raises dramatically. Figure 9 shows how fast ASCII load time raises up when the
number of triangles increases in comparison to binary load times. In this example,
there are seven ¯les: base, ¯ve links and ¯nal e®ector. All the ¯les are stored in a
folder called stl IRB beside the RoboClass folder.

Table 1. Load time of STL ¯les.

Face number Load ascii time (s) Load binary time (s) Ratio
15120 4.195026 0.076050 55
30249 10.873158 0.118491 92
75622 48.718367 0.214152 227
151255 200.434706 0.401590 499
302513 788.170335 0.777622 1014
756290 5037.88186 2.308548 2182
36 A. Sanchez et al.

4.2. Con¯guration ¯le


Open the con¯guration ¯le template, save it as con¯gIRB.m and begin to adapt the
parameters to the ABB-IRB120 robot.
General Parameters. The robot name and paths are de¯ned in the general para-
meters. The robot name is `IRB120'. The general path has the pwd command to
detect automatically the class path. The STL-¯les are all in a folder called stl IRB.
nameRobot ¼ 'IRB120';
path ¼ pwd;
stlpath ¼ [pwd 'n stl IRB n'];
Kinematics. The robot has 6-DOFs and all the joints have a rotational behavior.
Moreover, the DH parameters (theta, d, a, alpha) are obtained applying the DH
algorithm to the IRB120 robot.
dof ¼ 6; originTr ¼ eye(4);
jointType ¼ ['r' 'r' 'r' 'r' 'r' 'r'];
theta ¼ [0 -/2 0 0 0 0];
d ¼ [0.29 0 0 0.30 0 0.072];
a ¼ [0 0.27 0.07 0 0 0];
alpha ¼ [-/2 0 -/2 -/2 /2 0];
Dynamics. The dynamic parameters are required to perform dynamic calculations
and must be given by the manufacturer and ¯lled as indicated in Sec. 3.
STL Info. As shown in Table 2, the base and each link are made by one element. Each
element has a ¯eld with the name of the STL-¯le and another ¯eld with the color of

Table 2. STL structure for the ABB-IRB120 robot.

Base Element 1 - Name: IRB120 base.stl


Link number: 0 - Color: [0.9 0.4 0.2]
Linkl Element 1 - Name: IRB120 linkl.stl
Link number: 1 - Color: [0.9 0.15 0.1]
Link2 Element 1 - Name: IRB120Jink2.stl
Link number: 2 - Color: [0.9 0.4 0.2]
Link3 Element 1 - Name: IRB120Jink3.stl
Link number: 3 - Color: [0.9 0.15 0.1]
Link4 Element 1 - Name: IRB120 link4.stl
Link number: 4 - Color: [0.9 0.4 0.2]
Link5 Element 1 - Name: IRB120 link5.stl
Link number: 5 - Color: [0.9 0.15 0.1]
Link6 Element 1 - Name: IRB120Jink6.stl
Link number: 6 - Color: [0.1 0.1 0.1]
Representation of Robots in Matlab 37

the model in Red-Green-Blue (RGB) format. The code must be modi¯ed as shown in
Sec. 3.

base.Link ¼ 0;
base.robot ¼ [];
base.element1.name ¼ 'IRB120n base';
base.element1.color ¼ [0.89 0.39 0.21];

View Info. The selected maximum and minimum axes limit and camera angles are
shown below:

minX ¼ 0:4; minY ¼ 0:8; minZ ¼ 0:4; maxX ¼ 1:0; maxY ¼ 1:8;
maxZ ¼ 1:0; AZ ¼ 40; EL ¼ 10;

4.3. Handling functions


An IRB120 robot object is created when the constructor is called with the IRB120
con¯guration ¯le as argument.

 MyIRB ¼ Robot(configIRB());

To show a plot of the robot in the export position use the showRobot
function.

 MyIRB.showRobot()

To set the transparency level to 50% use the function setTransparency as


follows:

 MyIRB.setTransparency(0.5)

To set the robot in a speci¯c con¯guration, introduce a vector with the joint
angles in radians.

 MyIRB.showRobot([pi/4 pi/4 0 pi/2 0 0])

To simulate a movement use a for loop and the drawnow command as


follows:

 for i¼0:0.05:pi/2,
 MyIRB.showRobot([i/4 i/4 0 i 0 0]);
 drawnow;
 end;

If needed, use the con¯gView function to adjust the viewing parameters.


Calling the function without an argument, i.e. MyIRB.con¯gView(), will set the
viewing parameters to x½1; 1; y½1; 1; z½0; 1, azimuth to 40 degrees and vertical
38 A. Sanchez et al.

elevation to 10 degrees. To set a speci¯c view, e.g. x½0:5; 0:5; y½0:4; 0:4;
z½0; 0:8, azimuth ¼ 40 and vertical elevation ¼ 10, type the command:
 MyIRB.configView([0.5 0.5 0.4 0.4 0 0.8 40 10]);

4.4. Making a GUI


Create a Blank GUI as explained in Sec. 2.4. In the editing window guide add six
slides, one for each of the robot joints. Open the properties of the ¯rst slide and
rename the slider ¯eld with the name slide Q1 and the Max and Min ¯elds with
rotation of the rotation limits. Repeat for each joint the steps described for slide Q1.
Save the ¯le as guideIRB.m next to con¯guration ¯les, and open that ¯le with the
text editor. At the function robotGuide OpeningFcn create the robot and the vector
to handle the angles from the slides:
 handles.MyIRB ¼ Robot(configIRB());
 handles.q ¼ zeros(1,handles.MyIRB.kinematics.dof);
To link the slides to the robot joints and show it in the guide, follow the
instructions below. Under slider Q1 Callback get the angle from the slide and

Detail view of link 3

Fig. 10. Custom Schunk Arm (CSA), a 7-DOFs robot, with a detail view of link 3.
Representation of Robots in Matlab 39

show the robot with the updated position. Then, save the values with guidata
function.
 handles.q(1) ¼ get(hObject,'Value');
 handles.MyIRB.showRobot(handles.q);
 guidata(hObject, handles);
To add more elements to the guide as in Fig. 6 the same steps are repeated.

Fig. 11. CSA movement through a linear trajectory.


40 A. Sanchez et al.

4.5. Second application example


The second example is referred to as 7-DOFs robot arm developed at the Miguel
Hernandez University: the Custom Schunk Arm (CSA). The procedure is basically
the same to that used for the IRB120 example in Secs. 3.1 to 3.4, except that the
CSA comprises more elements: 36. Details omitted for brevity. The result obtained
for this second example is shown in Fig. 10, while Figs. 11(a) to 11(i) represent a
sequence of nine frames showing the CSA robot during the tracking of a linear
trajectory.

5. Conclusion
In this paper, a novel open-source software tool to simulate realistic serial robots in
Matlab has been presented. The library allows loading the CAD models of the robot
links from ASCII or binary STL format in order to avoid a representation of the robot
based on wires. As such, it allows performing very realistic simulations (e.g. see Fig. 6 in
comparison to Fig. 1) in an easy and fast way, which is useful both for research and
teaching purposes due to the increase in simulation accuracy. The e®ectiveness and
usability of RoboClass use has been demonstrated throughout two application
examples. The class presented in this paper is ready to adapt the CAD models of each
robot manufacturer to Matlab environment in order to control serial robots in a
realistic scene. This adaptation must be done only once for a given robot before using it.
Since the class creates the robot parts from external con¯guration ¯les, it is
possible to include di®erent robots in the same workspace, see Fig. 12, or even to
include other elements of the manufacturing process (e.g. elements of the production
line, security elements, manipulated pieces, etc.) in order to get a more complete
simulation scene.
Although the class has been developed for serial arms, it is possible to use it with
other kinematic architectures, like parallel kinematic machines. The class is basically
a wrapper for the mechanical information (STL and dynamic parameters) and the
robot analysis libraries (Robotics Toolbox). When using another toolbox for parallel
robots, like the one for a 3UPS1S robot in [17] or the toolbox for planar 3RRR device
[18], the class could be extended to use it with this kind of mechanism but it will be a
di®erent class for each parallel robot, not a generalized class like in the case of serial
robots.
The developed tool is especially useful both for robotics research and teaching in
order to show a realistic representation of the robot and its environment in the
widespread software Matlab. Moreover, the user can customize the open source code
to its requirements and use the advanced functions to get an accurate simulation.
The main advantages of the simulation tool developed in this work are
listed below

. It can be used both for research and education purposes.


. It allows a realistic representation of the robot and its environment.
Representation of Robots in Matlab 41

Fig. 12. Multiple robot simulation.

. It is compatible with kinematic and dynamic analysis.


. It can be easily extended to be used with parallel robots.

References
1. M. Bashari, E. Bagheri and W. Du, Dynamic software product line engineering: A ref-
erence framework, Int. J. Softw. Eng. Knowl. Eng. 27(2) (2017) 191–234.
2. K. Honda, H. Washizaki and Y. Fukazawa, Generalized software reliability model con-
sidering uncertainty and dynamics: Model and applications, Int. J. Softw. Eng. Knowl.
Eng. 27(6) (2017) 967–993.
3. Z. K. Aghdamand and B. Arasteh, An e±cient method to generate test data for software
structural testing using arti¯cial bee colony optimization algorithm, Int. J. Softw. Eng.
Knowl. Eng. 27(6) (2017) 951–966.
4. M. Flanders and R. C. Kavanagh, Build-A-Robot: Using virtual reality to visualize the
Denavit–Hartenberg parameters, Comput. Appl. Eng. Edu. 23(6) (2015) 846–853.
5. N. A. Bates, A. L. McPherson, R. J. Nesbitt, J. T. Shearn, G. D. Myer and T. E. Hewett,
Robotic simulation of identical athletic-task kinematics on cadaveric limbs exhibits a lack
of di®erences in knee mechanics between contralateral pairs, J. Biomech. 53(28) (2017)
36–44.
6. A. Doshi, R. T. Smith, B. H. Thomas and C. Bouras, Use of projector based augmented
reality to improve manual spot-welding precision and accuracy for automotive
manufacturing, Int. J. Adv. Manuf. Technol. 89(5–8) (2017) 1279–1293.
7. P. Corke, A robotics toolbox for MATLAB, IEEE Robot. Autom. Mag. 3(1) (1996)
24–32.
8. F. Chinello, S. Scheggi, F. Morbidi and D. Prattichizzo, Kuka control toolbox, IEEE
Robot. Autom. Mag. 18(1) (2011) 69–79.
42 A. Sanchez et al.

9. PerBergstr€om,"IGESToolbox".Mathworks (accessed May 2017), http://www.math-


works.com/matlabcentral/¯leexchange/13253-iges-toolbox.
10. D. Riley, 3D Puma Robot Demo, Mathworks (accessed May 2017) http://www.math-
works.com/matlabcentral/¯leexchange/14932-3d-puma-robot-demo.
11. Y. Cao, Learning robotics through developing a virtual robot simulator in Matlab,
in Proc. ASEE Annual Conference and Exposition, 2011, pp. 1–13.
12. SimMechanics, The Mathworks, Users Guide, 2005.
13. L. Huges, N. Bredeche and T. Futurs, Simbad: an autonomous robot simulation package
for education and research, Proc. Int. Conf. Simulation of Adaptive Behavior, Springer's
Lecture Notes in Computer Sciences/Arti¯cial Intelligence Series, 2006, pp. 831–842.
14. I. Bonev, RoKiSim   Robot Kinematic Simulation, Multi-platform educational software
tool for 3D simulation of serial six-axis robots, (accessed October 2017) https://www.
parallemic.org/RoKiSim.html.
15. H. Arshad, J. Jamal and S. Sahran, Teaching robot kinematic in a virtual environment,
Proc. World Cong. Eng. Comp. Sci. 1 (2010) 307–310.
16. ABB webpage (accessed May 2017), http://www.abb.es/product/en/9AAC100735.aspx
17. J. M. Sabater-Navarro, N. García, C. Perez, E. Fernandez, R. Saltaren and M. Almo-
nacid, Kinematics of A Robotic 3ups1s Spherical Wrist Designed for Laparoscopic
Applications, Int J. Med. Robot. Comput. Assist. Surg. 6(3) (2010) 291–300.
18. C. Jara, Jose M. Sabater-Navarro, J. M. Azorín, N. García C. Perez, R. Saltaren and
E. Yime, Analisis Del Espacio De Trabajo De Un Robot Paralelo 3RRR, XXIX Jornadas
de Automatica, 2010, pp. 1–7.

You might also like