Forward kinematics of a 2R robotic arm
- FORWARD KINEMATICS OF A 2R ROBOTIC ARM USING MATLAB PROGRAM
%inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
x1 = 0;
y1 = 0;
ct = 1;
for i=length(theta1)
theta2(i)
end
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.1 1.5 0 1.5])
pause(0.03)
M(ct)= getframe(gcf);
ct=ct+1;
end
end
movie=(M);
Videofile = VideoWriter('forward_kinematics avi','uncompressed AVI');
open(Videofile)
writeVideo(Videofile,M)
close(Videofile)
- STEPWISE EXPLANATION OF CODE
- Assign the values for the link1 and the link2
- Then provide theta values for various positions of the motion of robotic arm
- Provide the necessary starting points for the coordinates and also for the link1 and link2 respectively
- Create a new file and provide the necessary boundary conditions
- Now open the for loop and apply all the theta values provided for the link1 and link2
- Now copy and paste the necessary values as you already programmed in a separate file
- After that,plot the various values from starting point of the link initial condition to link2 final conditions
- Now close the loop conditions to stop the further execution of the running program
- Now create an animation file with some file extensions and save the video file with avi folder
Thus the necessary steps for the application of code is shown in this section.
ERRORS FACED WHILE PROGRAMMING
- While opening loop conditions ,im constantly getting error saying ATLEAST ONE END IS MISSING,the loop couldnt able to recognize the end point so it continuously printing the same condition in the command window.
2.Then the next error comes on its way that UNDEFINED FUNCTION OR VARIABLE 'CT',the program couldnot able to find the variable which is not assigned and the function itself not called inside the program.
STEPS TAKEN TO OVERCOME THE ERROR
1.Inorder to overcome the error one have to identify the root cause of the program,by seeing this i have identified my error that the loop condition is closed before the function in which i have assigned.Then after extending the required loop to the end of the structure of the program the program executed smoothly.
2.Then for the second produced random error i find that i didnt called a variable in the body but assigned it in the structure of the program.After finding this i called the variable 'ct' in the body the program and run the program,the program executed successfully.
SCREENSHOTS OF THE ERRORS
IMAGE SHOWING THE ERROR PRODUCED BY THE FOR LOOP COMMAND
IMAGE SHOWING ERROR PRODUCED WHILE ASSIGNING THE UNKNOWN VARIABLE
SCREENSHOT OF OUTPUT
AIM
To determine the forward kinematics of a 2R robotic arm manipulator using simple matlab program.
FORWARD KINEMATICS
It 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.
LINK OF THE ANIMATION OF 2R ROBOTIC ARM
ROBOTIC ARM FUNCTION
A typical robotic arm is made up of several metal segments joined by various links and joints.The computer controls the robot by individual step motors connected to each joint.It is also called as MANIPULATOR.
USES OF ROBOTIC ARM IN INDUSTRIES
They have been used in industrial applications like welding,thermal spraying,painting and drilling.
SCHEMATIC DIAGRAM SHOWING THE ROBOTIC WITH TWO LINKS
SIMPLE NUMERICAL FORMULA FOR ROBOTIC ARM WITH TWO LINKS
FOR LINK1
X1=L1*COSD(THETA1)
Y1=L1*SIND(THETA1)
FOR LINK2
X2=X1+L2*COSD(THETA2)
Y2=Y1+L2*SIND(THETA2)
NOTE
HERE D FUNCTION IS USED BECAUSE THESE EXPECTS THE VALUES IN DEGREES.
RESULT
Thus the program for the forward kinematics of a robotic arm is executed using simple matlab program