https://youtu.be/Z5dCiGoWSXw
% Kinematics of 2R Robotic arm
clear all
close all
clc
%Inputs
l1 = 2;
l2 = 1;
theta1 = linspace(0,90,20);
theta2 = linspace(0,90,30);
% coordinates
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);
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'LineWidth',4)
axis([-0.1 3 0 3])
pause(0.02)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
% conversion of plot into movie
movie(M)
videofile = VideoWriter('Movement_Robotic_arm.m','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
1.Above code is for showing Movementof Robotic Arm
2.L1 and L2 are lenghts of robotic arms
3.theta 1 and theta 2 are moving angles for arms
4.movement of arms are plotted
5.plots are converted into movie using given code
6.movie file display movement of both arms
7.Moving one code in other is complicated
8.movie link is provided