Documente Academic
Documente Profesional
Documente Cultură
TOOLBOX
Lab Manual
Contents
1. LAB-01
Introduction
Downloading toolbox
Linking toolbox with matlab
2. LAB-02
Rotation matrix
Homogenous matrix
3. LAB-03
Inter conversion of euler angles & homogenous matrix
3
4. LAB-04
3D representation of rotation & Homogenous matrix
5. LAB-05
Creating links
Creating robot object
6. LAB-06
Plotting robot object
Animation of robot
7. LAB-07
DH Matrix
Forward kinematics
8. LAB-08
Inverse kinematics
9. LAB-09
Joint trajectory
Joint position
Joint velocity
Joint acceleration
1.
LAB-01:
Introduction :
This Toolbox provides many functions that are useful in robotics
including such things as kinematics, dynamics, and trajectory
generation. The toolbox is useful for simulation as well as
analyzing results from experiments with real robots.
The Toolbox is based on a very general method of representing the
kinematics and dynamics of serial-link manipulators. These
parameters are encapsulated in Matlab objects. Robot objects can
be created by the user for any serial-link manipulator and a
number of examples are provided for well know robots such as
the Puma 560 and the Stanford arm. The toolbox also provides
functions for manipulating data types such as vectors,
transformations and unit-quaternions which are necessary to
represent 3-dimensional position and
orientation.
How to obtain the toolbox:
5
The Robotics Toolbox is freely available from the Toolbox home page
at
http://www.petercorke.com
The web page requests some information from you regarding
such as your country, type of organization and application.
The file is available in zip format (.zip). Download it and unzip it.
Linking toolbox with matlab
Copy the unzip folder (rvctools) into the MATLAB toolbox in
directory //C.
i.e
Now run your Matlab , click on the setpath button then add your
robot folder that you have already copied in the Matlab toolbox
and save it.(see fig 1 & 2)
Figure 1
Figure 2
Now ensure that robot folder is open in your matlab as shown below
(Figure 3) ,repeat this step each time using robot toolbox.
Figure 3
You have successfully linked robot toolbox with your matlab,now you can
easily solve robotics problems using matlab,but each time you have to
open robot toolbox in your matab as already mention in above figure(3).
2.
LAB-02:
Rotation matrix:
In linear algebra, a rotation matrix is a matrix that is used to perform a
rotation in Euclidean space. For example the matrix:
>> R=rotx(60,'deg')
R x=
1.0000
0 0.5000 -0.8660
0 0.8660 0.5000
>> Ry=roty(60,'deg')
Ry =
0.5000
0 0.8660
0 1.0000
-0.8660
0
0 0.5000
0.8660 0.5000
1.0000
Homogenous matrix:
A system is equivalent to a matrix equation of the form
Homogenous translation:
T = transl(x, y, z) is a transform (4 4) representing a pure translation.
Example:
>> t=transl(4,8,9)
t= 1
rotation:
Rotation about X axis:
T = trotx(theta) is a transformation (4 4) representing a rotation of theta
radians about the x-axis.
T = trotx(theta, deg) as above but theta is in degrees.
Rotation about Y axis
T = troty(theta) is a transformation (4 4) representing a rotation of theta
radians about the y-axis.
T = troty(theta, deg) as above but theta is in degrees.
Rotation about Z axis
T = trotz(theta) is a transformation (4 4) representing a rotation of theta
radians about the z-axis.
T = trotz(theta, deg) as above but theta is in degrees.
11
Lab-02 Task:
1) Find a rotation matrix R represents a rotation of 450 about x followed
by - 600 about(new y1(j1)),compare this result with your manual
result.
2) Show that Rx*RY RY*RX
3) Find a homogeneous transformation matrix T of frame that is
translated 4 units along x-axis, 1.4 units along y-axis followed by
rotation of 660 about z-axis.
12
3.
LAB-03:
13
Options
deg Compute angles in degrees (radians default)
Options
15
deg
17
4.
Lab-04:
noaxes
axis, A
Set dimensions of the MATLAB axes to A=[xmin xmax ymin
ymax zmin zmax]
frame, F The frame is named F and the subscript on the axis labels is F.
text opts, opt A cell array of MATLAB text properties
18
width, w
thick, t
3d
anaglyph, A
Specify anaglyph colors for 3d as 2 characters for left
and right (default colors rc):
red
g
b
c
m
green
blue
cyan
magenta
Label the X,Y,Z axes with the 1st, 2nd, 3rd character of the string L
'frame',
'F0','color','r')
>> T1=troty(0.6)
>> hold on
19
>> trplot(T1,
'frame',
'F1','color','g')
Lab-04 Task:
1) If the coordinate frame 01X1Y1Z1 is obtained from the coordinate frame
O0X0Y0Z0 by a rotation of /2 about the x-axis followed by a rotation of
/2 about the fixed y-axis, find the rotation matrix R representing the
composite transformation. Sketch the initial and final frames.
2) Find the Homogeneous matrix T corresponding to the set of Euler
angles{-/2, 0,/4}. Sketch matrix T relative to base frame use
arrow to find the direction of X1 relative to X0 .
20
5.
Lab-05:
Links
The links are the rigid members connecting the joints. The joints (also
called axes) are the movable components of the robot that cause relative
motion between adjacent links.
Creating links:
L
link
link([alpha,
a,
theta,
d])
link([alpha,
a,
theta,
d,
link(q)
sigma])
show(L)
The link function constructs a link object. The object contains kinematic
and dynamic parameters as well as actuator and transmission parameters.
The first form returns a default object, while the second and third forms
initialize the kinematic model based on Denavit and Hartenberg
parameters.
The second last form given above is not a constructor but a link method that
returns the link transformation matrix for the given joint coordinate. The
argument is given to the link object using parenthesis. The single argument
is taken as the link variable q and substituted for or D for a revolute or
prismatic link respectively.
The Denavit and Hartenberg parameters describe the spatial relationship
between this link and the previous one.
alpha
i-1
Ai-1
link length
theta
Di
Di
sigma
Ai
Examples
>> L = link([-pi/2, 0.02, 0, 0.15]) %creating link object
L =
-1.570796
>> show(L)
alpha
A
= 0.02
theta
D
= -1.5708
= 0
= 0.15
sigma
= 0
>> L(0.6)
angle
ans =
0.8253
-0.0000
-0.5646
0.0165
0.5646
0.0000
0.8253
0.0113
-1.0000
0.0000
0.1500
22
1.0000
robot
robot(rr)
r
r
r
=
=
=
robot(link ...)
robot(DH ...)
robot(DYN ...)
robot is the constructor for a robot object. The first form creates a default
robot, and the second form returns a new robot object with the same value
as its argument. The third form creates a robot from a cell array of link
objects which define the robots kinematics and optionally dynamics. The
fourth and fifth forms create a robot object from legacy DH and DYN format
matrices.
Since Matlab does not support the concept of public class variables
methods have been written to allow robot object parameters to be
referenced (r) or assigned (a) as given by the following table
Method
Operation
robot.n
robot.link
robot.name
r+a
r+a
Returns
number of joints
cell array of link objects
robot name string
23
robot.manuf
r+a
robot.comment
r+a
robot.gravity
direction
robot.mdh
modified.
DH convention: 0 if standard, 1 if
r+a
robot.tool
r+a
robot.dh
legacy DH matrix
robot.dyn
robot.q
r+a
joint coordinates
robot.qlim
r+a
2 matrix
robot.islimit
r
joint limit vector, for each joint set to -1,
0 or 1 depending if below low limit, OK, or greater than upper limit
robot.offset
r+a
robot.plotopt
r+a
robot.lineopt
r+a
robot.shadowopt
r+a
24
Example:
>> L1 = link([ pi/2 0
0])
L1 =
1.570796 0.000000 0.000000 0.000000 R
>> L2 = link([ 0
(std)
0 0.5 0])
L2 =
0.000000 0.000000 0.500000 0.000000 R
(std)
>> R=robot({L1,l2})
R=
noname (2 axis, RR)
grav = [0.00 0.00 9.81]
alpha
theta
R/P
(std)
(std)
>> R.link
ans =
[1x1 link]
[1x1 link]
>> R.tool
ans =
25
>> R.base
ans =
1
>> R.n
ans =
2
Serial-link robot class
A concrete class that represents a serial-link arm-type robot. The
mechanism is described using Denavit-Hartenberg parameters, one set per
joint.
Create a SerialLink robot object
R = SerialLink(links, options) is a robot object defined by a vector of Link
objects.
26
comment, COMMENT
tool, T
Examples
Create a 2-link robot
L(1)
Link([ 0 0
L(2)
Link([0 0 2 0]);
twolink
0 -90
d2
0 90
d3
0 0
2
*
0 -90
0 90
0 0
name,
two
5
*
6
*
SerialLink(L,
link);
Lab-05 Task:
1. Create three links of your own choice,then make a robot object from it
using:
a)Robot function b) SerialLink function. Name your robot
Three_Link_manipulator for both of the above functions.Check its
name and number of joints using options to show that you have
created your robot accurately.
6.
LAB-06:
Animation of robot:
drivebot(robot)
Pops up a window with one slider for each joint. Operation of the sliders
will drive the graphical robot on the screen. Very useful for gaining an
understanding of joint limits and robot workspace.
30
The joint coordinate state is kept with the graphical robot and can be
obtained using the plot function. The initial value of joint coordinates is taken
from the graphical robot.
Examples: To drive a graphical Puma 560 robot
>> puma560
% now drive it
Lab-06 Task:
1) Build SCARA robot from DH table shown below.
2) Name your robot as SCARA ,plot it if all joint variables are
zero.
3) Create a duplicate scara named SCARA_DUPL, and
translate its base -200 units along x-axis and 150 units
along y-axis. Plot SCARA_DUPL with the previous plot in
the same window to observe the translation.(joint variables
are zero).
4) Plot SCARA if 2nd joint is rotated 900 and 3rd joint
translated 8 units.
5) Animate SCARA and observe each joint movements.
31
7.
Lab-07:
DH Matrix:
32
>> a = sym('a');
>> b = sym('T');
%T= theta
>> c = sym('P');
% p=alpha
>> d = sym('d');
>> A=trotz(b)*transl(0,0,d)*transl(a,0,0)*trotx(c)
A =
[ cos(T), -cos(P)*sin(T),
[ sin(T),
[
0,
sin(P)*sin(T), a*cos(T)]
cos(P),
d]
33
0,
0,
0,
1]
%%% Now, to substitute the symbols by numerical values, we can use the
%%% subs function. For example, if we want to set all variables to
%%% zero, we can execute the following substitution:
>> A=subs(A,{c,a,b,d},{0,0,0,0})
A=
[ 1, 0, 0, 0]
[ 0, 1, 0, 0]
[ 0, 0, 1, 0]
[ 0, 0, 0, 1]
Forward kinematics:
T= fkine(robot,q)
fkine computes forward kinematics for the joint coordinate q giving a
transform for the location of the end-effector. robot is a robot object which
contains a kinematic model in either standard or modified DenavitHartenberg notation. Note that the robot object can specify an arbitrary
transform for the base of the robot.
If q is a vector it is interpreted as the generalized joint coordinates, and
fkine returns a transformation for the final link of the manipulator. If q is a
34
-0.5000
-19.2820
0.5000
-0.8660
126.6025
1.0000
1.0000
Lab-07 Task:
1) Represent DH matrix A in terms of theta , alpha , a &
d ,using sym command to define symbols.
2) Find DH matrices (A01,A12,A23.A56) for each link in the
given table.Use subs command to replace the link
parameters in the general matrix.
3) Build a robot cylindrical from the given table.
4) Plot the robot cylindrical if joint variables are zero.
5) Find forward kinematics of cylindrical robot for the given
joint variables q=[900 56 -10 300 600 300 ].
6) Plot the robot for above q find the position & orientation
( R P Y ) of the Tool in world frame for above q .
35
8.
Lab-08:
Inverse kinematics:
q
ikine(robot,
T)
ikine(robot,
T,
q0)
ikine(robot,
T,
q0,
M)
ikine returns the joint coordinates for the manipulator described by the
object robot whose endeffector transform is given by T. Note that the
robots base can be arbitrarily specified within the robot object.
If T is a transform then a row vector of joint coordinates is returned. If T is
a transform trajectory of size 4 4 m then q will be an n m matrix where
36
3.1416
37
Lab-08 Task:
1) Find the inverse kinematics of cylindrical robot (ref -Lab-07)
If the end effector is -50 unit translated alond x-axis 40 units
along z-axis and have a Roll of 900 .
2) Plot the robot for the joint parameters obtained by inverse
kinematics.
3) Find the inverse kinematics of puma560 if it has to pick a ball
placed at a point -0.7 unit along x-axis & 0.3 units along y=axis
& -0.4 units along z-axis.Plot it in a pose to pick the ball.
9.
Lab-09:
pos=jtraj(15,75,t)
%Start angle, end angle and return the position
values into an array pos
plot(t,pos) %plot the result
To look at the joint velocity & acceleration
[pos vel acc]=jtraj(15,75,t) %note jtaj can return a matrix, the first column
is position, the second column is velocity,& third column is acceleration
>> subplot(3,1,1)
>> plot(t,pos,'color','r')
>> subplot(3,1,2)
39
>> plot(t,vel,'color','g')
>> subplot(3,1,3)
>> plot(t,acc,'color','m')
To examine multiple joints, the start and end angles can be a matrix:
Start
Stop
angle
angle
The given table 1
shows joint
15
75
angles of
puma560 robot.
2
45
0
1) Compute 3
each joint
30
120
trajectory 4
and plot all in a
20
25
5
60
30
single
window.
30
0
2) Compute 6
each joint velocity
and plot all in a single window.
3) Compute each joint acceleration and plot it in a single window.
Lab-09 Task:
Joint
number
40
41