Challenge

Week 2- 2R Robotic Arm Challenge

https://youtu.be/IlvtfqDVWug

EXPLANATIONS
1.Linspace command:
 The 'linspce' command is used to generate a row vector.
 Example:
   K = linspace(1,10,5)
   K = 1.0000 3.2500 5.5000 7.7500 10.0000
2.For Loop:
 A 'loop', in general, refers to anything whose start and end points are connected. That is, once you begin from the start point and proceed further, you will reach the finish line just to find that it once again guidesyou to the same point where you started. Proceeding further means that you are repeating your same action again & again. 
 Example:
   for i=1:10
   disp(i);
   end
 Explanation 
Line 1 : for i = 1:10 - initiates the loop
                      - states a condition for which the instruction is to be repeated.
Line 2 : disp(i)      - instruction
                      - this command displays the value of "i" in command window.
Line 3 : end          - end of loop.
                      - this terminates the set of instruction and takes the program 
                        again to Line 1.
3. Plotting:
  Line plot:
     A line plot represents a mathematical function. It shows how the function changes with respect to the input argument. The trend of any variablethat depends on an independent variable (e.g time or frequency) could be shown graphicallly using line plots.
  Example:
    plot(x,y,'color','r','linewidth',3)
clear all
close all
clc

%Inputs
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);
        
        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([-0.1 1.5 0 1.5])
        pause(0.01)
        M(ct) = getframe(gcf);
        ct=ct+1;
    end
end

movie(M)
videofile = VideoWriter('forward_kinamatics.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.