Week 2- 2R Robotic Arm Challenge
Aim :
- Create an animation file of the plot.
- Uploading an animation on You tube and provide the You tube link for an animation in your report.
- We can also provide the google drive link.Note: Make sure that you provide the access to the video, while pasting the google drive link.
Governing Equations:
- Formula Used to calculate the Cordinates is
`x1 = l1*cosd(THETA 1)`
`y1 = l1*sind(THETA1);`
`x2 = x1 + l2*cosd(THETA2);`
`y2 = y1 + l2*sind(THETA2);`
- Terms Used are:
- l1= length of arm 1
- l2= length of arm 2
- Theta 1 = Angle of arm 1 with respect to base
- Theta 2 = Angle of arm 2 with respect to arm 1
Objective :
- Uploading an animation on You tube and provide the You tube link for an animation in your report.
- We can also provide the google drive link.Note: Make sure that you provide the access to the video, while pasting the google drive link.
Body OF Content :
Basic Matlab programming language is used for coding
clear all
close all
clc
% Forward Kinematics of a 2R robotic arm manipulator
% Inputs
l1 = 0.75;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
ct=1
for i = 1:length(theta1);
THETA1 = theta1(i);
for j = 1:length(theta2);
THETA2 = theta2(j);
x0 = 0;
y0 = 0;
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);
%Plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.003)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile);
writeVideo(videofile,M);
close(videofile)
line 1- Clear all command clears all the variables which were already present in the command window
line 2 - Close all closes all the workspace variables and the commands
line 3 - clc closes all the plots and windows opened while performing the Run command
line 4 - Indicating the comment as a heading to animate the Forward Kinematics of a 2R robotic arm manipulator
line 5 - Mentions the comment of the inputs to to be added
line 6 - Length of l1 given as 0.75
line 7 -Length of l1 given as 0.5
line 8 - Value of Theta1 is mentioned
line 9 - Value of Theta2 is mentioned
line 10- Value of ct mentioned as 1
line 11 - Creating a for loop for i, where i= 1:length(theta1)
line 12 - Value of THETA1 is figured out from THETA1 = theta1(i)
line 13 - Creating a for loop for j, where j= 1:length(theta2)
line 14 - Value of THETA2 is figured out from THETA2 = theta2(j)
line 15 - Value of x0=0
line 16 - Value of y0=0
line 17 - Value of x1=l1*cosd(THETA1)
line 18 - Value of y1=l1*sind(THETA1)
line 19- Value of x2 =x1 + l2*cosd(THETA2)
line 20- Value of y2 = y1 + l2*sind(THETA2)
line 21- Mentions the comment of the plotting
line 22- Plotting of values x0,y0,x1,y1,x2,y2, Along with the width is given with the command using linewidth.
line 23 - Axis values are mentioned
line 24 - Pause command is used to vary the speed of the animation as per the need and proper visualization
line 25- M(ct) command is used to mention the individual frames, for that getframe command is used.
line 26 - It is the value of the frame to be in increasing order, thats why its given as ct = ct+1
line 27 - End of loop j
line 28 - End of loop i
line 29 - To create a movie a movie command is used
line 30 - Videofile where the file is saved by which name and what extention,Here the file is saved in the name of 'forward_kinematics' under the extention of '.AVI'
line 31 - Videofile is opened using command open(videofile)
line 32 - we write in the file using command writeVideo(videofile,M).
line 33 - videofile should be closed using the command close(videofile)
Results :
ct = 1
Below is the Video created for the animation Uploaded on youtube.