Why Does dcm2angle Work Like This?
12 次查看(过去 30 天)
显示 更早的评论
Suppose I have a direction cosine matrix, brought to my attention by a colleague
C = round(angle2dcm(-pi/2,-pi/2,0,'ZYX'))
Extract the angles with @doc:dcm2angle (Aerospace Toolbox) using the Default option
[a1,a2,a3] = dcm2angle(C,'ZYX','Default');[a1,a2,a3]
Because the middle angle is -pi/2, the extracted angle triplets have multiple solutions, but the default result isn't one of them.
Sometime after R2019b and before or at R2022a, an additonal optional argument can be specified, though I could find nothing about this new argument in the release notes nor the bug fixes.
[a1,a2,a3] = dcm2angle(C,'ZYX','Robust');[a1,a2,a3]
Now we get a correct answer.
Trying with @doc:rotm2eul that's used in other toolboxes (Robotics, Navigation, UAV) we see that it returns a correct result without any optional arguments.
eul = rotm2eul(C.','ZYX')
round(angle2dcm(eul(1),eul(2),eul(3),'ZYX'))
@doc:dcm2angle with the Robust option actually computes two sets of angles, then computes the DCM with each set, and then compares the recomputed DCMs to the input DCM, and then returns the set of angles that result in a DCM that's closest to the input. @doc:rotm2eul uses a different approach altogether, though is limited to only three axes sequences.
To be sure, the Default option with @doc:dcm2angle is considerably faster than Robust, but Robust appears to take the same amout of time as @doc:rotm2eul
timeit(@() dcm2angle(repmat(C,1,1,1e5),'ZYX','Default'),3)
timeit(@() dcm2angle(repmat(C,1,1,1e5),'ZYX','Robust'),3)
timeit(@() rotm2eul(repmat(C.',1,1,1e5),'ZYX'),1)
Does anyone have a thought as to why dcm2angle is implemented as it is with Default and forces the user to use Robust? And why wouldn't that same reason apply to rotm2eul?
Once MathWorks realized that dcm2angle Default was returning incorrect results in some cases, why patch it with Robust and keep Default instead of just fixing the bug?
3 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadcopters and Drones 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!