Direct Dynamics of Two-Link Manipulator
Hi,
I am unsuccesful in using a MATLAB function block in Simulink to model the direct dynamics of a two-link planar manipulator. The function takes the gear ratio (), 2×1 motor torque (), angular position ($v$) and angular velocity ($dot v$) and outputs the angular acceleration ($ddot v$). See below for my Simulink model.The torque step function has a step time of 0.1, initial value of [0;0]. final value of [15;10] and also a sample time of 0.1. = 10 is a constant. The first integrator has initial conditions [-pi/2,0] and the second has initial conditions of [0,0]. I am outputting the torque, joint velocity and the joint position to the workspace.
I am getting the correct vector for torque: $[tao_1, tao_2] = [0,0]$ at time 0 and $[tao_1, tao_2] = [15,10]$ after that. However the joint 1 position is decreasing from 0 to -15 and the joint 2 position is staying at 0. The joint 1 and 2 velocities are staying constant at the initial velocity of -pi/2,0. I have pasted my code that I have gone over numerous times so I doubt there is any issue there. I think the issue is more in the setup for the Simulink.
Was wondering if people can help pinpoint the problem and help lead me in the right direction.
function v_ddot = dynamics(n, t_m, v_dot, v)
%given constants
ml1 = 49; ml2 = 34;
a1 = 1; a2 = 1;
l1 = 0.5; l2 = 0.5;
Iyy_1 = 4.08; Iyy_2 = 2.83;
Im1 = 0.25; Im2 = 0.25;
b1 = 12; b2 = 12;
bm1 = 0.08; bm2 = 0.08;
g = 9.8;
%calculations for lumped parameters I1 and I2
I1 = Iyy_1 + ml1 * l1^2 + ml2 * a1^2;
I2 = Iyy_2 + ml2 * l2^2;
h = ml2*a1*l2;
%mass, centrifugal/coriolis, gravitational, friction vectors
M = [n^2*Im1 + I1 + I2 + 2*h*cos(v(2)), I2 + h*cos(v(2)); I2 + h*cos(v(2)), n^2*Im2 + I2];
V = h*sin(v(2))*[-2*v_dot(1)*v_dot(2) – v_dot(2)^2; v_dot(1)^2];
G = [(ml1*l1 + ml2*l2)*cos(v(1))*g + ml2*l2*cos(v(1)+v(2))*g; ml2*l2*cos(v(1)+v(2))*g];
F = [b1*v_dot(1) + n^2*bm1; b2*v_dot(2) + n^2*bm2*v_dot(2)];
%solving for the angualar accelerations
v_ddot = M (-V – G – F + t_m * n);
endHi,
I am unsuccesful in using a MATLAB function block in Simulink to model the direct dynamics of a two-link planar manipulator. The function takes the gear ratio (), 2×1 motor torque (), angular position ($v$) and angular velocity ($dot v$) and outputs the angular acceleration ($ddot v$). See below for my Simulink model.The torque step function has a step time of 0.1, initial value of [0;0]. final value of [15;10] and also a sample time of 0.1. = 10 is a constant. The first integrator has initial conditions [-pi/2,0] and the second has initial conditions of [0,0]. I am outputting the torque, joint velocity and the joint position to the workspace.
I am getting the correct vector for torque: $[tao_1, tao_2] = [0,0]$ at time 0 and $[tao_1, tao_2] = [15,10]$ after that. However the joint 1 position is decreasing from 0 to -15 and the joint 2 position is staying at 0. The joint 1 and 2 velocities are staying constant at the initial velocity of -pi/2,0. I have pasted my code that I have gone over numerous times so I doubt there is any issue there. I think the issue is more in the setup for the Simulink.
Was wondering if people can help pinpoint the problem and help lead me in the right direction.
function v_ddot = dynamics(n, t_m, v_dot, v)
%given constants
ml1 = 49; ml2 = 34;
a1 = 1; a2 = 1;
l1 = 0.5; l2 = 0.5;
Iyy_1 = 4.08; Iyy_2 = 2.83;
Im1 = 0.25; Im2 = 0.25;
b1 = 12; b2 = 12;
bm1 = 0.08; bm2 = 0.08;
g = 9.8;
%calculations for lumped parameters I1 and I2
I1 = Iyy_1 + ml1 * l1^2 + ml2 * a1^2;
I2 = Iyy_2 + ml2 * l2^2;
h = ml2*a1*l2;
%mass, centrifugal/coriolis, gravitational, friction vectors
M = [n^2*Im1 + I1 + I2 + 2*h*cos(v(2)), I2 + h*cos(v(2)); I2 + h*cos(v(2)), n^2*Im2 + I2];
V = h*sin(v(2))*[-2*v_dot(1)*v_dot(2) – v_dot(2)^2; v_dot(1)^2];
G = [(ml1*l1 + ml2*l2)*cos(v(1))*g + ml2*l2*cos(v(1)+v(2))*g; ml2*l2*cos(v(1)+v(2))*g];
F = [b1*v_dot(1) + n^2*bm1; b2*v_dot(2) + n^2*bm2*v_dot(2)];
%solving for the angualar accelerations
v_ddot = M (-V – G – F + t_m * n);
end Hi,
I am unsuccesful in using a MATLAB function block in Simulink to model the direct dynamics of a two-link planar manipulator. The function takes the gear ratio (), 2×1 motor torque (), angular position ($v$) and angular velocity ($dot v$) and outputs the angular acceleration ($ddot v$). See below for my Simulink model.The torque step function has a step time of 0.1, initial value of [0;0]. final value of [15;10] and also a sample time of 0.1. = 10 is a constant. The first integrator has initial conditions [-pi/2,0] and the second has initial conditions of [0,0]. I am outputting the torque, joint velocity and the joint position to the workspace.
I am getting the correct vector for torque: $[tao_1, tao_2] = [0,0]$ at time 0 and $[tao_1, tao_2] = [15,10]$ after that. However the joint 1 position is decreasing from 0 to -15 and the joint 2 position is staying at 0. The joint 1 and 2 velocities are staying constant at the initial velocity of -pi/2,0. I have pasted my code that I have gone over numerous times so I doubt there is any issue there. I think the issue is more in the setup for the Simulink.
Was wondering if people can help pinpoint the problem and help lead me in the right direction.
function v_ddot = dynamics(n, t_m, v_dot, v)
%given constants
ml1 = 49; ml2 = 34;
a1 = 1; a2 = 1;
l1 = 0.5; l2 = 0.5;
Iyy_1 = 4.08; Iyy_2 = 2.83;
Im1 = 0.25; Im2 = 0.25;
b1 = 12; b2 = 12;
bm1 = 0.08; bm2 = 0.08;
g = 9.8;
%calculations for lumped parameters I1 and I2
I1 = Iyy_1 + ml1 * l1^2 + ml2 * a1^2;
I2 = Iyy_2 + ml2 * l2^2;
h = ml2*a1*l2;
%mass, centrifugal/coriolis, gravitational, friction vectors
M = [n^2*Im1 + I1 + I2 + 2*h*cos(v(2)), I2 + h*cos(v(2)); I2 + h*cos(v(2)), n^2*Im2 + I2];
V = h*sin(v(2))*[-2*v_dot(1)*v_dot(2) – v_dot(2)^2; v_dot(1)^2];
G = [(ml1*l1 + ml2*l2)*cos(v(1))*g + ml2*l2*cos(v(1)+v(2))*g; ml2*l2*cos(v(1)+v(2))*g];
F = [b1*v_dot(1) + n^2*bm1; b2*v_dot(2) + n^2*bm2*v_dot(2)];
%solving for the angualar accelerations
v_ddot = M (-V – G – F + t_m * n);
end simulink MATLAB Answers — New Questions









