Challenge

Week 2- 2R Robotic Arm Challenge

Forward kinematics of a 2R robotic arm manipulator:-


Inputs:-
l1=1
l2=0.5
theta1=linspace(0,90,4)
theta2=linspace(0,90,4)

where,
l1 and l2 are the lenths of the link1 and link2
theta1 is the angle of link1 at x-axis
theta2 is the angle of link2 at x-axis
linspace command is a function where it assigns a numerical space between each values itself
linspace(0,90,4) is used to assign 4 values between 0 to 90 with the equal numerical space

ct=1
-for i=1:length(theta1)
THETA1=theta1(i)
-for j=1:length(theta2)
THETA2=theta2(j)

where,
ct is the counter
for is the command function for forloop
i and j is the variable assigned to the for loop

coordinates:-
x0=0
y0=0
x1=l1*cosd(theta1)
y1=l1*sind(theta1)
x2=l2*cosd(theta2)
y2=l2*sind(theta2)

where,
x0 and y0 are the base of the robot(link1) and it is a starting points which is fixed.
x1 and y1 are the base of link2 and it is a end points of link1 and starting points of link2.
x2 and y2 are the end points of link2
cosd and sind is the angle degree of the x and y axis which is a trigonometrical formula.

plotting:-
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2]'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.3)
ct=ct+1
M(ct)=getframe(gcf)


where,
plot is function for plotting
here [x0 x1] and [y0 y1] is used to determine the link 1
here [x1 x2] and [y1 y2] is used to determine the link 2
linewidth is a function to determine the thickness of the links
3 is mentioned after the linewidth is the thickness size
pause function is to pause the code
ct=ct+1 is to incrementing the plots
gcf is current figure window

-end
-end

Movie(m)
videofile=videowriter(;forward_kinematics.avi','uncompressed AVI')
open(videofile)
writevideo(videofile,M)
close(videofile)

where,
Movie(M)-matlab is going to generate a movie with all those frames
videofile is where we are going to save our frames or files

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.