Challenge

Week 2- 2R Robotic Arm Challenge

Objective :- A program in matlab to Simulate the forward kinematic of a 2R Robotic arm with animation using

matlab.

Theory : -

ROBOTICS :- Robotic is an interdisciplinary sector of science and engineering dedicated to the design,construction and use of mechanical robots.

ROBOT :- A robot is the product of robotics field, where programmable machines are built that

can be assit humans action.

KINEMATIC ROBOT ARM :- Kinematics is the science of motion. In a two joint robotic arm,given

the angle of the joints,the kinematics equation give the location of the arm.

Matlab code :-

%close all
%clear all
%clc
% simulate the forward kinematics of a 2R arm
%Length of links are in (mm)
l1 = 1;
l2 = 0.5;
%Angle of links inclination are in (degree)
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
%counter
ct = 1;
%Using for loop code
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);
%Ploting the lines
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
axis([0 1.5 0 1.5])
pause (0.3)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
movie(M)
% creating animation video file
videofile = VideoWriter('kinematic_forward_2r_link.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Screen shot of matlab code :-
Screen shot of output code :-

Explanation of the matlab code :-

  • First of all giving the links value are in (mm) as :- l1 = 1 , l2 = 0.5 .
  • After then giving the angle values are in (degree),for forward kinematic of links we giving the values of theta1 and theta2 multiple times by the using of linspace command as shown in below:-

theta1 = linspace(0,90,10)

theta2 = linspace(0,90,10)

  • Then our next step is using counter command.
  • Using for loop find the co-ordinates of link1 and link2.
  • Using plot cammand creating a plot for link1 and link2.
  • At the end create a animation movie using movie(m) command.

Result :- The simulation of the forward kinematics 2R robotic arm is completly simulate by the using of matlab and animation video are done by movie(m) command.

Errors faced while programming : -

  • During the plotting there is overwritten the links and shows one color.

Screen shot of error :-

Solution : -

BY using hold on command the error ca be solved.

  • By mistake of without using of brackets within parentheses are given error.

Screen shot of error :-

Solution :-

By using brackets within parentheses .

  • Error are shows when create animation file from type writevideo instead of WriteVideo.

Screen shot of error :-

you tube link are given below :-

https://youtu.be/X8LXW_8DFuY

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.