Challenge

Week 2- 2R Robotic Arm Challenge

Aim:Matlab program to simulate forward kinematics of 2D robotic arm

Theory: Considering 2D robotic arm with 2 parts with length L1 and L2 of 1 m and 0.5 m respectively. Let them make and angle of theta 1 and theta 2 respectively with the horizontal whose values vary from 0 to 90 degree and there are 10 values between the range. let x0,y0 be the initial position or the hinged point of the first part of the arm. we ll be finding x1 and y1 with the l1 and theta 1 values and x2, y2 using x1, y1 and l2 and and theta 2 values.plot the values and get frames from it and using movie command get the simulation video from it.

clear all
close all
clc
%Inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
ct = 1;
%looping 
for i=1:length(theta1)
    THETA1 = theta1(i);
    for j=1:length(theta2)
        THETA2 = theta2(j);
        %declaring values for x1,x2,x3,y1,y2,y3
        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);
        %denoting axis
        axis([-0.1 1.5 0 1.5])
        pause(0.03)
        %getting frames
        M(ct) = getframe(gcf);
        ct = ct+1;
    end
end
%using movie command for simulation
movie(M)
videofile = VideoWriter("Forward_Kinematics.avi",'Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

Conclusion: With the above code we will get the plot as well as the output simulation in the following google drive link.https://drive.google.com/file/d/11Rv8gudDAneHPkBOIYYcDrQE18JkE-uN/view?usp=sharing

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.