Project

2R Robotic Ar challenge

Aim:

To Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm and link the video from youtube

Procedure:

We write a program to find what is the final position of manipulator using for loop.

L1= length of link1

L2= length of link2

theta1= inclined angle of link 1

theta2= inclined angle of link 2

(x0,y0)= origin or link 1 points

(x1,y1)= link 1 ending and link 2 starting points

x1= L1*cosd(theta1)

y1= L1*sind(theta1)

(x2,y2)= link 2 ending points

x2= x1+ L2*cosd(theta2)

y2= y1 + L2*sind(theta2)

  • for each position of theta 1, theta2 can take multiple values, so there will be two loops one for position of theta 1 and the other for position of theta 2 i.e 'i' and 'j' resp.
  • linspace command is used for multiple values of theta (0, 90, 10) means b/w 0 to 90 there will be 10 values
  • theta1(i)= THETA1 and theta2(j)= THETA2
  • When you use plot command , the most common plots gets overwritten, to avoid this use hold on
  • ct = counter means represents each and every frame saved in one plots with different points
  • M is used for making movie with uncompressed avi file

Main code

clear all; close all; clc;

L1= 1;
L2= 0.5;
theta1= linspace(0,90,10);
theta2= linspace(0,90,10);
ct= 1;  % ct represents each and every frame
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);


%PLOTTING of different line in same plot with the help of ct function

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) % new figure window= gcf
ct= ct + 1;
    end
end

%for making movie 
movie(M)
% then we create new Avi file
videofile= VideoWriter('forward_kinematics.avi','uncompressed AVI');
open(videofile)  % frame of M should be written
writeVideo(videofile, M)
close(videofile)​

Error faced

This is an indexing error , says we can use alternate frames but its not necessarry to use it , we can run the program and after it fully runs , it says error like this which is normal, mainly our program is running smoothly

In 2R robotic arm means 2 rotational joints in the robot. Both arms have a different angle of rotation.Based on the angle,the arm rotates.Initially, the angle values are obtained by using the linspace command.For the first position of link 1,all the possible position of link 2 is obtained. Similar to the first position all position of link 1 is setuped and corresponding link 2 positions are identified. By using movie command we can create the video file of the robotic arm

Youtube's video link:

https://youtu.be/lgTMznoF8pM

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.