Forward Kinematics of a Robotic arm
AIM OF THE PROJECT:
The aim of the project is to simulate the forward kinematics of a 2R Robotic Arm.
WHAT IS FORWARD KINMEATICS?
Forward kinematics refers to the use of the kinematic equations of a robot to compute the position of the end-effector from specified values for the joint parameters
DESCRIPTION:
By observing the above figure,
L1 and L2 are the lengths of two links and θ1 andθ2 are the angles associated with links.
θ1 is the angle between x-axis and link1
θ2 is the angle between x-axis and link2
We need to calculate the position of the link ends, for that we need to find out the coordinates
one end of the link1 is constrained(i.e., all DOF are fixed)
one end of link2 is connected with link1 and other end is connected to manipulator, the manipulator performs the operations given by the instructor.
By following the figure,
(x0,y0) = (0,0)
(x1,y1) = (L1cosθ1,L1sinθ1)
(x2,y2) = (x1+L2cosθ2,y1+L2sinθ2)
PROCEDURE:
Before proceeding, we have to know the basic inputs, so i considered
L1 and L2 are 2mm and 1mm
θ1 and θ2 values have to change in aascending order, so that for loop is used.
To draw the link, plot() command is used and axis is fixed.
To capture and store the frames getframe() command is used.
To animate and to save the video videowriter() command is used.
Below is the code i executed for to simulate the forward kinematics of a 2R Robotic Arm
% Program on forward kineatics of 2R Robotic arm
% Inputs
% Length os two links
l1 = 2;
l2 = 1;
% Angles
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.2 3.5 0 4])
pause(0.03)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
% Creating and save animation file
movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
OUTPUT:
The output for the above written code is
PROBLEMS FACED DURING THE EXECUTION OF CODE:
During the execution of the code i faced many minor mistakes, the major ones are:
- Error: File: challenge_2R_robotic_arm.m Line: 32 Column: 13
Invalid expression. When calling a function or indexing a variable, use
parentheses. Otherwise, check for mismatched delimiters. -
Unrecognized function or variable 'fcg'.
Error in challenge_2R_robotic_arm (line 35)
M(ct) = getframe(fcg); -
The closest match is: movie in C:\Program Files\MATLAB\R2020a\toolbox\matlab\specgraph\movie.p
Error in challenge_forward_kinematics_2R_robotic_arm (line 41)
Movie(M)
STEPS TAKEN TO OVERCOME THOSE ERRORS
- Checking the syntax and performing the operation again.
- watching the video to make sure there is no mistake.
- Following and checking the commands carefully i.e., upper case and lower case letters.