Project

2R Robotic Arm Challenge

In this project-forward kinematics of a 2R robotic arm we determine the workspace of a robotic arm with two links . The two links can have different constraints and lengths. In the code first we give the input parameters like length of arms [L1,L2],and the angle with which the arms can be rotated[theta1,theta2].

Next we create loops which run \'i\' and \'j\' times, where \'i\'=length or number of theta 1 values \'j\'=length or number of theta 2 values each time the for loop runs THETA1 takes the value of theta1 and THETA2 takes value of theta2 .

Inside the loop ,the arm1\'s one end is fixed at the origin with coordinates[ie,x0=0 &y0=0] other ends coordinates[final] are calculated from the THETA1 values previously obtained. Similarly for arm2 initial coordinates are the final coordinates of arm1 other ends coordinates are calculated from the THETA2 values . Plot is made using the coordinate values .Since the for loop of \'j\' is inside of for loop of \'i\' ,for one value of THETA1 all the THETA2 values are calculated and are plotted in figure one by one. Animation file is created by using getframe command when each plot is created.

%Forward kinematics of a 2R robotic arm
clear all
close all
clc
%length of the links
l1 =1; %link 1
l2 =0.5; %link 2
theta1 = linspace(0,90,10); %angle of link 1
theta2 = linspace(0,90,10); %angle of link 2
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);
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],\'linewidth\',3);
axis([-.1 1.5 0 1.5])
pause(0.18)
M(ct)= getframe(gcf);
ct=ct+1;
 end
end

%creating a video file
movie(M)
videofile= VideoWriter(\'forkin.avi\',\'Uncompressed AVI\');
open(videofile)
writeVideo(videofile,M)
close(videofile)

For a given angle of link 1 corresponding change in angles of link 2 is shown in the animation video . Hence the entire workspace of the robotic arm can be seen and evaluated in the video.

link for animation video: https://youtu.be/xwVGSzk9p4E

screenshots of the output

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.