Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
    조회 수: 8 (최근 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
참고 항목
카테고리
				Help Center 및 File Exchange에서 Symbolic Variables, Expressions, Functions, and Settings에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!