2R ROBOTIC ARM USING MATLAB
AIM
Write a programe in matlab to simulate the forward kinematics of a 2R robotic arm.
Figure of 2R robotic arm
Let coordinates of Point A are (x0,y0),
Point B are (x1,y1)
Point c are (x2,y2)
Let theta1 be the angle subtended by the link 1 with reference to the horizontal axis theta2 be the angle subtended by the link 2 with reference to the horizontal axis.
Length of link 1 and link 2 are 1.5 and 1 units.
Objective
- Create an animation file of the plot.
- Upload an animation on You tube and provide the You tube link for an animation in your report.
Link of Animation of robotic arm - https://youtu.be/-w7VRhY7UE8
Presentation of Code
clear all
close all
clc
%inputs (lenght and angles)
L1=1.5;
L2=1;
theta1=linspace(0,90,12);
theta2=linspace(0,90,12);
ct=1;
for i=[1:length(theta1)]
THETA1=theta1(i);
for j=[1:length(theta2)]
THETA2=theta2(j);
%initial values
x0=0;
y0=0;
%by geometry
x1=L1.*cosd(THETA1);
y1=L1.*sind(THETA1);
x2=x1+(L2.*cosd(THETA2));
y2=y1+(L2.*sind(THETA2));
%plotting graph
plot([x0,x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
axis([0 3 0 3]);
pause(0.03)
%creating movie
M(ct)= getframe(gcf);
ct=ct+1;
end
end
movie(M);
videofile=VideoWriter('forwardkinematics.avi','Uncompressed AVI');
open(videofile);
writeVideo(videofile,M);
close(videofile);
OUTPUT
We get the animation of 2R Robotic arm and the link to view the animation
REPORT
2R Robotic arm consists of three links and two revolute joints. It is used in various industries for various applications due to the revolute joint were the end link is provided with end effectors. These effectors play vital role in handling various operations. Here we write the code for what range of region will it use depending on its length.
In order to create the animation we need to provide the set of inputs which should be executed one after other so that smooth animation is created. Here are the set of inputs we provide.
L1= length of arm or link connected to fixed link(blue)
L2= length of arm to connected to above link(red)
theta1= angle made by L1 with horizontal
theta2 =angle made by L2 with horizontal
- We use ‘for’ loop in the code, where for each input (angle) for 1st link set of angles of link two is provided.
- Hence, for each rotation of link 1 set of rotation of link 2 takes place and this continues further for another angle of link 1 and so on for the range of values of angle given
- By geometry we will find the values of coordinate of both the links.
- We will plot the graph by providing the input parameters and also mentioning the rang of numbers should be present in x any y axis
- Finally we collect all the plotted figures using ‘get frame’ function where it collects all the figures that are plotted for different angles of movable links.
- Now we create the movie which contains the animation for the range of angles provided.
Error occured during coding
Not closing the brackets after defining the function leads to compilation error
hence, code should be written in such a way the computer understands it
CONCLUSION
From the simulation obtained we can view how the Robotic arm moves in the workspace provided.