Question
1. Divide the 30 and 45 into 100 steps. That is theta1 = 0:30/100:30; theta2 = 0:45/100:45; Observe the animation of the 2-link robot. Change
1. Divide the 30 and 45 into 100 steps. That is theta1 = 0:30/100:30; theta2 = 0:45/100:45;
Observe the animation of the 2-link robot. Change both angles of 1 and 2 to be 360. Modify the code to observe the whole movement.
framemax = 100; M=moviein(framemax); set(gcf,'Position',[100 100 640 480]);
for k = 1:100 T1=RobotConv(theta1(k), 0, 3, 0); T2=RobotConv(theta2(k), 0, 2, 0);
p0 = [0 0 0]; p1 = RobotPosition(T1); p2 = RobotPosition(T1*T2); figure(1) X = [p0(1) p1(1) p2(1)]; Y = [p0(2) p1(2) p2(2)]; plot(X,Y,'o-') axis([-1 8 -1 8]); grid M(k) = getframe(gcf); end
RobotConv.m
function T = RobotConv(theta,d,a,alpha)
rad = pi/180;
M_theta = [cos(theta*rad) -sin(theta*rad) 0 0;sin(theta*rad)
cos(theta*rad) 0 0;0 0 1 0;0 0 0 1];
M_d = [1 0 0 0;0 1 0 0;0 0 1 d;0 0 0 1];
M_a = [1 0 0 a;0 1 0 0;0 0 1 0;0 0 0 1];
M_alpha = [1 0 0 0;0 cos(alpha*rad) -sin(alpha*rad) 0;0 sin(alpha*rad)
cos(alpha*rad) 0; 0 0 0 1];
T=M_theta*M_d*M_a*M_alpha;
RobotPosition.m
function P = RobotPosition(T)
x = T(1,4);
y = T(2,4);
z = T(3,4);
P = [x y 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