Week 2- 2R Robotic Arm Challenge
Youtube Link for animation
REPORT--
STEPS
- Initializing the arm length and inclination angles.
l1=1; % length of arm 1l2=0.5; % length of arm 2theta1=linspace(0,90,10); % inlcnation values of arm1theta2=linspace(0,90,10);
- CT- Used for image reconstruction.
- using for loop end coordinates are calculated for every angle.
for i =1:length(theta1) %{loop for plotting of arm 1 and 2a=theta1(i); %{ for every change in arm1 and arm2 inclinationfor j=1:length(theta2)b=theta2(j); % a= angle of inclination of arm1 and b=angle of inclination of arm2x=0; % fixed end coordinatesy=0;x1=l1*cosd(a); %end x coordinates of arm1y1=l1*sind(a); %end y coordintes of arm1x2=l1+l2*cosd(b); %end x coordinates of arm2y2=l1+l2*sind(b); %end y coordintes of arm2
- plotting is done using plot instead of line command.
plot([x x1],[y,y1],[x1 x2],[y1 y2],LineWidth=1.5)axis([0 2 0 2])xlabel('horizontal reach---------->')ylabel('verticl reach----------->')
- animation is created by using CT and Pause.
close all clear all clc l1=1; % length of arm 1 l2=0.5; % length of arm 2 theta1=linspace(0,90,10); % inlcnation values of arm1 theta2=linspace(0,90,10); %inlcnation values of arm2 tic ct=1 for i =1:length(theta1) %{loop for plotting of arm 1 and 2 a=theta1(i); %{ for every change in arm1 and arm2 inclination for j=1:length(theta2) b=theta2(j); % a= angle of inclination of arm1 and b=angle of inclination of arm2 x=0; % fixed end coordinates y=0; x1=l1*cosd(a); %end x coordinates of arm1 y1=l1*sind(a); %end y coordintes of arm1 x2=l1+l2*cosd(b); %end x coordinates of arm2 y2=l1+l2*sind(b); %end y coordintes of arm2 %plotting........... plot([x x1],[y,y1],[x1 x2],[y1 y2],LineWidth=1.5) axis([0 2 0 2]) xlabel('horizontal reach---------->') ylabel('verticl reach----------->') %providing the pause for plotting pause(0.1) M(ct)=getframe(gcf) ct = ct+1 end end duration=toc movie(M) videofile=VideoWriter('forwrd kinematic robotic arm') %creating a video file open(videofile) writeVideo(videofile,M) close(videofile) - Video file is created.
ERRORS--
- Error occurred due to dot operator.
- Error due to the wrong syntax in pause.
- Unable to create animation using the lines.
Steps were taken to solve the error--
- Dot operator is removed.
- Syntax error in the pause is solved using parenthesis.
- Animation is created by using a plot instead of a line.