Week 2- 2R Robotic Arm Challenge
Aim
Using Matlab program to simulation the forward kinematics of a 2R Robotic Arm and animation of robotic arm.
% Simulation of forward kinematics of a 2R robotic arm
% input data
L1=1;
L2=0.6;
x0=0;
y0=0;
Theta1=linspace(0,90,10);
Theta2=linspace(0,90,10);
ct=1
% formula to calculate x1 and y1,
x1=L1*cosd(THETA1);
y1=L1*sind(THETA1);
% formula to calculate x2 and y2,
x2=L1+L2*cosd(THETA2);
y2=L1+L2*sind(THETA2);
therefore
L1=length of link1
L2=length of link2
x0,y0=starting points of link 1, fixed points(0,0)
x1,y1=ending point of link 1 and starting point of link 2
x2,y2=ending point of link 2
Theta1 and Theta2= angle of link one and link 2
% program for forward kinematics of a 2R robotic arm
clear all
close all
clc
% input data
L1=1;
L2=0.6;
x0=0;
y0=0;
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(i);
% formula to calculate x1 and y1,
x1=L1*cosd(THETA1);
y1=L1*sind(THETA1);
% formula to calculate x2 and y2,
x2=L1+L2*cosd(THETA2);
y2=L1+L2*sind(THETA2);
%plotting the graph
plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3);
axis([0 1.5 0 1.5])
pause(0.05)
M(ct)=getframe(gcf);
ct=ct+1;
end
end
%creating a movie clip of animation
movie(M)
videofile = VideoWriter('forward_kinematics_2d','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile),
Procedure,
Firstly i have created the inputs and acoorcding to inputs i have started the basic program without plotting during that time i got to know there is no errors in commonds and inputs.
Then, while plotting the graph i have found a error in for loop, i have use only one end commond, during that time the error is attached in screenshot as below.

then by doing corretion i got the graph and output-
Finally the creation of movie clip, i got to face lot of errors of commonds i have used wrong cases of letter for example
videofile = Videowriter('forward_kinematics_2d','uncompressed AVI'); i have used this commond instead of videofile = VideoWriter('forward_kinematics_2d','uncompressed AVI');
the error is showed invalid recognisation. At last the program as done by using above commonds.
The video clip is attached in the link
https://drive.google.com/drive/folders/1Lc1X4u7WHVtsd8XwVeT3JyqSNqA8Akh4?usp=sharing