Challenge

Week 2- 2R Robotic Arm Challenge

AIM:

To simulate the 'FORWARD KINEMATICS' of a 2R robotic arm using matlab.

OBJECTIVE:

  • write a program to simulate forward kinematics of a 2r robotic arm.
  • Animating and creating a movie from the plots obtained fron the program.

THEORY:

A manipulator/end effector movement determines the workshop where the robotic arm can be applicable. our motive is to animate movement of the robotic arm with the subseqent relative motion between the two comparising links.

INPUTS:

(X0,Y0) -starting point link 1

(X1,Y1) -ending point link 1/starting point of link 2

(X2,Y2) -ending point link 2

l1 -length of link 1 attached to base

l2 -length b/w end of link 1 and the end of effector

theta1 -angle made by link 1 x-axis

theta2 -angle made by link 2 y-axis

PROGRAM:

%forward kinematics of a 2r robotic arm manipultor:
clear all
close all
clc

%input 
%lenght of the robotic arm:
l1=2;
l2=1;
%set of angles for the movement of the robotic arm:
theta1=linspace(0,90,20);
theta2=linspace(0,90,20);

%coordinates
%counter with the starting values as 1:
ct=1;
%iterating i from 1 to 10 theta1 has 10 values
for i=1:length(theta1)
    THETA1=theta1(i);
    for j=1:length(theta2)
    THETA2=theta2(j);
    %co-ordinates for the starting point of link 1:
    x0=0;
    y0=0;
    %co-ordinates for the ending point link1/starting point of link 2:
    x1=l1*cosd(THETA1);
    y1=l1*sind(THETA1);
    %co-ordinates for the ending point link2:
    x2=x1+l2*cosd(THETA2);
    y2=y1+l2*sind(THETA2);
    %plotting
    %co-ordinates of arm asigned over a theta1&theta2:
    plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3,'marker','*')
    %the limits of x-axis and y-axis:
    axis([-0.1 4 0 4])
    pause(0.03)
    %frames of figure to comprise movie/animation:
    M(ct)=getframe(gcf);
    ct=ct+1;
    end
end

%to make a movie from collected frames
movie(M)
%saving a movie in avi format:
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
%writing the movie in the videofile created:
writeVideo(videofile,M)
close(videofile)


EXPLATION FOR THE PROGRAM:

  • Initially we defined the lenght of the links l1 and l2.
  • Set values for the theta1 and theta 2 are assigned in and array with the linspace command.
  • Use of for command iterating desired values for the desired variables.
  • Again using for command used to provide movement to the second robotic arm.
  • Defining the co-ordinates for the both robotic arms.
  • Plotting the co-ordinate commandand write the commands for changing the appearance from the contour.
  • All figure are assigned to the value of M, one at using ct to terminates the for loop.
  • Finally, movie command is used to combine all the figure saved in the M file to make an animation/movie and threater saving it in .AVI format.

ANIMATION:

The Link for forward kinematics of 2r robotic arm as mentioned below;

https://youtu.be/h_ERu34Hwis

Google drive link as mentioned below;

https://drive.google.com/file/d/1RJi_vwuyKFLhmekncuQTfpG2-Zbs-W-s/view?usp=drivesdk

CONCLUSION:

A practical scenario regarding the functioning of the robotic arm and its workspace has been exprienced by simulating the forward kinematics with a program in matlab.

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.