2R Robotic Arm Challenge
Aim: To Simulate the Forward Kinematics of a 2R Robotic arm
Software used: Octave
Theory
Kinematics deals with the study of motion, without any reference to the forces that cause the motion.
Forward Kinematics is used to determine the required position and orientation from a given set of joint angles.
The robotic arm is used for multiple industrial applications, from welding, material handling and thermal spraying, to painting and drilling. The robotic technology also provides human like dexterity in a variety of environment.
The robotic arm is made up of a finite number of individual rigid segments. Each rigid segment is called as link and links are connected to each other by joints. Link move with respect to its joints.
In a 2-joint robotic arm, given the angles of the joints, the kinematic equations give the location of the tip of the arm.
L1 and L2 are length of the links
θ1 is the angle made by link 1 with X-axis
θ2 is the angle made by link 2 with X-axis
(X0, Y0) →Starting point of link 1
(X1, Y1) →End point of link 1 and Starting point of link 2
(X2, Y2) → End point of link 2
where,
X0=0 ; Y0=0
X1=L1 cos(θ1)
Y1= L1 sin(θ1)
X2=X1+L2 cos(θ2)
Y2=Y1+L2 sin(θ2)
Code
clear all
close all
clc
% Forward kinematics of 2R robotic arm
%Inputs
L1=2;
L2=1;
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);
%co-ordinates
X0=0;
Y0=0;
X1=L1*cosd(THETA1);
Y1=L1*sind(THETA1);
X2=X1+L2*cosd(THETA2);
Y2=Y1+L2*sind(THETA2);
%plotting
figure(ct)
plot([X0,X1],[Y0,Y1],[X1,X2],[Y1,Y2],'linewidth',3)
pause(0.03)
axis([-0.1 3 0 3])
ct=ct+1;
file_text=sprintf("forward_kinematics%d.png",ct);
saveas(gca,file_text);
endfor
endfor
Explanation of code
- Starting the program with clear all, close all and clc
- Defining the length of both links L1 and L2
- theta1 and theta 2 array is generated using linspace command which generates array starting from zero to 90 degrees with 10 steps in between
- The counter is initialized using ‘ct ’ command
- A for loop is used to write it for specific number of times
- Defining co-ordinates for starting point of link 1
- Calculating the co-ordinates for link 1 and link 2 using the equations
- Plot is obtained by plotting all the co-ordinate values
- “saveas” and “sprintf” commands are used to save the plots for every iteration and ‘’imageMagik” is used to stitch the plots together and create animation
Errors in programming: No errors were obtained.
You tube link for an animation
Conclusion:
Program to simulate the forward kinematics of a 2R Robotic Arm was written and the animation was created .