Challenge

Week 2- 2R Robotic Arm Challenge

% A program to simulate the forward kinematics of a 2R Robotic arm
clear all [ good start to use this cods at start]
close all
clc

% input value

l1 = 1 [length of first robotic arm]

l2 = 0.5 [length of secound robotic arm]

theta1 = linspace(0,90,20) [angle of 1st arm]
theta2 = linspace(0,90,20) [angle of 2ed arm]
ct = 1
for i =1:length(theta1) [ for loop is use to print 20 value of both 1st and 2ed robotic arm THETA1=theta1(i) position] for j =1:length(theta2)
THETA2=theta2(j)
% corrdinates
x0 =0 [ 1st arm starts from value (0,0) ]

y0 =0

x1 = l1*cosd(THETA1) [ 1st arm ends in x1 and 2ed arm starts from x1]
y1 = l1*sind(THETA1)

x2 = x1 + l2*cosd(THETA2) [ x2 and y2 tells that end point of robotic arm]
y2 = y1 + l2*sind(THETA2)

%plotting

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'LineWidth',3) [ both arm are plotted in same line since

i dont use 'hold on' command]

axis([-0.1 1.5 0 1.5]) [ -0.1 tells starting point of xaxis and 1.5 is end point of xaxis and 0 and 1.5 shows starting and ending of yaxis]


pause(0.03) [ to delay the each frame]
m(ct)= getframe(gcf)
ct=ct+1
end
end

movie(m)
videofile=VideoWriter("robortic_arm2.avi","Uncompressed AVI") [movie command used
open(videofile) for making animation]

writeVideo(videofile,m)
close(videofile)

Animation file of the plot

https://drive.google.com/file/d/16QO6QxkEaDAzWlzKBw2Rbo6L5gxWcpKB/view?usp=sharing

error i am seen in this program

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.