Challenge

Week 2- 2R Robotic Arm Challenge

Theory

  • A robotic arm is a type of mechanical arm,usually programmable having similar fumctions as that of a human arm,the arm is sum total of the mechanism or may be a part of complex robot.
  • The links of a manipulator are connected by joints allowing either rotational motion or translational displacement.
  • The links of the manupulator can be considered to form a kinematic chain. The terminus of the kinematic chain of the manipulator is called the end effector and it is analogous to the human hand.
  • Forward kinematics refers to the use of kinematics equations of a robot to compute the position of the end effector from specified values for the joint parameters.
  • Robotic arms are used in various industrial applications such as welding,metal cuting,drilling etc.

Program:

Program used here is Matlab

% A program in Matlab to simulate the forward kinematics of a 2R Robotic Arm

clear all

close all

clc

% Taking inputs

% Length of the link 1(l1) & link 2(l2) in meters.

l1=1;

l2=0.5;

% Angle traced by link 1 in degrees (theta_1)

theta_1=linspace(0,90,20);

% Angle traced by link 2 in degrees (theta_2)

theta_2=linspace(0,90,20);

% Initialising the base coordinates of link-1

x_0=0;

y_0=0;

ct=1;

for i=1:length(theta_1)

THETA_1=theta_1(i) % taking particular values of angle traced by link-1 in order.

for j=1:length(theta_2)

THETA_2=theta_2(j) % taking particular values of angle traced by link-2 in order.

% Calculating the coordinates of end point of link-1

x_1=x_0+l1*cosd(THETA_1);

y_1=y_0+l1*sind(THETA_1);

% Calculating the coordinates of end ponts of link-2

x_2=x_1+l2*cosd(THETA_2);

y_2=y_1+l2*sind(THETA_2);

% Plotting the robotic arm for simulation

plot([x_0 x_1],[y_0 y_1],[x_1 x_2],[y_1 y_2],"linewidth",3);

axis([-0.1 1.5 0 1.5]);

% Pausing the current plot for a while before moving to the next plot

pause(0.03);

% Capturing the current plot to combine later

M(ct)=getframe(gcf);

% Incrementing ct so that each frame is captured in M

ct=ct+1;

end

end

% Making move from the collected frames

movie(M);

% Creating a video file of ".avi" format to save the animation

videofile=videoWriter('forward_kinematics_of_2R_robotic_arm.avi','Uncompressed AVI');

open(videofile);

% Writing the movie in the videofile created

writeVideo(videofile, M);

close(videofile);

Explanation of the Program

1. Lengths of both the links are taken as input. Length of link-1 (L1) is taken as 1m and length of link-2 (12) is taken as 0.5m.

2. Angles traced by both the links, for link-1 and for link-2 is taken as input. The angles traced are varied over a range to simulate the movement of the robotic arm.

3. Base position of link-1 (zo, y) is considered as origin (0,0).

4. Then two for loops are used to iterate over the range of angles traced by both the links. For each particular angle of link-1, link-2 is moved over its entire range, to obtain different positions of end effector at that angle of link-1.

5. For a particular value of e, and e,, the end position of link-1 is calculated by these equations.

x1=x0+l1.cosd(THETA1)

y1=y1+l1.sind(THETA1)

The end position of link-1 is also the start position of link two. The end position for link-2 is calculated by these equations

x2=x1+l2.cosd(THETA2)

y2=y1+l2.sind(THETA2)

6. Then for each particular position of lin-1 and link, a plot is made which is then captured frame by frame to make a movie.

7.A video file of '.avi' format is made to save the movie.

8. The movie is then written in to the video and final animation is created.

Output

The output is obtained in the form of a video clip. The video is viewed by visiting the link given below:

https://youtu.be/26oFZ8N6fDE

Conclusion

A forward kinematics of a 2R Robotic Arm in 2D workspace by using Matlab Program

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.