Week 2- 2R Robotic Arm Challenge
Program script to make a animation vedio of fordward kinamatic of a 2R robotic arm
We need to analyse the movements of robotic arm and endpoints when rotation angle changes.
Program:
% fordward kinamatic simulations of a 2R robotic arm
% inputs length of the robotic links
l1 = 2; % length of link 1
l2 = 2.5; % length of link 2
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
ct = 1;
for i = 1:length(theta1)
A = theta1(i);
for j = 1:length(theta2)
B = theta2(j);
x0 = 0;
y0 = 0;
x1 = l1*cosd(A);
y1 = l1*sind(A);
x2 = x1+l2*cosd(B);
y2 = y1+l2*sind(B);
% plotting and making a simulation vedio
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2])
axis ([-3 5 0 5]);
pause(0.03);
m(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(m)
vediofile = VedioWriter('Fordward_kinamatics','simulation_AVI')
open(vediofile)
writerVedio(vediofile,m)
close(vediofile)
Script comments:
First we to take the inputs values like:
Length of robotic links
l1 and L2
robotic links angles
Theta1 and Theta2
we need to generate given set of range values by using linspace command.
By using for loop command we can generate the number of counters.
Inside the for loop we need to give the link end points co-ordinates
Plotting the figures with some delay using pause(sec)
Movie making we need to get the set of frames by using getframe command
Give a movie file name and exicute the movie.