Week 2- 2R Robotic Arm Challenge
% Robotic arm simulation using MATLAB
clear all
close all
clc
%Inputs
l1=1;
l2=0.5;
theta1= linspace(0,90,10); %robotic arm 1 angle variation.
theta2= linspace(0,90,10); %robotic arm 2 angle variation.
ct=1
for i= 1:length(theta1)
for j= 1:length(theta2)
% Defining origin of the first arm of the robot.
x0 = 0;
y0 = 0;
x1 = l1*cosd(theta1(i));
y1 = l1*sind(theta1(i));
% Defining the position for the second arm of the robot
% x1 = l1*cosd(theta1) y1 = l1*sind(theta1) will be the origin point for
% the second robotic arm.
x2 = x1+l2*cosd(theta2(j));
y2 = y1+l2*sind(theta2(j));
figure(1)
plot([x0 x1],[y0 y1],"Color",'r','linewidth',5)
hold on
plot([x1 x2],[y1 y2],"Color",'b','linewidth',5)
hold off
grid on
axis([0 2 0 2])
legend('primary arm','secondary arm')
M(ct)= getframe(gcf);
ct = ct+1
end
end
% Movie capture simulation of robotic arm.
movie(M)
videofile= VideoWriter("Kinematics_of_robotic_arm_plain")
open(videofile)
writeVideo(videofile,M)
close(videofile)
Following is google drive link to acess video of the robotic arm movement.
https://drive.google.com/file/d/1UuQhEtgVpxSdmM9lI_AD8UjLAMNsfMk8/view?usp=sharing