Challenge

Week 2- 2R Robotic Arm Challenge


Question- To write the program in matlab tosimulate the forward kinematics of a 2R Robotic Arm.

objective:-
1- To write a program in matlab to simulate the forward kinematics of a 2R Robotic Arm.
2- To create a Movie of the animation of the plots obtained from the program

Literature:-
A robotic arm is a type of mechanical arm, usually programmable, with similar functions to a human arm; the arm may be the sum total of the mechanism or may be the sum total of the mechanism or may be part of a more complex robot.The links such a manipulator are connected by joints allowing either rotational motion (such as in an articulated robot)or translation(linear) displacment.The links of the manipulator can be considered to form a kinematic chain. The terminus of the kinematic chain of the manipulator is called the end effector and it analogous to human hand. In the project,we consider a 2R robotic arm. A 2R robotic arm represents a robotic arm with two rotations.i.e it has two links which rotate or work over a two-dimensional plane with each of links having a single degree of freedom, also both the links are restricted to
a 90 degree rotation with respect to the axes. Below attached shows the 2R robotic arm having many parts as described.


1- Let, L1&L2 be the lengths of the link-1& link-2 respectively.
2- Let,theta1,be the angle formed by the link-1 with horizontal.
3-Let,theta2,be the angle formed by the link-2 with horizontal.
4- Let,the starting and end co-ordinates of the link1 to be (x0,y0) and(x1,y1)
5-Let, the starting and co-ordinates of the link-2 to be (x1,y1) and (x2,y2)

Code Explanation:-
1- Programing language used Matlab Online
2- Starting the program by using the
comments
3- Providing the input variables like predifing the length of the robotic arm i.e L1 and L2
4- Assign the value for theta1 and theta2 using linspace command for theta=0 to 90 degree for 15 values.
5- Assigning the cr(compression ratio) value as a specific digit.
6- Now using 'for' command for iterating the values of the desired variable.
7- Again using for loop inside for theta providing motion of the second roobtic arm.
8- Defining the position/cordinates of the links with the help of the geomertical formulae.
9- Plotting all the co-ordinates and the links and the giving the axis no.
10-Using the pause command to make the plot look realistic
11-Incrementing the cr or compression ratio value by +1 each time it executes for loop.
12-All figures are assigned to a variable M one at a time using cr
13-Using movie commandis to combine all the figure saved in the M file to make an animation/movie
14-At end saving the movie in .avi format.

Matlab Code:-

%robotic arm simulator position code
clear all
close all
clc
%inputs
l1=1;
l2=0.5;
theta1=linspace(0,90,15);
theta2=linspace(0,90,15);
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);
%ploting
% figure ct is prducing a new window each time for loop is executing
plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3)
axis([-0.1 1.6 0 1.6])
M(ct)=getframe(gcf);
%M is the array of the frames of the plot
ct=ct+1;
pause(0.03)
end
end
movie(M)
Videofile=VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(Videofile)
writeVideo(Videofile,M)
close(Videofile)


% end of the code


Errors & Command window Execution:-
- No errors were found during exicution
- Use of semi-colon(;) in coding results in no output in command window

Result/conclusion- Thus we have simulated 2R robotic arm by using the matlab programming and also created a
Movie/Animation from the plots obtained from the program.
Below is the link given for the program output for movie/ animation of a 2R robotic arm

video link-  https://youtu.be/EMucb8iUpFU

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.