Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
3 ビュー (過去 30 日間)
古いコメントを表示
% DH parameters using symbolic tool box
clear
clc
%%
syms theta1 theta2 theta3
R1 = [ cos(theta1), 0, sin(theta1), 0;
sin(theta1), 0, -cos(theta1), 0;
0, 1, 0, 0;
0, 0, 0, 1];
R2 =[ cos(theta2), -sin(theta2), 0, 0.1*cos(theta2);
sin(theta2), cos(theta2), 0, 0.1*sin(theta2);
0, 0, 1, 0;
0, 0, 0, 1];
R3 =[ cos(theta3), 0, sin(theta3), 0;
sin(theta3), 0, -cos(theta3), 0;
0, 1, 0, 0;
0, 0, 0, 1];
% Total Forward Matrix
A_03 = simplify(R1 * R2 * R3);
A_13 = R2 * R3;
%% inverse kinematic
Px = -0.135;
Py = -0.000;
Pz = -0.128;
A_03_ = A_03;
A_03_(1:3,4) = [Px Py Pz];
A_13_ = simplify(R1 \ A_03_);
A_23_ = simplify(R2 \ A_13_);
I = simplify(R3 \ A_23_);
%%
eq(1) = Px == A_03(1,4);
eq(2) = Py == A_03(2,4);
eq(3) = Pz == A_03(3,4);
eq(4) = A_13_(1,4) - R1(1,4) == 0 ;
eq(5) = A_13_(2,4) - R1(2,4) == 0 ;
eq(6) = A_13_(3,4) - R1(3,4) == 0 ;
eq(7) = A_23_(1,4) - R2(1,4) == 0 ;
eq(8) = A_23_(2,4) - R2(2,4) == 0 ;
eq(9) = A_23_(3,4) - R2(3,4) == 0 ;
eq(10) = I(1,4) == 0;
eq(11) = I(2,4) == 0;
eq(12) = I(3,4) == 0;
sol = solve(eq);
q(1:4,1) = double(sol.theta1);
q(1:4,2) = double(sol.theta2);
q(1:4,3) = double(sol.theta3);
I dont know why it keep sending me an error
Error in Inverse_kinematic (line 58)
q(1:4,1) = double(sol.theta1);
How should i change this:
sol =
struct with fields:
theta1: [0×1 sym]
theta2: [0×1 sym]
theta3: [0×1 sym]
2 件のコメント
Star Strider
2020 年 6 月 20 日
The reason is that it cannot solve your system:
sol =
struct with fields:
theta1: [0×1 sym]
theta2: [0×1 sym]
theta3: [0×1 sym]
回答 (1 件)
Devineni Aslesha
2020 年 7 月 24 日
The reason for showing 1x1 sym for theta1 is that they are declared as symbolic variables using syms theta1. However, 0x1 sym is for struct sol fields theta1,theta2 and theta3 as it cannot solve your system.
For more information, rfer the following link
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!