Challenge

Week 2- 2R Robotic Arm Challenge

%Forward Kinaematics of 2R robatic arm kinematics
close all
clear all
clc

% Inputs
theta1 = linspace(0,180,15);
theta2 = linspace(0,160,15);

l1 = .75
l2 = .75

% Excuting for loop 
a=1;
for i = 1:length(theta1)
    degree1 = theta1(i);
    for j = 1:length(theta2)
        degree2 = theta2(j);

        x0 = 0;
        y0 = 0;

        x1 = l1*cosd(degree1);
        y1 = l1*sind(degree1);

        x2 = x1+l2*cosd(degree2);
        y2 = y1+l2*sind(degree2);
% Plotting
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],LineWidth=5)
        axis([-2,2,-0.1,2])
        pause(0.08)

        M(a)= getframe(gcf);
        a=a+1;

    end
end
%creating the animatin
movie (M)
videofile = VideoWriter('forwardarmkinematics.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)

Determing the Inputs l1,l2,theta1,theta2

Calcualting the position of the link with respective to the l and theta

for repeating the same for link1 and link 2 we have used for loop with the i,j

plot command is used to plot the graph

with the pause the ploting

movie command is used to animate the ploting Video is attached as a drive file : Matlab program for 2d robotic arm kinematics challenge

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.