Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
% 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 Kommentare
Star Strider
am 20 Jun. 2020
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]
Antworten (1)
Devineni Aslesha
am 24 Jul. 2020
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 Kommentare
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!