Challenge

Week 3.2 - 2R Robotic Arm Challenge

AIM-2R Robotic Arm Challenge .

Theory:-

Here x0,y0 is the incial value .

theta is the angle of first arm .

x1,y1 is the joint of two arm .

x2,y2 is the end point 2nd arm .

here `x1=l1*cos(theta1)`

`y1=l1*sin(theta1)`

`x2=x1+l2*cos(theta2)`

`y2=y1+l2*sin(theta2)`

CODE IN MATLAB:

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);
        %coordinats
x0=0;
y0=0;
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%ploting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-1 2 0 2])
pause(0.03)
M(ct)=getframe(gcf);
ct=ct+1;
    end
end
movie(M)
videofile=VideoWriter('Forword_kainametic.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

INNCORRECT CODE:

%kinametics of rubotic arms
clear all
close all
clc
%inputs
l1=1;
l2=0.5;
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
for i=1:length(theta1)
    THETA1=theta1(i);
    for j=1:length(theta2)
        THETA2=theta2(j);
%coordinats
x0=0;
y0=0;
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%ploting
line([x0 x1],[y0 y1],'linewidth',3,'color','b')
line([x1 x2],[y1 y2],'linewidth',3,'color','r')
axis([-1 2 0 2])
pause(0.03)
    end

OUTPUT OF INCORRECT CODE:

Here all the lines are ploted in one plot by every for loop ,so i replace the plot function by the line function ,then also i am not able to gate the proper plot ,so draw arm1 and arm2 in a one plot function .

Affter correction:

for corrected plot video 

https://www.youtube.com/watch?v=YqXIyuuFOrA

Code explanation :

lear all:It remove all the variables stored in the current workspace.

close all:It close all the fig window opened if any from previous execution .

clc: This clear all the text from the commond windows.

linspace(0,90,10):Is use to creat a array of angle theta1 and theta2 .
 
first 'for' is use for creat a loop for first arm and is use for creat a loop for first arm .
 
'plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)'Is creat a plot of arm1 and arm2 for one loop .
 
'axis([-1 2 0 2])' Is use for set the axis's the limits.
 
'pause(0.03)' Is use to pause the code .
 
'M(ct)=getframe(gcf)' It is use to capture the fig as a frame.
 
'gcf ' If refers to current fig handle in metlab .
 
'movie(m)' plays the movies freams in array .
 
'video  writer' this command will creat a video  file of spacifayed name .
 
'Open' Open the specifyed file .
 
'close' Write the creat specifed file .
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.