Project

2 Arm robot animation

*********** Comments by Grader ************

GOOD JOB !!!!

Make use of insert code option to insert a code rather than just copy pasting it.

Marks here are deducted for the above mentioned reasons.

SUGGESTION :

The other thing that you can do is to attach the code and images in projects.skill-lync.com and paste the link over here.

If you have any doubts please ask us on WATS APP or raise a ticket on FRESHDESK or even you can call us clarify all your doubts.

Thank you.

CODE:

close all
clear all
clc
%inputs

l1 = 2;

l2 = 1;

%angle of the arm 1
theta1 = linspace(0,90,10);

%angle of the arm 2
theta2 = linspace(0,90,10);

%counter
ct =1;

%function for movement
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);
plot([x0 x1] , [y0 y1],[x1 x2] , [y1 y2],'linewidth',3)
axis([-.1 3.5 0 3.5])
pause(.05)
M(ct) = getframe(gcf);
ct=ct+1;

end
end

movie(M)
videofile = VideoWriter('Week2_project.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)

 

REPORT ON THE PROJECT:

Aim:

To Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm. To create a animation file of the plot.

Procedure and explanation of the project:

Step 1: commands "close all" ; "clear all" ; "clc" these commands close all the previous files,clear all the previous contents and clears the content in command window respectivly.

Step 2: commands "l1 = 2;" ; "l2 = 1;" these commands represents the inputs it specifically represents the length of the robot arms respectivly.

Step 3: commands "theta1 = linspace(0,90,10);" ; "theta2 = linspace(0,90,10);" these commands are also represents the inputs it indicates the angle of inclination of the robot arms.The command "linspace(0,90,10)" indicates producing 10 random values between 0 and 90.

Step 4 : command "ct=1;" this command is used to intialise a variable that is to be used as a counter variable.

Step 5 : command "for i= 1 : length(theta1)" it is a for function command from an intial value of 1 to goes upto length of theta1 it is generally a incremental loop.

Step 6 : command "THETA1 = theta1(i);" this command assigns the value to THETA1 for each value of the theta1(i)

Step 7 : command "for j = 1 : length(theta2)" it is a for function command from an intial value of 1 to goes upto length of theta2 it is generally a incremental loop.

Step 8 : command "THETA2 = theta2(j);" this command assigns the value to THETA2 for each value of the theta2(j)

Step 9 : command "x0=0" ; "y0=0" ; "x1= l1*cosd(THETA1);" ; " y1 = l1 * sind (THETA1);" ; "x2= x1 + l2*cosd(THETA2);" ; "y2 = y1 + l2 * sind(THETA2);" these command are the used to initialse and calculate the values for the points "x0,yo,x1,y1,x2,y2".

Step 10: command"plot([x0 x1] , [y0 y1],[x1 x2] , [y1 y2],'linewidth',3)" this command plots a graph between the points to represents the robot arms.

Step 11 : command " axis([-.1 3.5 0 3.5]) " ; this command defines the scale of the plot from -1 to 3.5 in x axis and 0 to 3.5 in y axis.

Step 12 : command " pause(.05) " this commands pause each plot by .05 seconds.

Step 13 : command " M(ct) = getframe(gcf);" This command gets the frame of the plot and stores in variable "M" for animation purpose.

Step 14 : command : "ct=ct+1;" this is basically an incremental command.

Step 15 : command : "movie(M)
videofile = VideoWriter('Week2_project.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile) " these commands are used to create a avi video file from the plot by capturing the frame rate by using the variable "M".

ERROR AND CORRECTION:

Error:

Correction:

The command "VideoWriter" was typed incorrectly as "videowriter".thus the error is occured and then corrected.

RESULT:

Thus the program successfully executed and animation file is created for the robotic arm.

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.