No matter the NOA matrix I enter, the result I receive is "empty double column vector" and I want to receive a numerical value.

1 Ansicht (letzte 30 Tage)
I have the following code. The end goal of this is to be able to set the overall rotation/placement matrix equal to a numberical matrix. I want to solve for the angles in the overall matrix and get an answer in degrees. If there is more than one solution, I want to be able to see both solutions.
The use for this is solving/checking RPY end effector robots when given the NOA matrix to start.
The values for the NOA matrix would be interchangable, but the ones within there currently do solve a matrix
% Use Symbolic Math Toolbox
syms phi_a phi_o phi_n
%Rotation in a
T_a = [cosd(phi_a), -sind(phi_a), 0, 0;
sind(phi_a), cosd(phi_a), 0, 0;
0,0,1,0;
0,0,0,1]
%Rotation in o
T_o = [cosd(phi_o), 0, sind(phi_o), 0;
0, 1, 0, 0
-sind(phi_o), 0, cosd(phi_o), 0;
0, 0, 0, 1]
%Rotation in n
T_n = [1, 0, 0, 0;
0, cosd(phi_n), -sind(phi_n), 0;
0, sind(phi_n), cosd(phi_n), 0;
0, 0, 0, 1]
%Overall Matrix
RPY = T_a * T_o * T_n
%Final Solution Matrix
NOA = [.7849, -0.1478, .6018, 5;
0.4532, .7992, -0.3948, 8;
-0.4226, 0.5826, 0.6943, 2;
0,0,0,1]
% Solve for the angles phi_a, phi_o, and phi_n
solutions = solve(NOA == RPY, [phi_a, phi_o, phi_n]);
% Extract solutions
phi_a_solution = double(solutions.phi_a)
phi_o_solution = double(solutions.phi_o)
phi_n_solution = double(solutions.phi_n)

Antworten (2)

Steven Lord
Steven Lord am 17 Sep. 2024
Let's look at the last column of your two matrices.
syms phi_a phi_o phi_n
%Rotation in a
T_a = [cosd(phi_a), -sind(phi_a), 0, 0;
sind(phi_a), cosd(phi_a), 0, 0;
0,0,1,0;
0,0,0,1];
%Rotation in o
T_o = [cosd(phi_o), 0, sind(phi_o), 0;
0, 1, 0, 0
-sind(phi_o), 0, cosd(phi_o), 0;
0, 0, 0, 1];
%Rotation in n
T_n = [1, 0, 0, 0;
0, cosd(phi_n), -sind(phi_n), 0;
0, sind(phi_n), cosd(phi_n), 0;
0, 0, 0, 1];
%Overall Matrix
RPY = T_a * T_o * T_n;
%Final Solution Matrix
NOA = [.7849, -0.1478, .6018, 5;
0.4532, .7992, -0.3948, 8;
-0.4226, 0.5826, 0.6943, 2;
0,0,0,1];
lastColumns = [RPY(:, end), NOA(:, end)]
Are there any values of your variables that can possibly make 0 equal to 5 (the first elements of the two columns), equal to 8 (the second), or equal to 2 (the third)?
  1 Kommentar
Umar
Umar am 19 Sep. 2024
Hi @ Steven Lord,
Great observation. You are correct about the last column of the RPY matrix, which is derived from the rotation matrices, will always be [0; 0; 0; 1], indicating no translation. Conversely, the last column of the NOA matrix contains values [5; 8; 2; 1], which signifies specific translations in the x, y, and z directions. Basically, it is a discrepancy which implies that there is no possible combination of the rotation angles (phi_a, phi_o, phi_n) that can equate the last column of RPY to that of NOA, as the translation components are fundamentally different. Therefore, the equality NOA == RPY cannot hold true for the last column, confirming that the last column values in NOA cannot be achieved through the rotation matrices alone. So, in order for @ Alyssa Bloomfield resolving this discrepancy, she may need to separate the rotation and translation components in your calculations to make sure that the translation values are handled independently from the rotation angles.

Melden Sie sich an, um zu kommentieren.


Umar
Umar am 17 Sep. 2024

Hi @Alyssa Bloomfield,

You asked,”I want to solve for the angles in the overall matrix and get an answer in degrees. If there is more than one solution, I want to be able to see both solutions.”


please see my response to your comments below.

To achieve the desired functionality, you have to enhance the provided MATLAB code which will utilize the Symbolic Math Toolbox to define the rotation matrices for the angles of rotation about the axes and then solve for these angles based on the given numerical matrix (NOA). The final results will be printed in degrees, and will make sure that all possible solutions are displayed.Here is the updated MATLAB code:

% Use Symbolic Math Toolbox
syms phi_a phi_o phi_n
% Rotation matrix around the z-axis (T_a)
T_a = [cosd(phi_a), -sind(phi_a), 0, 0;
     sind(phi_a), cosd(phi_a), 0, 0;
     0, 0, 1, 0;
     0, 0, 0, 1];
% Rotation matrix around the y-axis (T_o)
T_o = [cosd(phi_o), 0, sind(phi_o), 0;
     0, 1, 0, 0;
     -sind(phi_o), 0, cosd(phi_o), 0;
     0, 0, 0, 1];
% Rotation matrix around the x-axis (T_n)
T_n = [1, 0, 0, 0;
     0, cosd(phi_n), -sind(phi_n), 0;
     0, sind(phi_n), cosd(phi_n), 0;
     0, 0, 0, 1];
% Overall Rotation Matrix (RPY)
RPY = T_a * T_o * T_n;
% Final Solution Matrix (NOA)
NOA = [.7849, -0.1478, .6018, 5;
     0.4532, .7992, -0.3948, 8; 
     -0.4226, 0.5826, 0.6943, 2; 
     0, 0, 0, 1];
% Solve for the angles phi_a, phi_o, and phi_n
solutions = solve(NOA == RPY, [phi_a, phi_o, phi_n]);
% Extract solutions and convert to degrees
phi_a_solution = double(solutions.phi_a);
phi_o_solution = double(solutions.phi_o);
phi_n_solution = double(solutions.phi_n);
% Display the solutions
disp('Solutions for the angles in degrees:');
disp('phi_a (rotation about z-axis):');
disp(rad2deg(phi_a_solution)); % Convert radians to degrees
disp('phi_o (rotation about y-axis):');
disp(rad2deg(phi_o_solution)); % Convert radians to degrees
disp('phi_n (rotation about x-axis):');
disp(rad2deg(phi_n_solution)); % Convert radians to degrees
% Check for multiple solutions
if length(phi_a_solution) > 1
  disp('Multiple solutions found for phi_a:');
  disp(rad2deg(phi_a_solution));
end
if length(phi_o_solution) > 1
  disp('Multiple solutions found for phi_o:');
  disp(rad2deg(phi_o_solution));
end
if length(phi_n_solution) > 1
  disp('Multiple solutions found for phi_n:');
  disp(rad2deg(phi_n_solution));
end

So, this updated code provides a comprehensive solution to the problem of determining the angles of rotation from a given numerical matrix as mentioned in your comments. Please see attached.

If you have further questions, please let me know.

  1 Kommentar
Umar
Umar am 18 Sep. 2024
Hi @Alyssa Bloomfield,
Please let us know if our answers resolved your problem. If you still facing issues, please let us know.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by