Week 3.2 - 2R Robotic Arm Challenge
%kinematics of 2R robotic arm using Octave
clear all
close all
clc
%input link length
R=1;
theta1 = linspace(0,90,50); %angle between link1 and base
theta2 = linspace(0,90,50); %angle between link 2 and link 1
for i=1:length(theta1)
THETA1 = theta1(i);
for j =1: length(theta2)
THETA2 = theta2(j);
x0 = 0;
y0 = 0;
x1 = R*cosd(THETA2);
y1 = R*sind(THETA2);
x2 = x1 + R*cosd(THETA1);
y2 = y1 + R*sind(THETA2);
%Plotting
plot([x0 x1], [y0 y1], [x1 x2], [y1 y2],'linewidth', 3)
axis ([-2 2 0 2])
pause (0.03)
end
end