Challenge

Week 2- 2R Robotic Arm Challenge

Aim:

               To write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm .

Procedure:

               The name of the program is written in the top of the program. Clear all is used top clear the workspace values. Close is used for close all the windows of the old program. Clc is used to clear the command window.

               Input topic is mentioned to easily identify l1 and l2 is given in the program the length of the arm is given. Then the theta value is given the linspace is determines start point, end point and in between interval

               Ct it is the counter the initial point were to start is mentioned. For loop is used here because they are multiple values are calculated and to provide the animation it is used. Here the I value is given it mentions the number of values it contained.

               Length calculate the number values it contain in the theta and 1 to 10 it contains understand and as per that it is taken. Another for loop is used because an each harm position the another arm as the multiple position to visualize it the for loop as the another for loop total the program continuously run for 100 times

               THETA2 is mentioning the values of theta2(j) as another 10 values totally 10*10 100 times the programs run. Below that the x and y axis link start point set and after that the next link point provided and the calculation formula is provided. In this case for the each point of the axis is formula is provided. Cosd is provided because without d the cos is calculate the radian. When cosd is mentioned it take the theta value

               Plotting is provide below. Here the plotting of the all formulas result is visualized  xy manner the plotting is takes place in it the colour of the link is provided line width size provided

               The axis limits is provided x start to end at first to and y start to end at third and fourth value mentioned. The pause is provided to visualize the frame after the every half second or the final output final position only visualized . then the movie creating takes place here the frames are joined and makes the continuous play of frames

               Below that only the ct addition takes plays. The counter is used for when each time in the loop the program completes the ct increment takes place in this way the loop takes place then the loop end

               To create movie we use the movie command and M denotes the symbol for movie. Then the file name is given below here the forwards kinematics is file name and uncompressed AVI is format it is not used the output size increase of video file

               Open is used to play the file and run during simulation. Then writeVideo is used to write the video as the movie also mentioned. After completing close command is used to close

Errors found and overcomed:

               M(ct)=getframe(gcf);

               ct=ct+1

               the above commands to be in this format other wise error occurs

               videofile = VideoWriter('forward_kinematics.avi','uncompressed AVI');

               here the case of the letter to be as above for videowriter

     writeVideo(videofile,M)

               here too the case as been as above command

               THETA1 = theta1(i)

               x1 = l1*cosd(THETA1)

               in above condition we has been changed the THETA1 after entry of for loop this shoud be changed while we copy and paste.

               These types of error are occurred during I founded those case letter they used and overcome with the executing program. I attached  my result and program with this.

% Forward kinematics of a 2R robotic ARM manipulation
clear all
close all
clc

%input
l1 = 1
l2 = 0.5

theta1 = linspace (0,90,10)
theta2 = linspace (0,90,10)

ct=1

for i= 1 : length(theta1)
    THETA1 = theta1(i)
    for j = 1 : length(theta2)
        THETA2 = theta2(j)
        x = 0
        y = 0 

        x1 = l1*cosd(THETA1)
        y1 = l1*sind(THETA1)

        x2 = x1+l2*cosd(THETA2)
        y2 = y1+l2*sind(THETA2)

        %plotting
        plot([x x1],[y y1],[x1 x2],[y1 y2],'linewidth',3)
        xlabel('x axis')
        ylabel('y axis')
        axis([-0.1 1.5 0 1.5])
        pause(.5)
        M(ct)=getframe(gcf);
        ct=ct+1
    end
end

movie(M)
videofile = VideoWriter('forward_kinematics.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
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.