Compound quaternion Matlab -error

6 views (last 30 days)
Mark S
Mark S on 6 Dec 2021
Edited: Mark S on 8 Jan 2022
Hi, I have written a Matlab code where i can compound two relative poses by Translation-Vecot-Unit-Quaternion-Pair
But I get an error and I did not know why. The error message is:
Output argument "t_q_pair_A_C" (and possibly others) not assigned a value in the execution with "test2>t_q_pair_compound"
function.
Error in test2 (line 40)
q_pair_A_C = t_q_pair_compound(t_q_pair_A_B,t_q_pair_B_C);
Can anybody give me a hint why I get this error message. Thank you :)
Here is my code:
.

Accepted Answer

KSSV
KSSV on 6 Dec 2021
In this function:
function t_q_pair_A_C = t_q_pair_compound(t_q_pair_A_B,t_q_pair_B_C)
% Extract Translation Vectors
t_A_B = t_q_pair_A_B.t;
t_B_C = t_q_pair_B_C.t;
% Extract Unit Quaternion
q_A_B = t_q_pair_A_B.q;
q_B_C = t_q_pair_B_C.q;
%Compound Translation Vectors
t_A_C_pure_q = q_pure(t_A_B) + q_A_B * q_pure(t_B_C) * q_inv(q_A_B);
[~, v_1,v_2, v_3] = parts(t_A_C_pure_q);
t_A_C = [v_1;
v_2;
v_3];
end
You need to assign the output. May be you want:
function t_q_pair_A_C = t_q_pair_compound(t_q_pair_A_B,t_q_pair_B_C)
% Extract Translation Vectors
t_A_B = t_q_pair_A_B.t;
t_B_C = t_q_pair_B_C.t;
% Extract Unit Quaternion
q_A_B = t_q_pair_A_B.q;
q_B_C = t_q_pair_B_C.q;
%Compound Translation Vectors
t_A_C_pure_q = q_pure(t_A_B) + q_A_B * q_pure(t_B_C) * q_inv(q_A_B);
[~, v_1,v_2, v_3] = parts(t_A_C_pure_q);
t_q_pair_A_C = [v_1;
v_2;
v_3];
end
  3 Comments
KSSV
KSSV on 6 Dec 2021
Thanks is accepting/ voting the answer. :)
KSSV
KSSV on 6 Dec 2021
You are using a different variable name for that. This line:
q_pair_A_C = t_q_pair_compound(t_q_pair_A_B,t_q_pair_B_C);
should be:
t_q_pair_A_C = t_q_pair_compound(t_q_pair_A_B,t_q_pair_B_C);

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!