Challenge

Week 2- 2R Robotic Arm Challenge

Aim:

To write a program in MATLAB for forward kinematics of a 2R robotics arm.

Governing equations:

Were,

Objectives:

  • To made a program and animation of 2R robotics arm in MATLAB and discuss the error and solution in detail.

Body of content:

  • The programing of robotics arm is very crucial in mechanical industry, the first thing which is done in this program is coding the kinematics of the linkage of robot.
  • As its mentioned to program a 2R robotics arm the number of links taken here is 2.
  • Below is the detailed input code used in this programing.

Input

clear all
close all
clc
 
%Inputs
 
LINK1 = 1
LINK2 = 0.5
theta1 = linspace(0,90,45)
theta2 = linspace(0,90,45)
 
%for loop for animation
 
ct = 1
 
for i = 1 : length(theta1)
    THETA1 = theta1(i);
    for j = 1: length (theta2)
    THETA2 = theta2(j);
    X0 = 0;
Y0 = 0;
 
X1= LINK1*cosd(THETA1);
Y1 = LINK1*sind(THETA1);
 
X2= X1 + LINK2*cosd(THETA2);
Y2 = Y1 + LINK2*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)

Explanation of code:

  • This code is done in MATLAB 2021R, in which the inputs variable of robotics links is taken as LINK1 and LINK2, and variable for angle Θ is taken as theta1 and theta2.
  • The expression of coordinate is taken same as X0 and X1 for initial and final value.

Error and solution:

During the attempt of kinematics robotics links there is so many errors occur in coding. But the major error which happen in coding as discuss below.

Above is the major error occurring regarding the forward kinematics links of robotics.

The problem is simple spelling mistake as you can see in writevideo the v is have to be capital and the spelling of uncompressed is wrong.

The error and solution are shown in below figure.

Above is the figure of mistake which lead to error.

And above is the correction done for the error

Result

Below is the google link for 2R robotics arm video for the final result purpose.

https://drive.google.com/file/d/18EDFTLGGOMJ34f7Tp8WYc3piCgs4Tx48/view?usp=sharing

Conclusion:

The above program to simulate the forward kinematics of a 2R Robotic Arm is done in MATLAB 2021R, this program is done to find out the moment of robotics in different angle.

As the robotics configuration in crucial in mechanical industry, so one should know the programming of basic robotics arm.

The details of code are shown in body of content in input, and the error occurs during the coding is shown in error and solution parts.

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.