Challenge

Week 2- 2R Robotic Arm Challenge

%FORWARD KINEMATICS OF A 2R ROBOTIC ARM MANIPULATOR AND SIMULATE IT
clear all
close all
clc

%inputs
L1 = 1;                       %length of link 1
L2 = 0.5;                       %length of link 2
theta1 = linspace(0,90,10);  %create a row vector from 0 to 90 with 10 evenly spaced points
theta2 = linspace(0,90,10);  %create a row vector from 0 to 90 with 10 evenly spaced points

ct=1;
%for_loop
for i = 1:length(theta1)
    T1 = theta1(i);         %the values of theta1 when iterated is stored in T1
    for j = 1:length(theta2) 
    T2 = theta2(j);         %the values of theta2 when iterated is stored in T2

    x0 = 0;                      %base of link1 is fixed at origin
    y0 = 0;                      %base of link1 is fixed at origin


    x1 = L1*cosd(T1);            %finding final coordinate of link1
    y1 = L1*sind(T1);            %finding final coordinate of link2


    x2 = x1 + L2*cosd(T2);       %finding final coordinate of link2
    y2 = y1 + L2*sind(T2);       %finding final coordinate of link2

%plotting

    plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',2)
    axis([-0.5 2.5 0 2.5])
    pause(0.03)

    M(ct) = getframe(gcf);
    ct = ct+1;
    end
end

movie(M)

videofile = VideoWriter('Forward_kinematic_2R.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

ERRORS resolved

This error was a typo, the word theta was not correctly spelled, and was resolved immediately after.

The above error was resolved by changing the directory, and saved it a different folder.

FOLLOWING IS THE LINK TO THE CLIP OF THE VIDEO:

https://drive.google.com/file/d/1V2AZwrimw6cEeFo88urQ4l9nGIzjX_Br/view?usp=sharing

OUTPUT:

RESULT:

This is a screenshot of a moving robotic arm, in this the arm is the blue line is the upper arm, and the starting coordinate is (0,0), the rotational joint starts from the end point of blue line, for every angle of θ1,(angle made by blue line on x-axis), there is an angle of θ2(angle made by red line on x-axis), which is depicted in the provided video link.

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.