Week 2- 2R Robotic Arm Challenge
Aim:Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm, as shown in the video
Objective:
- writing the code for farward kinamatics of 2R arm
- Upload an animation on You tube and provide the You tube link for an animation in your report
Inputs: (xo,yo) = this is the initial coordinates
(x1,y1) =middle coordinate
(x2,x2) =last coordinate
L1 = length of the 1st arm
L2 = lenght of the 2nd arm
theta1 = angle at 1st link
theta2 = angle at 2nd link
code for the farward kinamatic arm is follws below
% program to stimutlate the 2r robertic arm in matlab
close all
clear all
clc
% difining inputs
l1 = 1; % this is lenght of 1st arm
l2 = 0.5; % this the lengt 2nd arm
theta1 = linspace(0,90,10); % here i am defining the range for theta1
theta2 = linspace(0,90,10); % here i am defining the thetha2
% now we are defining for loop for creating the animation of robertic arm
ct = 1; % hera i am taking comand called ct which is used to plot our figure
for i =1:length(theta1)
THETA1 = theta1(i);
for j = 1:length(theta2)
THETA2 = theta2(j);
% defining the inital axis
x0 = 0;
y0 = 0;
% hera we have taken intial axis (0,0) becouse at intial our axis are zero
% defining 2nd axis
x1 = l1*cosd(THETA1);
y1 = l2*sind(THETA1);
% here we are taking wnd axis at link 2 of the robertic arm
% defining 3rd axis(manuplater)
x2 = x1+l1*cosd(THETA2);
y2 = x2+l2*sind(THETA2);
% ploting the figure using above data
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',4); % i am taking linwidth comnd to define my line width
axis([-1 2 0 1]); % i am taking my axis range
pause(0.03); % pause comand is used foe controling the time of the figure
M(ct) = getframe(gcf);% hera i am storeing my all the frame which i have got in figure in array called 'm'
ct = ct+1;
end
end
movie(M)
videofile = VideoWriter('animation of robertic arm.Avi ','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
animation of video is given below link:https://youtu.be/qKbWtSx99dU
error:I dint get any complecated error