Challenge

Week 2- 2R Robotic Arm Challenge

Introduction:

Robotic arms can be used to automate the process of placing goods or products onto pallets. By automating the process, palletizing becomes more accurate, cost-effective, and predictable. The use of robotic arms also frees human workers from performing tasks that present a risk of bodily injury. The robotic arm is used for multiple industrial applications, from welding, material handling, and thermal spraying, to painting and drilling.

Code:

%To create and plot the Kinematics of a 2R Robotic Arm

 

close all
clear all
clc

 

%Let us consider the following inputs as given below. Let L1 and L2 be the
%lengths of the first and second robotic arms respectively.
%Here x0 and y0 are the initial points of the first robotic arm.

 

L1 = 1;
L2 = 1.5;
x0 = 0;
y0 = 0;

 

%Let theta1 and theta2 be the angles where the arms of the robot
%can operate. As we can consider that both theta's are operating in the range of 0 to 90.

 

%So here theta1 and theta2 are arrays with 20 different values between 0 to 90.
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);

 

%Here let ct be the counter
ct = 1;

 

for i=1:length(theta1)

    THETA1 = theta1(i);

 

    for j=1:length(theta2)

        THETA2 = theta2(j);

 

%Following equations below can be used to calculate the locations of the arms.

 

        %Here x1 and y1 are the end points of the first robotic arm and the

        %start points of  the second robotic arm.

        x1 = L1*cosd(THETA1);

        y1 = L1*sind(THETA1);

      

        %Here x2 and y2 are the end points of the second robotic arm.

        x2 = x1 + L2*cosd(THETA2);

        y2 = y1 + L2*sind(THETA2);

 

%Plotting with animation.

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',4)

title('Animation Of Robotic Arm') %Title of the plot

axis([-3 3 -3 3]) %Axis Limits

pause(0.1) %pause is used to pause playback or recording after a particular execution.

M(ct) = getframe(gcf); %getframe is used to capture the axes or figure with a movie frame.

ct = ct+1;

    end

end

 

%Command for the getting the movie file of the robotic arm.
movie(M) %movie is used to play the recorded movie frames from above
videofile = VideoWriter('Forward Kinematics of a Robotic Arm','Uncompressed AVI'); %videowriter - creates objects to write video files. 
open(videofile) %open() - Open files for writing the video data created
writeVideo(videofile,M) %writevideo - writes video data to a file
close(videofile) %used to close the file after writing video data

The getframe(gcf) command is used to get the frame and store it as an image into the array M. The videowriter command creates an empty video file in avi format and it is stored in the variable videofile. The writevideo command inserts the frames into the videofile.

Animation: https://drive.google.com/file/d/1l-epQZHUyurWlabqxtxQRPm3IZ49IveI/view?usp=sharing

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.