Question
Modeling Robot Arm reach and motion CAN YOU ADD COMMENTS FOR THE BELOW MATLAB CODE (WHAT EACH STEP DOES): close all clear all alpha4 =
Modeling Robot Arm reach and motion
CAN YOU ADD COMMENTS FOR THE BELOW MATLAB CODE (WHAT EACH STEP DOES):
close all
clear all
alpha4 = 0:15:75;
alpha3 = -45;
alpha2 = -45:15:45;
alpha5 = -45:10:45;
Arm43 = 8;
Arm32 = 5;
Arm21 = 3;
[ALPHA4, ALPHA3,ALPHA2,ALPHA5] = ndgrid(alpha4,alpha3,alpha2,alpha5);
longdist = Arm43*cosd(ALPHA4)+Arm32*cosd(ALPHA4+ALPHA3)+Arm21*cosd(ALPHA4+ALPHA3+ALPHA2);
height = Arm43*sind(ALPHA4)+Arm32*sind(ALPHA4+ALPHA3)+Arm21*sind(ALPHA4+ALPHA3+ALPHA2);
z = height;
x = cosd(ALPHA5).*longdist;
y = sind(ALPHA5).*longdist;
%plot3(x(:),y(:),z(:),'.')
%axis equal
%calculate distal line segment
firstArmZ2 = Arm43*sind(ALPHA4);
firstArmX2 = cosd(ALPHA5).*(Arm43*cosd(ALPHA4));
firstArmY2 = sind(ALPHA5).*(Arm43*cosd(ALPHA4));
secondArmZ2 = Arm43*sind(ALPHA4)+Arm32*sind(ALPHA4+ALPHA3);
secondArmX2 = cosd(ALPHA5).*(Arm43*cosd(ALPHA4)+Arm32*cosd(ALPHA4+ALPHA3));
secondArmY2 = sind(ALPHA5).*(Arm43*cosd(ALPHA4)+Arm32*cosd(ALPHA4+ALPHA3));
thirdArmZ2 = height;
thirdArmX2 = x;
thirdArmY2 = y;
figure(2)
hold on
for tmp1 = 1:length(firstArmZ2(:))
plot3([0 firstArmX2(tmp1)],[0 firstArmY2(tmp1)],[0 firstArmZ2(tmp1)],'k-')
plot3([firstArmX2(tmp1) secondArmX2(tmp1)],...
[firstArmY2(tmp1) secondArmY2(tmp1)],...
[firstArmZ2(tmp1) secondArmZ2(tmp1)],'b-')
plot3([secondArmX2(tmp1) thirdArmX2(tmp1)],...
[secondArmY2(tmp1) thirdArmY2(tmp1)],...
[secondArmZ2(tmp1) thirdArmZ2(tmp1)],'color',[0.5 0.5 0.5])
end
% create a box
x1 = 10;
x2 = 20;
x3 = 20;
x4 = 10;
y1 = -15;
y2 = -15;
y3 = 15;
y4 = 15;
z = 1;
plot3( [x1 x2 x3 x4 x1], [y1 y2 y3 y4 y1], [z z z z z])
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started