Week 2- 2R Robotic Arm Challenge
Report for the 2-D arm manipulator challenge
clear all= remove items from workspace free the system memory
close all= close running figures
clc= clears the command window
%Forward kinematics of a 2R Robotic Arm Manipulator
clear all
close all
clc
%Inputs
l1=1
l2=0.5
l1 shows the length of link 1
l2 shows the length of link 2
theta1 and theta2 are variables and shows the angles of the respective link
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
linspace command is used to generete linearly spaced vectors i.e the angles of the links in this case
ct=1;
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
x0=0;
y0=0;
for loop is used to repeat specified number of times and the loop is ended by the end command at the loop end where the loop has to end
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)
plot command is used to plot the desired graph output according to inputs
axis([-0.1 1.5 0 1.5])
pause(0.1)
M(ct)=getframe(gcf);
ct=ct+1;
axis command sets the axis limits of the plot
pause is used to stop the execution of the program temprorarily
getframe captures axes of the figures as moving frame
end
end;
movie(M)
videofile=VideoWriter('forward_kinematics.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
movie play the recorded movie frame
videowrite is used to create objects to write in a video file
writevideo write the desired frames in a moving video
There were some error which i faced during the execution of the program link the following
theta1=linspace(0.90.10);
%Forward kinematics of a 2R Robotic Arm Manipulator
clear all
close all
clc
%Inputs
l1=1
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_graph
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.1)
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)
there i used a dot as a seperator in theta1 input so it was showing an error
So i connect to one of the support enginner with the help of 1 to 1 session on got the help
Here is the Google drive link below for the kinematics of the video
https://drive.google.com/file/d/1kRI0zf8OaUMJHGV-NLJMYA3jKJUWz1_m/view?usp=sharing