Week 2- 2R Robotic Arm Challenge

2R Robotic Arm
EXPLANTION :
STEP 1 :
CALCULATE THE POSITION OF LINK 1;
*Link 1 has the two points.(1)Starting point.(2)ending point.The starting point is connected with base and the end point connect to link 2.
*Coordinate of starting point –(0,0)
*Coordinate of end of staring point= l1cos(theta1)
l1sin(theta1)
where,
l1- length of the link 1
theta1- angle of link 1
STEP 2:
CALCULATE THE POSITION OF LINK 2;
*The starting point of the link 2 is connected with end point of the link 1.
*coordinate of the end manipulator(x2 y2) = 1) x2 =x1 +l2cos(theta2)
2) y2=y1+l2sin(theta2)
Where,
l2 - length of the link 2
theta2 - angle of link 2
PROGRAM-EXPLANATION :
*Put the input values of links length(l) and angle(theta).
*We have the three coordinates like(x0 y0),(x1 y1),(x2 y2).
*The starting coordinate(x0 y0) will be zero.Because it will be connected to the base.
*Also we know the inputs values of length and angle. So find the (x1 y1) and (x2 y2)values.
*By using the plot command we get the final output.
% Inputs
l1 = 1;
l2 = 0.5;
theta1 =40;
theta2 =22;
%coordinates
x0 =0;
y0 =0;
x1=l1*cosd(theta1);
y1=l1*sind(theta1);
x2=x1+l2*cosd(theta2);
y2=y1+l2*sind(theta2);
%plotting
line([x0 x1],[y0 y1],'linewidth',3,'color','b')
line([x1 x2],[y1 y2],'linewidth',3,'color','r')