Robotics Lab Journal: ECS Program
Robotics Lab Journal: ECS Program
BE Sem VIII
Electronics and Computer Science
Robotics Laboratory Journal
(ECL801)
1
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
2
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
4
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
LO No. LO Statement (At the end of the course, students will be able to …) BL
1 To illustrate coordinate transformations. (Application) 3
6 To generalize from given facts and relate knowledge from several areas 6
5
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
List of Experiments
Sr. LO PSO PI
Title
No.
1 STUDY OF ROBOTIC MANIPULATORS 1 1 1.2.2,1.7.1,4.4.3
8 MINIPROJECT 6 2 1.2.2,1.7.1,2.8.2,3.
8.2,4.4.3,5.4.1,
6.1.17.1.1,,8.1.1,8.2.
2,9.1.1,9.2.2,9.2.3,9.
3.1,10.3.1,11.3.1,11.
3.2,12.1.1
6
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
Grade
Overal
Practicals/TutoriaIs l
Grade
Assignment/Report Writing & Presentation/Group Discussion
Internal Assessments marks IA1....... & IA2 ....... out of ............
Average =…..
1………………………………
7
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
2………………………………
8
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
EXPERIMENT NO: 1
STUDY OF ROBOTIC MANIPULATORS
9
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
EXPERIMENT NO:1
STUDY OF ROBOTIC MANIPULATORS
Aim: Study of given robot models and determine the Work Space
Envelope of SCARA robot
Theory:
Work Space Envelope: The locus of all the points traced by the tip of the end
effectors in the three-dimensional space is defined as WSE. The area in which
robot can do useful work is work envelope area. The geometry of the work
envelope is determined by the sequence of joints used for the first three axes.
Cartesian Robot: The three major axes of a Cartesian robot are all prismatic. The
prismatic joints correspond to moving the wrist up and down, in and out and back
and forth.
Cylindrical Robot:If the first joint of the Cartesian robot is replaced with revolute
joint it becomes a cylindrical robot.the configuration of cylindrical robot is RPP.
(R-revolute,P-prismatic).The first revolute joint swings the arm back and forth
about a vertical base axis.The second prismatic joint then move the wrist up and
down along vertical axis and the third prismatic joint moves the wrist in and out
along the radial axis.Since there will be some radial position work envelope
generated by this configuration is the volume between two vertical concentric
cylinders.
Spherical Robot: If the second joint of a cylindrical robot is replaced by a revolute
joint we get a spherical robot.The first revolute joint swings the arm back and forth
about the vertical axis while the second revolute joint pitches the arm up and down
about a horizontal shoulder axis.The prismatic joint moves the wrist radially in and
out.The work envelope generated is the volume between two spheres
SCARA Robot SCARA is Selective Compliance Assembly Robot Arm. robot has
two revolute joints and one prismatic joint to position the wrist. for a SCARA robot
the axes of all the three joints are vertical The first revolute joint swings the arm
10
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
back and forth about a base axis that can also be thought of asa vertical shoulder
axes .the second revolute joint swings the forearm back and forth about vertical
elbow axis. Thus two revolute joints control motion in a horizontal position The
vertical component of the motion is provided by third joint which slides wrist up
and down.
The work envelope of SCARA robot can be complex depending upon the limits on
the ranges of travel for the first two axes.
Articulated Robot:An articulated robot is the dual of Cartesian robot in the sense
all three of the major axes are revolute rather than prismatic.
The first revolute joint swings the robot back and forth about a vertical base axis.
The second joint pitches arm up and down about a horizontal shoulder axis and
the third joint pitches the forearm up and down about horizontal elbow axis.
11
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
EXPERIMENT NO:2
A PROGRAM TO IMPLEMENT COORDINATE TRANSFORMATION
12
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
Experiment No:2
A program to implement Coordinate Transformation
1 0 0
R1(θ) = ⌈ 0 cos ( θ) −sin (θ) ⌉
0 sin (θ) cos (θ)
CODE:
if (value == 123)
R= R1*R2*R3
else (value == 231)
R= R2*R1*R3
end
end
PF=R*transpose (PM)
OUTPUT:
14
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
15
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
EXPERIMENT NO :3
A PROGRAM TO IMPLEMENT HOMOGENEOUS COORDINATE
TRANSFORMATIONS
16
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
Experiment No 3
A program to implement Homogeneous Coordinate Transformations
Aim:
To implement Composite homogeneous coordinate transformations
Theory :
Algorithm
1. Initialize transformation matrix as Identity matrix
2. Represent rotations and translations using separate HCTM matrix
3. Represent Composite rotations in separate HCTM matrix
4. If the mobile coordinate frame M is to be rotated about or translated along a
unit vector of the fixed coordinate frame F pre multiply the HCTM by the
appropriate fundamental HCTM matrices
5. If the mobile coordinate frame M is to be rotated about or translated along a
unit vector of the mobile coordinate frame M post multiply the HCTM by the
appropriate fundamental HCTM matrices
6. If there are more fundamental rotations or translations go to step 4,else
stop.The resulting CHCTM matrix T transforms mobile M frame coordinates
into F frame coordinates
CODE:
m1 = [1 0 0 1];
T = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1];
operation = input ("First Operation Rotation or Translation’s");
if operation == 'R'
x = input ("Angle of Rotation");
a = input ("Axis of Rotation");
if a == 1
HR = [1 0 0 0; 0 cos(x) -sin(x) 0; 0 sin(x) cos(x) 0; 0 0 0 1];
elseif a == 2
HR = [cos(x) 0 sin(x) 0; 0 1 0 0; -sin(x) 0 cos(x) 0; 0 0 0 1];
else a = 3;
HR = [cos(x) -sin(x) 0 0; sin(x) cos(x) 0 0; 0 0 1 0; 0 0 0 1];
end
H1 = HR * T;
17
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
H1 = HT * T;
end
H2 = HR;
H2 = HT;
end
H=H2*H1;
OUTPUT:
18
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
19
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
EXPERIMENT NO:4
20
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
Experiment No:4
A program to implement Direct Kinematics
Aim: To solve the direct kinematics of a 3-axis planar robotic arm and 4 axis
SCARA robot and study DH algorithm.
Theory: In Direct Kinematics joint variables of a given robot are given and
determine the position and orientation of the tool with respect to a coordinate frame
attached to the robot base using DH algorithm.
DH algorithms a two pass algorithm in which the first pass assign a set of RHOCF
to the distal end of each link. On the second pass the values for the kinematic
parameters are determined.
Once the link coordinates are assigned, we can then transform coordinate frame k
to coordinate frame k-1 using a homogeneous coordinate transformation matrix.
By multiplying several of these coordinate transformation matrices we get a
coordinate transformation matrix which transforms or maps tool coordinates into
base coordinates. This composite homogeneous coordinate transformation matrix
is called the arm matrix.
1. Number the joints from 1 to n starting with the base and ending with the
tool yaw, pitch and roll in that order.
2. Assign a right handed orthonormal coordinate frame Lo to the robot
base, making sure that zo aligns with the axis of joint 1.set k = 1.
3. Align zk with the axis of joint
int k +1
4. Locate the origin of Lk at the intersection of the zk and zk -1 axes .If
they do not intersect ,use the intersection of zk with a common normal
between zk and zk- 1
5. Select xk to be orthogonal to both zk and zk -1 .If zk and zk -1 are parallel
point xk away from zk-1
6. Select yk to form a right handed ortonormal coordinate frame Lk
21
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
8. Set the origin of Ln at the tool tip.Align zn with the approach vector, yn
with the sliding vector , and Xn with the normal vector of the tool
Set k = 1
9. Locate point bk at the intersection of the xk and Zk-1 axes .If they do not
intersect ,use the intersection of xk with a common normal between xk and
zk-1
10. Compute qk as the angle of rotation from xk-1 to xk measured about Zk-1
11. Compute dk as the distance from the origin of frame Lk-1 to point bk
measured along Zk-1
12. Compute Bk as the distance from poinf bk to the origin of frame Lk
measured along xk
13. Compute ax as the angle of rotation from zk- 1 to zk measured about xk
14. Set k = k+1 If k n, go to step 8 , else
stop,
This is called as DH algorithm.
CODE:
l1 = 10; % length of first arm
l2 = 7; % length of second arm
theta1 = 0:0.1:pi/2; % all possible theta1 values
theta2 = 0:0.1:pi; % all possible theta2 values
[THETA1,THETA2] = meshgrid(theta1,theta2); % generate grid of angle values
X = l1 * cos(THETA1) + l2 * cos(THETA1 + THETA2); % compute x coordinates
Y = l1 * sin(THETA1) + l2 * sin(THETA1 + THETA2); % compute y coordinates
data1 = [X(:) Y(:) THETA1(:)]; % create x-y-theta1 dataset
data2 = [X(:) Y(:) THETA2(:)]; % create x-y-theta2 dataset
plot(X(:),Y(:),'r.');
axis equal;
xlabel('X','fontsize',10)
ylabel('Y','fontsize',10)
title('X-Y coordinates for all theta1 and theta2 combinations','fontsize',10)
OUTPUT:
EXPERIMENT NO:5
A PROGRAM TO IMPLEMENT INVERSE KINEMATICS
23
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
Experiment No:5
A program to implement Inverse Kinematics
Aim: Write a program to implement the inverse kinematics Solution
of the given SCARA Robot and determine the Joint variable for the
given TCV.
Theory: Inverse Kinematics Problem ,Given a desired position P and orientation R for
the tooI find the values for the joint variables q which saisfy the arm equation
given by
R P
Tbase tool ( q) = ⌈ 0 1 ⌉
The inverse kinematics problem is more difficult than the direct kinematics problem,
because no single explicit systematic procedure analogous to the DH algorithm is
available .As a result each robot or generally simlilar class of robots has to be treated
separately. It makes Robot more versatile..
Solution to an IK problem are not unique. There are multiple solutions
In tool configuration space the two solutions are identical, because they produce the
same p and R but in joint space they are clearly distinct.Typically the elbow up solution
is preffered because it reduces the chance of collision.
Algorithm
1. Start
2. Input tool configuration vector
3. Extract joint variables
4. stop.
CODE:
w = input("enter the value for w: ");
d = input("enter the value for d: ");
a = input("enter the value for a: ");
q2 = acos(((w(1)^2) + (w(2)^2) - (a(1)^2) - (a(2)^2))/(2*a(1)*a(2)));
Y = (((a(2)*sin(q2)*w(1)) + (a(1) + a(2)*cos(q2))*w(2)));
X= ((a (1) +(2) *cos(q2)) *w (1)) -(a (2) *sin(q2) *(w (2)));
q1a = atan2(Y,X);
q1b = atan2(((a(2)*sin(-q2)*w(1)) + ((a(1) + a(2)*cos(-q2))*w(2))), (((a(1) +
a(2)*cos(-q2))*w(1))-(a(2)*sin(-q2)*w(2))));
q3 = d(1)-d(4)-w(3)';
q4 = pi*log(w(6));
disp("q2= ")
disp(q2)
disp("q1a= ")
24
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
disp(q1a)
disp("q1b= ")
disp(q1b)
disp("q3= ")
disp(q3)
disp("q4= ")
disp(q4)
OUTPUT:
25
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
EXPERIMENT NO:6
A PROGRAM TO IMPLEMENT TEMPLATE MATCHING
26
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
27
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
Experiment No:6
A program to implement template matching
Now in the memory there are a number of templates Ti (k j) and one image I (k,j).
To search whether a given part (template) belongs to the class of parts (image) or
not take the template & scan the gray scale image or digital image I (k , j) from
left to right & top to bottom using raster scanning method.
At each time of translation obtain & index performance called as performance
index Pi(x,y).
Whenever the template matches with the part in the image, the index=0. the match
has been folm"d search is successful the location of the part is also found. The
performance index is given by
Pi(x,y)= MoΣ no
Σ I(k=x,j+y)-Ti(k,j)
k=1 j=1
Algorithm
1. set I=1,x=0,y=0,e>0
2. compute Pi(x,y)
3. set y=y+1;if y<=(n-n0) go to step 2
4. set y=0,x=x+1,if x<=(m-m0) go to step2
5. set found =false.
CODE:
i = [2 1 0 0 3; 0 0 5 0 0; 0 4 0 6 0; 1 0 5 0 0];
t=[0 4 0; 3 0 5; 0 4 0];
P= [0 0 0;0 0 0];
m=5;
n=4;
m0=3;
n0=3;
for k =1:n0
for j=1:m0
for x = 1:n-n0+1
for y =1:m-m0+1
P(x,y) = P(x,y)+abs(i(k+x-1,j+y-1)-t(k,j));
end
end
28
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
end
end
disp("P")
disp(P)
Y = min(P,[],1);
Z = min(Y);
disp("Minimum Performance Index is :")
[r,c]=size(P);
for i=1:r
for j=1:c
if(P(i,j)==Z)
disp("Location:")
disp(i-1),disp(","),disp(j-1);
end
end
end
OUTPUT:
29
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
EXPERIMENT NO:7
A PROGRAM TO IMPLEMENT TRAJECTORY PLANNING
30
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
Experiment No:7
A PROGRAM TO IMPLEMENT TRAJECTORY PLANNING
Aim - To compute and plot trapezoidal velocity trajectory for 2D planar motion.
The graphical form of motion (position, velocity, acceleration and jerk) description is
named the motion diagram. Motion needed to be planned for the robot after the
31
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
program instruction is read from program memory and before the drives of the
manipulator start motion. Multiple limits are considered on trajectory planning (travel
time, maximal values of velocity and acceleration and jerk. The maximum velocity
limit can depend on technology or emergency conditions. Higher velocity is more
dangerous for people working in the same room with a robot. Higher acceleration and
deceleration values need drive motors with higher output power and manipulator
construction standing higher forces and torques. Jerk value can be limited by smooth
acceleration and deceleration. Motion diagrams can be described by one third
polynomial of position, second order of polynomials of velocity and linear
acceleration (deceleration) function. In simple cases the motion diagram of the
trajectory is described by a simple function. The velocity diagram has the form of
triangle or trapezoid.
CODE:
wpts = [0 45 15 90 45; 90 45 -45 15 90];
[q, qd, qdd, tvec, pp ] = trapveltraj(wpts, 501);
subplot(2,1,1)
plot(tvec, q)
xlabel('t')
ylabel('Positions')
legend('X','Y')
subplot(2, 1, 2)
plot(tvec, qd)
xlabel('t')
ylabel('Velocities')
legend('X','Y')
32
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE
Chembur, Mumbai - 400 088
UG Programme in Electronics and Computer Science
OUTPUT:
33