Challenge

Week 2- 2R Robotic Arm Challenge

%Program for Forward KInematic Robotic Arm

clear all
close all
clc

%Inputs

L1=1;
L2=0.5;

theta1=linspace(0,90,15) (explanation - varying theta values for first arm)
theta2=linspace(0,90,15) (explanation - varying theta values for second arm)
ct=1;

for i=1:length(theta1) (explanation - looping theta1 values for different values for first arm)
THETA1=theta1(i);


for j=1:length(theta2) (explanation - looping theta2 values for different values for second arm w.r.t to first arm)
THETA2=theta2(j);

%Calculating Joining Points of Arms


x0=0; (explanation - origin or rigid point )
y0=0;

x1=L1*cosd(THETA1); (explanation - defining components of line vector of first arm )
y1=L1*sind(THETA1);

x2=x1+L2*cosd(THETA2); (explanation - defining components of line vector of second arm )
y2=y1+L2*sind(THETA2);

%Figure

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-1 1 0 0.5]) (explanation - defining axia limits)
pause(0.03) (explanation - controlling the visualisation or performance of the curve)
M(ct)=getframe(gcf); (explanation - saving latest frame before incrementing counter)
ct=ct+1;


end

end

%Creating Movie

movie(M) (explanation - creating movie)
videofile = VideoWriter('Forward_Kinematic_Link.avi','uncompressed AVI'); (explanation - defining movie)
open(videofile) (explanation - open movie)
writeVideo(videofile,M) (explanation - write movie)
close(videofile) (explanation - close movie)

%Program for Forward KInematic Robotic Arm

clear all
close all
clc

%Inputs

L1=1; 
L2=0.5;

theta1=linspace(0,90,15) 
theta2=linspace(0,90,15) 
ct=1;

for  i=1:length(theta1)     
            THETA1=theta1(i);


      for j=1:length(theta2) 
                 THETA2=theta2(j);

%Calculating Joining Points of Arms


x0=0;  
y0=0;

x1=L1*cosd(THETA1); 
y1=L1*sind(THETA1);

x2=x1+L2*cosd(THETA2); 
y2=y1+L2*sind(THETA2);

%Figure

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-1 1 0 0.5]) 
pause(0.03)  
M(ct)=getframe(gcf);  
ct=ct+1;


end

end

%Creating Movie

movie(M) 
videofile = VideoWriter('Forward_Kinematic_Link.avi','uncompressed AVI'); 
open(videofile)  
writeVideo(videofile,M) 
close(videofile)  
 

 

 

 

 

 

 

 

 

 

 

 

https://drive.google.com/file/d/1O1YDO8X6Pit5a8oYeeXbj_h_xgOrI8yg/view?usp=sharing

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.