Challenge

Week 2- 2R Robotic Arm Challenge

For this robotic arm one i have created the programm using the l1 and l2 and with the help of theta values the angels are provided and the coordinates are also given then i have given the coordinates with length and theta and again for the second arm the same data is given in coding

now coming to the point of plotting the line data is given with linewidth and colors spects as after running the programme the single line arm output is given

then coming to the next part of programme we are writting the code related to animating and creating the plot in another new tab

with the help of the input values of l1 and l2 and the same of theta values . after we are makung it up with loop code amd giving the i value , later after that for each value of theta 1 link 1 and for link 2 can take mulitple positions were theta 2 changes .

now give another loop code line with j and give the input vales to that were later the loop with work on running the code

now after that copy and paste the previous tab code from line coding as we have done in that

and change the small theta letters to caps, change in line 16 with the caps as said , after that give the plotting values to that along with the theta values and write with the ct values with the iteration of the ct and then convert the line command to plot which helps in plotting and most recent plot will be shown

delete the 2 plot line command & make it in plot 1

after as this done please go for the commands that create and open and close and write the video file video and please save and at last just run the code and see the plotting will be shown and animated video will be saved in file

clear all  
close all
clc


%inputs
l1 = 1.5;
l2 = 0.5;
theta1 = linspace(0,90,4);
theta2 = linspace(0,90,4);

ct=1;
for i = 1:length(theta1)
    for j = 1:length(theta2)
    THETA1 = theta1(i);
    THETA2 = theta2(j);
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)
axis([-0.1 1.5 0 1.5])
pause(0.1)
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.