Week 3.2 - 2R Robotic Arm Challenge
Aim:
To simulate the forward kinematics of the 2D robotic arm using MATLAB code.
Objectves:
Understand and visualize the relationship between the joint angles and the end effector.
Matlab code is given below for the simulation of 2D robotic arm.
clear all
close all
clc
%forward kinematics of a 2R robotic arm manipulator
%inputs
l1=1; %length of the first arm
l2=0.5; %length of the second arm
theta1=linspace(0,90,10); %angle for first arm using linspace command
theta2=linspace(0,90,10); %angle for second arm using linspace command
ct=1; % counter frame
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
x0=0; % coordinate points of the arms
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',3);
axis([-0.1 2 0 2.5])
pause(0.3)
M(ct)=getframe(gcf); %getting current frame
ct=ct+1;
end
end
movie(M)
videofile=VideoWriter('robotic_arm.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Videolink:
The simulation was uploaded in the youtube and the link is given here,
Conclusion:
Overall, simulating the forward kinematics of a 2D robotic arm has proven to be an invaluable tool for robotics research and development, enabling us to analyze, optimize, and control the arm's motion with greater precision and efficiency.