Week 2- 2R Robotic Arm Challenge
*********** Comments by Grader ************
GOOD JOB!!
SUGGESTION :
The other thing that you can do is to attach the code and images in projects.skill-lync.com and paste the link over here.
If you have any doubts please ask us on WHATSAPP or raise a ticket on FRESHDESK or even you can CALL us clarify all your doubts.
Please don't submit incomplete work as these challenges are made with an intuition of improving your understanding regarding the topic.
So attempt all challenges sincerely.
Thank you.
The youtube link for the animation video "https://youtu.be/i0wlCcQSyOo".
First, I defined the values of the arms.
Then I defined the angular movement of the first and the second arm from 0 to 90.As the movement is incremental I used a linspace command to define the the number of divisions.
After that I used two loops for plotting a graph for each every change of movement of the arms. I defined the first loop for the first arm and the second for the plotting the second arm positions graph. When the first loop gets executed the value of THETA1 becomes and this value keeps on changing based on the the number of times the loop runs. As the no of divisions specified is fifteen in the linspace command for theta1, so the loop is gonna run 15 times.After the first loop gets executed the first run the second loop start. This also works in the same fhasion but this loop gets executed 15 times for 1 execution of the first loop.The second arm is defined by two points as both points move. The first is connected to the first arm defined as x1 and y1 for x and y coordinate system. Then the second point as x2 and y2. Then the formula is defined for the movement of the both points.
Then based upon the values the graph is plotted with x and y axis defined.These images are stored in a variable known as M.For every count of execution of the second loop the count variable stores the images in M then gets incremented and stores the next image upon the next run.
After running the loop all the Images stored in M are written on a file created as forward_kinematics.avi.
The error that I faced while programming is that the filewas not opened for the software to write. I understood the error and immediately rectified it by typing open(Videofile)
clear allclose allclc%Inputsl1=1;l2=0.5;theta1=linspace(0,90,15);theta2=linspace(0,90,15);ct=1for i=1:length(theta1) THETA1=theta1(i); for j=1:length(theta2) 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.01) M(ct)=getframe(gcf); ct=ct+1; endendmovie(M)Videofile=VideoWriter('forward_kinematics.avi','Uncompressed AVI')open(Videofile)writeVideo(Videofile,M)close(Videofile)