Project

Forward kinematics for 2r robot arm

% forward kinematics of 2r robot arm
clear all
close all
clc
% inputs
l1 = 2;
l2 = 1;
tita1 = linspace(0,90,10);
tita2 = linspace(0,90,10);

ct = 1
for i = 1:length(tita1)
    t1 = tita1(i)
    for j = 1:length(tita2)
        t2 = tita2(j) 
        x0 = 0;
        y0 = 0;
        x1 = l1*cosd(t1);
        y1 = l1*sind(t1);
        x2 = x1 + l2*cosd(t2);
        y2 = y1 + l2*sind(t2);
        
        % plot
        
        plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],\'linewidth\',2.5)
        axis ([-1 3.5 0 3.5]) 
        
        M(ct) = getframe(gcf);
        pause (0.1);
        ct = ct+1;
    end   
end
movie(M) 
video = VideoWriter(\'robotarm.avi\',\'Uncompressed AVI\');
open(video)
writeVideo(video,M)
close(video)

https://youtu.be/dAW6HX1oRSM

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.