Challenge

Week 2- 2R Robotic Arm Challenge

Movie link:

https://youtu.be/zMawzjCWR3g

close all
clear all
clc
%The robot here in the problem is having length of both links
%The angles are variable, more specifically an array

%Inputs required
l1=2;   %Length array in meters
l2=1;   % Second Link length 
t1=linspace(0,90,10);   %angles for the first link
t2=linspace(0,90,10);   %angles for the first link

%Coordinates of starting and end points of both links
x0=0;
y0=0;
%for loop for making animation of robotic arm 
% this is done for calculation of each coordinates for position of robotic
% arms
ct=1;
for i=1:length(t1)
    x1=l1*cosd(t1(i));   %using parametric form to calculate the coordinates
    y1=l1*sind(t1(i));
    for j=1:length(t2)
        x2=x1+l2*cosd(t2(j));
        y2=y1+l2*sind(t2(j));
        
        plot([x0 x1], [y0 y1], [x1 x2], [y1 y2], "linewidth",3)
        axis([0 3 0 3])
        pause(0.02)
        M(ct)=getframe(gcf);
        ct=ct+1;
    end
end
movie(M)
Videofile=VideoWriter("himanshu_forward_Kinematics.avi", "Uncompressed AVI")
open(Videofile)
writeVideo(Videofile,M)
close(Videofile)

errors:

close all
clear all
clc
%The robot here in the problem is having length of both links
%The angles are variable, more specifically an array

%Inputs required
l1=2;   %Length array in meters
l2=1;   % Second Link length 
t1=linspace(0,90,20);   %angles for the first link
t2=linspace(0,90,20);   %angles for the first link

%Coordinates of starting and end points of both links
x0=0;
y0=0;
%for loop for making animation of robotic arm 
% this is done for calculation of each coordinates for position of robotic
% arms
ct=1
for i=1:length(t1)
    x1=l1*cosd(t1(i));   %using parametric form to calculate the coordinates
    y1=l1*sind(t1(i));
    for j=1:length(t2)
        x2=x1+l2*cosd(t2(j));
        y2=y1+l2*sind(t2(j));
        figure(ct)
        line([x0 x1], [y0 y1], 'linewidth',3,'color','g')
        line([x1 x2], [y1 y2], 'linewidth',2,'color','r')
    end
end

There were some errors encountered during the running of code but after proper searching this become easy to correct.

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.