Project

2R robotic arm challenge

Objective:

It is required to know the work space of Industrial robot which can be done by simulating and animating the links at various points.

Introduction:

Industrial robots perfom important role in the the modern industrial infrastructure,and in order to be able to plane the factory correctly ,the workspace of the robot should be identified.In addition to this this work space is used to identify the danger ones in the factory which no human should be present in as previous accidents with industrial robots resulted in severe injuries and death.

Inputs:

l1=1 m

l2=0.5 m

Modeling equation:

`x1=l1*cos(theta1)`

`y1=l1*sin(theta1)`

`x2=x1+l2*cos(theta2)`

`y2=y1+l2*sin(theta2)`

Program structure:

The main idea of the program is to use two for loops in order to cover all the probabilities of the robot link motion.This is done by setting the limit of the counter "i and j" in the for loops by the number of angles which are generated by the linspace command which will form the study and analysis points of the program.Then a single theta is picked from the array generated by the linspace command to perfrom the calculations on. Then it is plotted and animated and saved in an avi movie file.

code:

clear all
close all
clc

%inputs
l1=1;
l2=0.5;
theta1=linspace(0,180,10);
theta2=linspace(0,180,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 = y1+l2*sind(THETA2);

        %plotting
        
        plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3)
        axis([-1.5 1.5 0 1.5])
        pause(0.03)
        M(ct)=getframe(gcf);
        ct = ct+1;
   
   
   end
end
movie(M)
videofile= VideoWriter('forword_kinematics.avi','uncompressed avi')
open(videofile)
writeVideo(videofile,M)

program explaination:

  • First the input is defined
  • Then theta1 and theta2 array is generated using linspace command which generates array starting from zero to 180 degrees with 8 steps in between,so he will perform calculation every 20 degrees.
  • Then counter is initialized using “ct” command
  • Then the counter “i” for the first loop in initialized and limited using the number of elements in the theta 1 array
  • Then we pick certain THETA from theta 1 array to perform the calculations on
  • Then the counter “j” for the second loop is initialized and limited using the number of elements in the theta2 array
  • Then we pick certain THETA from theta 2 array to perform calculations on
  • Then the modeling equations are initialized and modeled using cosd and sind command because the input is in degrees
  • Then the output is plotted on Cartesian plot with linewidth 3
  • Then it slowed down by 0.03 second
  • Then we get individual frames using get frame command
  • The counter is then increased by 1
  • Using individual frames, a movie is created using movie command
  • A new avi file is created where the individual frames are stored using avi video file command
  • The video file is opened,written and closed in the following command

Errors in programming:

The main error is defining the y1 equation using theta2 which resulted in the program working and animation generated but it was returning to zero every now and then .It was then corrected.

Animation:

https://youtu.be/3YtFBTpUg68

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.