Challenge

Week 2- 2R Robotic Arm Challenge

2R ROBOTIC ARM CHALLENGE

AIM:

  • To write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm.
    Objective :
    • Write a program to simulate the forward kinematics of a 2R Robotic Arm.
    • To create a Movie/Animation from the plots obtained from the program.

Forward Kinematics:

Forward kinematics refers to the use of the kinematic equations of a robot to compute the position of the end-effector from specified values for the joint parameters.

https://www.rosroboticslearning.com/forward-kinematics

Theory:

Kinematics is the science of motion. In a two-joint robotic arm, given the angles of the joints, the kinematics equations give the location of the tip of the arm.

A robotic arm is a kind 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 part of a more complex robot. The links of such a manipulator are connected by joints allowing either rotational motion or translational (linear) displacement.

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 is analogous to the human hand. in this project, we consider a 2R robotic arm. A 2R robotic arm represents a robotic arm with two rotations. I.e. It has two links that rotate or work over a two-signal plane with each of the links having a single degree of freedom. both the links are restricted to a 90° rotation with respect to the axes. Fig below shows the 2R robotic arm having many parts as described.

In the showing of the above figure1, the robotic arm consists of 4 components
• The Base, which is clamped to the surface, and all other links are joined through the hinge joint.
• Link1 (L1) making θ1 with horizontal.
• Link2 (L2) making θ2 with horizontal.
• The device attached to the manipulator which interacts with its environment to perform tasks is called the end effector.
PROGRAM:
% A Program for 2R Robotic Arm Challenge
clear all
close all
clc

%Inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);

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 = x1 + l2*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:
  • Programing Language used by MATLAB Online.
  • For clearing command window & workspace, closing all plots, and Defining the input variables.
  • Predefining the length values of the robotic arms, L1&L2.
  • Providing the values for theta1 & theta2 using the linspace command for theta=0 to 90 degrees for 10 values.
  • Providing the compression ratio value as a specific digit.
  • Using the 'for loop' command for iterating the values of the desired variable.
  • Again use the 'for loop' command for providing movement of the second robotic arm.
  • Provide the equation for the X1, Y1, X2, and Y2 and define the coordinates of both the robotic arms.
  • Plotting all the coordinate values and providing the X-axis and Y-axis numbers.
  • Using the pause command to make the plot look realistic.
  • Incrementing the compression ratio value by +1 each time executes 'for loop'.
  • All figures are assigned to a variable M, one at a time using a compression ratio, ending the 'for loop'.
  • using movie commands to combine all the figures saved in the .M file to make an animation/movie, and the end saving the movie in .avi format.
Errors & Command window Execution:
  • No Errors were found during execution.
  • I used the semi-colon(;) in the program resulted in no output in the command window.
Result/Conclusion:
  • Thus we have simulated the 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 to the program output for the movie/animation of a 2R robotic arm.
  • https://youtu.be/Gpz3dR-EUrw
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.