Challenge

Week 2- 2R Robotic Arm Challenge

%Inputs
l1=1;
l2=0.5;
theta1=linspace(0,90,10); %linspace for linearly space numbers
theta2=linspace(0,90,10);
ct=1; %counter steps
for i=length(theta1) %i act as a counter
    THETA1=theta1(i); %Denotes the ith variable in theta1 goes to THETA1
    for j=length(theta2)
    THETA2=theta2(j); %Denotes the jth variable in theta2 goes to THETA2
    
    x0=0;
    y0=0;

    x1=l1*cosd(THETA1); %command to simulate l1 arm movement
% using THETA in place of theta
    y1=l1*sind(THETA1); %command to simulate l2 arm movement

    x2=x1+l2*cosd(THETA2); %using cos d to use angle in degree
    y2=y1+l2*sind(THETA2);
    
    
    plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3)
    axis([-.1 1.5 0 1.5]) %axis limits for x and y axis
    pause(0.1) %pausing the code for 0.1 sec
    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.