Challenge

Week 2- 2R Robotic Arm Challenge





ANIMATION FOR 2R ROBOTIC ARM MOTION


Firstly, the robots have arms that arm have different angle of motion. Here we considering 2 leg robotic arm motion(2R robotic arm motion). The leg 1 have different degrees of angles and leg 2 have different angle of motion that motion we animated using MATLAB codes. The robotic arm length l1 and l2 then the angle theta1 and theta 2 then we considering different arm motions and different picking points of a
Robotic arm. The arm motions are in x and y directions. First we assign some values in legs the add different angle value in matrix then add to for loop and create a plot after we creating a video file using movie command

CODE:

% animation of kinamatics of a 2R robboic arm motion
clear all
close all
clc
 %inputs

 l1 = 1;
 l2 = .5;
 ct = 1;
 theta_1 = linspace(0,90,10);
 theta_2 = linspace(0,90,10);
 for i = 1:length(theta_1)
     THETA_1 =theta_1(i)
     for j = 1: length(theta_2)
         THETA_2 = theta_2(j);
         x0 = 0;
         y0 = 0;

         x1 = l1*cosd(THETA_1);
         y1 = l1*sind(THETA_1);
         
         x2 = x1+l2*cosd(THETA_2);
         y2 = y1+l2*sind(THETA_2);

         %plotting
         

         plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
         axis([-.1 1.5 0 1.5]);
         pause(.03)
         M(ct) = getframe(gcf);
         ct = ct+1;
     end

 end
 movie(M)
 videofile=VideoWriter('Anmtd2Rrbtcmtn.avi')
 open(videofile);
 writeVideo(videofile,M)
 close(videofile);


Code Explanation:

clear all – Clear all variable from workspace
close all – Close all current figures in MATLAB
clc- clear all text from the command window
linspace- Create linearly spaced vector or generate linearly spaced values.
For loop- This MATLAB function executes a group of statements in a loop for a specified number of    
                 times. 
Plot- This MATLAB function creates a 2-D line plot of the data in Y versus the corresponding values in X
Axis- This MATLAB function specifies the limits for the current axes
Movie- This MATLAB function plays the movie frames in array M once.
VideoWriter-create an object to write a video file

Result:

After run the program  I got movie file and I attached the google drive link with this code.
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.