Project

2R Robotic Arm Challenge

OBJECTIVE:

Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm.

THEORY:

In the manufacturing world, one of the most common robots used is robotic arm. It can be used for several applications such as welding,material handling and material removal etc. Due to this robotic arms it cut down on worker error and decrases the labor costs. The arm is the main section of the robotic arm and consists of three parts: the shoulder, elbow and wrist. These are all joints, with the shoulder resting at the base of the arm, typically connected to the controller, and it can move forward, backward or spin.

INPUTS:

  • Length

L1=3

L2=2.5

  • Equation to solve X and Y value

(x0,y0):

Here starting point of the limb1 is fixed to the base. So that the strting point of the limb1 cannot move it is in fixed position so the value of 'x' and 'y' will be '0'.

x0=0
y0=0

(x1,y1):

It is the ending point of the limb1 and also the starting point of the limb2. It is represented by an angle 'theta1' and length 'L1'. The equation x and y will be

x1=L1*cosd(theta1)
y1=L1*sind(theta1)

(x2,y2):

It is the ending point of limb2.It is represented by an angle 'theta2' and length 'L2'. The equation x and y will be

x2=x1+L2*cosd(theta2)
y2=y1+L2*sind(theta2)

CODE EXPLANATION:

  1. Matlab is better to start with clear all, close all, clc command

CLEAR ALL: The statement is used to clear all the data that have stored in the workspace.

CLOSE ALL: The statement is used delete all figures and close the plots.

CLC : The statement clear the command window.

2. Enter the input value and determine the value for theta with a command linspace in this we create a degree from 0 to 180 with 8 values between the degree we have created.

3. Then initialize the counter command using ct.

4. To rotate the robotic arm continuously we are using for loop. First we are intiating the loop and according to our condition the value are to be 0 through 180, the variable “i” is initiated.

5. Then enter the equation x and y which has been explained above in formulas.

6. Then plot the values of x0,x1,x2 and y0,y1,y2 with the linewidth of 3.

7. Then use the axis command to determine the length of x-axis and y-axis to show the output clearly.

8. Then use pause command to slow down the output.

9. Then we use frame command to get individual frame .

10. Then increment the counter value by 1.

11. The end command is used to end the loop statement this terminates the set of instruction and takes the the program again to execute.

12. using movie command we can create a movie with the help of individual frame.

13. Using the different individual frame a new avi file is created using videofile command.

14. Then we are poening the videofile using the open command and closing the videofile using the close command.

CODE:

clear all
close all
clc

%length of the limb
L1 = 3;
L2 = 2.5;

%determining the value of theta
theta1 = linspace(0,180,8);
theta2 = linspace(0,180,8);

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([-6 6 0 6])
pause(0.3)
M(ct)=getframe(gcf);
ct=ct+1;
    end
end    

movie(M)
videofile=VideoWriter('forward_kinematics_1.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

ERROR:

The error that i have faced during the program is i have increased by length of the limb and decreased the length of x-axis and y-axis. Then i have decreased the length of the limb

RESULT:

Thus, we have executed the program for forward kinematics of a 2R Robotic Arm simulation using the matlab software.

https://drive.google.com/open?id=1ucRiJvIUCl9revq_12FiGDqdYVzGkCGk

https://drive.google.com/open?id=1L0aLZdB8AKEVKq650iVuEBIq5S9On85Z

https://youtu.be/ddKrsfWaSlM

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.