Matlab Coder fails generation for slerp() call with double quaternions

조회 수: 2 (최근 30일)
I am using MATLAB coder to generate code for following function.
function [D] = getInterpolatedTransforms(q0,t0,q1,t1,steps,correction)
D = zeros(4,4,steps);
for i = 0:1:steps-1
coeff = single(i/steps);
qt = slerp(q0,q1,coeff);
tt = [t0*(1-coeff)+t1*coeff,1]';
D(1:3,1:3,i+1) = (quat2rotm(qt))*correction;
D(1:4,4,i+1) = tt;
end
end
I get following error while generating code at the "check for issues" step
??? This assignment writes a 'single' value into a 'double' type. Code generation does
not support changing types through assignment. Check preceding assignments or input
type specifications for type mismatches.
Error in ==>> quaternioncg Line: 48 Column: 17
Code generation failed: View Error Report
??? This assignment writes a 'single' value into a 'double' type. Code generation does
not support changing types through assignment. Check preceding assignments or input
type specifications for type mismatches.
Error in ==>> quaternioncg Line: 48 Column: 17
Code generation failed: View Error Report
The location of the error is in Matlab internal file quaternioncg.m
Please help me reolve the issue. I am new to this tool.
  댓글 수: 1
James Tursa
James Tursa 2020년 11월 2일
Maybe you could tell us which line is generating the error?
Could you use double types instead? E.g.,
coeff = double(i/steps);

댓글을 달려면 로그인하십시오.

채택된 답변

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2020년 11월 2일
Solution 1 : Remove the single cast
function [D] = getInterpolatedTransforms(q0,t0,q1,t1,steps,correction)
D = zeros(4,4,steps);
for i = 0:1:steps-1
coeff = i/steps;
qt = slerp(q0,q1,coeff);
tt = [t0*(1-coeff)+t1*coeff,1]';
D(1:3,1:3,i+1) = (quat2rotm(qt))*correction;
D(1:4,4,i+1) = tt;
end
end
Solution 2: Make the input quaternion as single
>> a = quaternion(single([45,0,0]),'eulerd','ZYX','frame');
>> c = quaternion(single([-45,0,0]),'eulerd','ZYX','frame');
>> codegen getInterpolatedTransforms -args {a,1:3,c,3:5,10,0.5} -report

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by