Challenge

Week 2- 2R Robotic Arm Challenge

Forward kinematics of a 2R Robotic Arm

to solve forward kinematics of 2R robotic arm
assume figure consist of Two links length


θ1 & θ2 are given
θ1=45 degree
θ2=90 degree

link 1= l1= 1
link 2= l2= 0.5

so will calculate position of manipulator
step1-calculate position of link 1
step2- calculate position of link 2
step3- plotting link position as on plot with respect to X&Y axis
step4- using counter & for command to get angular movement of link as per with respect to each other and get new variable THETA1&2.
step5- putting values of THETA in step1&2 as in link position to create plot of possible Robotic ARM movement
step6- To create animated plot with for and counter variables attached
step7- Created plot movie animated video avi file from current plot

[[step1]]
so from figure we took initial position of link
(x0 y0) =(0,0) its starting point initial position its as per x and y axis

x1= l1cosθ1
y1= l1sinθ1
&


x2= x1+l2cosθ2
y2= y1+l2sinθ2
solution set
[x0,y0][x1,y1],[x2,y2]

(in editor window)--------(steps taken to remove problem existing incommand window)

% forward kinematics of 2R Robotic arm Manipulator
first will inputs commanRd
clear all
close all------------------(to clear and close existing window)
clc

% Inputs-- (taken from above figure )
l1=1;
l2=0.5;----------(SEMICOLON MISSED SOMETIMES DURING CODING,,,semicolon used to separate dimensinon or create new row or column)steps for error

theta1=45-----(as per figurewe took values)
theta=90-------//------

% coordinates
x0=0;-----(its starting point of robotic arm)
y0=0;

[[step2]]
x1= l1*cosd(theta1);--------( USING SIN(theta) OR COS(theta) IS WRONG BEACUSE,,, cosd & sind is taken for purpose its not in radians)steps for error
y1= l1*sind(theta1);
&
x2= x1+l2*cosd(theta2);----(x2 and y2 position will be calculate by this summation from axis)
y2= y1+l2*sind(theta2);

[[step3]]
%Plotting
line([x0 x1],[y0 y1],'linewidth',3,'color','b')-----(there is plotting from given above inputs)steps for error
line([x1 x2],[y1 y2],'linewidth',3,'color','b')

so we got positions of all link in X&Y axis so we now to animate plot and creat new file in edior window

(in editor window)

clear all
close all
clc

%Inputs
theta1 = linspace(0,90,10)------(for Animate plot we will varry angles of link from base to end position angular movement)steps for error
theta2 = linspace(0,90,10)------(this will vary angle from with total 10 quantities)

[[step4]]
ct=1;---------(counter are added for loop )steps for error
For i= 1:length(theta1)----------(making this i= contain 10values)(0 10 20 30...)
theta2(i)

for
i= 1: length (theta1)
THETA1 = theta1(i);--------(it will varry position of link1 with respect to link2 so that link from initial to final position both respectively as THETA1 of i)

for j= 1:length(theta2)
THETA2 = theta2(j);-------(it will varry position of link2 with respect to link1 so that link from initial to final position both respectively as THETA2 of j)
end

now we will copy all program from earlier and will putting values of new THETA1 and THETA2 in code for link animated plot

[[step5]]
x0=0;-----(its starting point of robotic arm)
y0=0;

x1= l1*cosd(THETA1);--------(cosd & sind is taken for purpose its not in radians, THETA1 well be new angular movement)
y1= l1*sind(THETA1);
&
x2= x1+l2*cosd(THETA2);----(x2 and y2 position will be calculate by this summation from axis, THETA2 will be angular movement )
y2= y1+l2*sind(THETA2)


[[step6]]
%Plotting

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)-----(plotting of link with axis for animated plot)steps for error
axis([-0.1 1.5 0 1.5])-----( axis took as per pattern(X0 X1 Y0 Y1)
pause(0.03)--------(pause of 0.03 added)
M(ct) = getframe(gcf);------(for animated plot M with counterwith current fig)
ct = ct+1;------(counter added)

end
end

[[step7]]

movie(M)--------------------( for creat animated plot vith video file movie)steps for error
videofile = VideoWriter('Forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)-----(write video file as per plot created)steps for error
close(videofile)-------(close video file)

Youtube link for Animation Video is following

https://youtu.be/_lKiBHru6BQ

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

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.03)
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)
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.