[Rotation] Swing & Twist Decomposition#367
Conversation
|
Hi @fagg , thank you for this contribution too! A few comments:
It would be really interesting to have at least one example that demonstrates one of these use cases. I'd prefer the joint limit use case, since this is most interesting to me, but it does not have to be this one. Would it be possible to add one example?
|
|
Hello @AlexanderFabisch,
Done.
I added a draft set of changes.
I have added two. One is simple plot - which shows the original rotation, it's decomposition into twist and swing, and it's composition from twist and swing. The more complex of the two attempts to demonstrate axis redundancy using this decomposition. What it shows is a robot end-effector holding a tool whose working axis is the body z-axis, where the tool is pointing towards a workpiece. It builds a nominal porientation (aim + arbitrary roll), decomposes it about the tool axis into swing (where the tool axis points) and twist (roll about the tool). We then visualize the sweep along the twist while holding the swing fixed. Effectively, what we generated is a set of end-effector orientations that keep the tool pointed at the workpiece - you could consider this a solution set for a task-space planner with twist being the only remaining free parameter.
I already had tried to make that clear in the comments - it seems I failed. The latest version here has beefed up language around those assumptions in the doc string. |
|
This looks really good. Thanks! I will test everything next week. |
| @@ -0,0 +1,78 @@ | |||
| """ | |||
| ========================== | |||
There was a problem hiding this comment.
Minor detail, but these ===s should have the same length as the title.
| @@ -0,0 +1,116 @@ | |||
| """ | |||
| ========================================= | |||
| * Ambiguities: double cover. | ||
|
|
||
| Swing-Twist Decomposition | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
~s should have same length as title
|
|
||
| .. math:: | ||
|
|
||
| \boldsymbol{q} = \boldsymbol{q}_{swing} \boldsymbol{q}_{twist}, |
There was a problem hiding this comment.
Could you use \text{swing} and \text{twist} here and in the docstrings?
| :include-source: | ||
|
|
||
| import numpy as np | ||
| from pytransform3d.rotations import ( |
There was a problem hiding this comment.
Could you also use black-like formatting here?
|
Had time to review already now. It's very well documented. I just have some comments on little details. This is a really good contribution, thanks! |
Adds two new functions to pytransform3d.rotations:
swing_twist_decomposition- splits a unit quaternion into a twist (rotation about a given axis) and a swing (rotation about an axis orthogonal to it), such thatq = q_swing . q_twist.swing_twist_composition- the inverse operation, for reconstruction of the original rotation from its swing and twist components.This decomposition is useful for enforcing joint limits, separating roll about a link axis from the remaining rotation about a symmetry axis. It follows Dobrowolski (2015), "Swing-twist decomposition in Clifford algebra" - https://arxiv.org/abs/1506.05481
Algorithmic details:
q_swing = q . q_twist^-1swing_twist_decomposition(q, axis)andswing_twist_decomposition(-q, axis)return the exact same twist quaternions and equivalent swings. Secondly, composition may cause a sign flip - you may get-qinstead ofq.Implementation details:
All cases and constraints described above are covered by unit tests.