Week 2- 2R Robotic Arm Challenge
Theory:
Aim:
To Calculate the Forward Kinematic of 2R robotic arm.
Process:
let considered a Base having axis (0,0), l1 is the length of first arm having angle of deflection of theta1 and l2 is the length of the second arm having angle of theta2, Now let the co-ordiantes of the arm (x1 y1), (x2 y2).
Here Forward kinematic is used to calculate the position of end-effector of a specific value of the joint parameters.
Here we are calculating the value of x1, y1 and x2, y2. Taking those values in consideration and plotting the graph of robot arm movement and taking the rading at different position of joint parameter.
Application of 2R Robotic arm:
- Welding in automobile industry.
- Material handling.
- Assembly operations.
- Machine loading and unloading.
- Spray painting of automobile bodies.
Link: https://youtu.be/w8X5le57GXw
Problem:
% Animating 2R Robotic Arm
clear all
close all
clc
%Input
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
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',3);
axis([-0.5 1.5 0 1.5]);
pause(0.03)
M(ct) = getframe(gcf);
ct= ct+1;
end
end
%Video Conversion
movie(M)
videofile = VideoWriter('forward_Kinemetic.avi', 'Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Explanation:
by using the formula to calculate the forward kinematic of robotic arm x = l*cosd(theta) and x= l*sind(theta) in horizontal and vertical axis.
l1 and l2 is given .
Theta1 and theta2 is 1:10 row matrix between (0 to 90deg).
Using linspace command reduce the effort of getting 10 values between (0 to 90deg).
As shown in the problem section I have used for loop to generating the position at different joints so that the graph terminate at different points on the axis, the for loop takes a condition like i = 1:length(theta1) that means I'm assining the theta1 total length that means the linspace command gives me 10 values between 0 and 90deg and the forloop will take those 10 value as a length of the theta (which means the 'i' will repeate 10 time at different points from 0 to 90) which shows differnt graphical plots at different points and as well 'j' in theta2 such that the graph will showing 10 different position of joints of l1 and l2 from a fixed base (0,0).
Some Error:
During the first attempt I got few Error like shown in the images.
1: Fixing the axis without Brackets.
2: Difference between theta and THETA.
3: Forgoting Semicolon (;).