Week 2- 2R Robotic Arm Challenge
Here I have written a program of 3 Robotic arm to show the animation .
Explanation:
- First I have taken arm lengths and their angle as input.
- Then I used 3 forloops for 3 arms and wrote the Mathematicl logic for all the 3 arms inside the loop.
- Then I wrote the code inside the loop to plot the arms and to show the animation.
- Then I have done the movie of that animation by adding some codes at the end.
Here I have attached the MATLAB code for the above problem and also attached the google drive link of the movie.
% Forward Kinematics of a 3R robotic arm manipulation
clear
close all
clc
% Inputs
l1=1;
l2=0.5;
l3=0.4;
theta1=linspace(0,360,10);
theta2=linspace(0,360,10);
theta3=linspace(0,360,5);
%taking a counter value for each frame
ct=1;
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
for k=1:length(theta3)
THETA3=theta3(k);
x0=0;
y0=0;
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
x3=x2+l3*cosd(THETA3);
y3=y2+l3*sind(THETA3);
%Plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],[x2 x3],[y2 y3],'linewidth',3)
axis([-2 2 -2 2])
pause(0.0005)
M(ct)=getframe;
ct=ct+1;
end
end
end
%Creating Movie
movie(M)
%Create a video file
videofile=VideoWriter('Forward_kinematics.avi','Uncompressed AVI');
% To open the videofile
open(videofile)
% To write the movie frame on videofile
writeVideo(videofile,M)
close(videofile)
Google Drive link
https://drive.google.com/file/d/1aoJ7Gm2fjRdcgRexuYeMNjsCGlw5MrIW/view?usp=sharing