Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit dual quaternion #165

Draft
wants to merge 6 commits into
base: devel
Choose a base branch
from
Draft

Add unit dual quaternion #165

wants to merge 6 commits into from

Conversation

artivis
Copy link
Owner

@artivis artivis commented Aug 18, 2020

This PR adds the unit dual quaternion group, currently called DHu.

note: I suspect there is a better name than DHu

Draft implementation:

Group

  • DHu::Random
  • DHu::Inverse
  • DHu::Compose
  • DHu::normalize
  • DHu::conjugate
  • DHu::conjugatedual
  • DHu::rotation
  • DHu::translation
  • DHu::isometry
  • DHu::adj
  • DHu::log
  • DHu::act
  • Jacobians
  • DHu::...

Tangent

  • DHuTangent::rjac
  • DHuTangent::ljac
  • DHuTangent::smallAdj
  • DHuTangent::hat
  • DHuTangent::exp
  • DHuTangent::...

Comes on top of #150.

Closes #164.

@artivis artivis self-assigned this Aug 18, 2020
@artivis artivis added the enhancement New feature or request label Aug 18, 2020
@artivis
Copy link
Owner Author

artivis commented Aug 18, 2020

Draft implementation (class layout and a few functions in b9f0460).

@codecov-commenter
Copy link

Codecov Report

Merging #165 into devel will decrease coverage by 0.83%.
The diff coverage is 92.19%.

@@            Coverage Diff             @@
##            devel     #165      +/-   ##
==========================================
- Coverage   98.23%   97.39%   -0.84%     
==========================================
  Files          37       43       +6     
  Lines        1130     1190      +60     
==========================================
+ Hits         1110     1159      +49     
- Misses         20       31      +11     

@joansola
Copy link
Collaborator

joansola commented Aug 18, 2020

We should start by exp. Did you find any suitable source of info? I don't have a very sharp mind lately and would prefer to copy-paste as much as possible from reputable sources, rather than develop from scratch (which is much more fun, funnily).

I guess after exp we'll be able to develop the adjoint. This is normally easy.

The trouble will be as always with J_l and J_r ....... I fear these.

Jacobians are easy once we have the blocks above. We can try to simplify the expressions resulting from the chain rule. Often we are luck with these simplifications.

@joansola
Copy link
Collaborator

Nice job BTW! how do you code so quickly? Did you create a template or script for new classes in manif?

Copy link
Collaborator

@joansola joansola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey just a couple comments. Please answer comment about normalize() as I am intrigued by this point.

* @brief Constructor given a translation and a unit quaternion.
* @param[in] t A translation vector.
* @param[in] q A unit quaternion.
* @throws manif::invalid_argument on un-normalized complex number.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

un-normalized *complex number --> un-normalized quaternion

Comment on lines +316 to +323
template <typename _Derived>
void DHuBase<_Derived>::normalize()
{
const Scalar n = coeffs().template head<4>().norm();
coeffs() /= n;
// real and dual parts are orthogonal
coeffs().template tail<4>() -= (coeffs().template head<4>().dot(coeffs().template tail<4>())) * coeffs().template head<4>();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not understand this part in the paper. What are we to normalize? The rotational quaternion (4 components) and then the translational quaternion by the same scaling (4 more components)? Or all the real+dual quaterninon (8 components)? Or both the real and dual normalized separately?

That is, at the end of normalize(), what should we have:

  1. | Real | = 1 and | Dual | = anything (just as in the code)
  2. | (Real,Dual) | = 1
  3. | Real | = 1 AND | Dual | = 1

??

Copy link
Owner Author

@artivis artivis Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this source the author defines 3 conjugates (Sec.5) and more specifically the second conjugate that "follows from the classical quaternion conjugation": σ∗ = p∗ + ϵq∗. Sec.6 states that "a dual quaternion is unit if σ ⊗ σ∗ = 1" which implies that the real part p must be a unit quaternion and the dual part p must be orthogonal to the real part p. So at the end of normalize() we should have:

4.a |Real| = 1
4.b Real . Dual = 0

These are the conditions I'm checking for at construction (see here). And I'm testing normalize() in this test which seems to pass.

Note that this 'second conjugate' is simply called conjugate() in the code and we have
inverse() { return conjugate(); }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the product in 4b defined? Is it regular quaternion product?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sec.6 Eq.21 of the aforementioned reference: p0q0 + p1q1 + p2q2 + p3q3 = 0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I see, so they are orthogonal as 4-vectors: p.tr * q = 0

@artivis
Copy link
Owner Author

artivis commented Aug 18, 2020

We should start by exp. Did you find any suitable source of info? I don't have a very sharp mind lately and would prefer to copy-paste as much as possible from reputable sources, rather than develop from scratch (which is much more fun, funnily).

No I haven't found yet a source for exp/log, I'll look for it specifically. Definitely agree on developing as little as possible from scratch. So far I relied on this source.

how do you code so quickly? Did you create a template or script for new classes in manif?

Ahah that's one of the many advantages of manif. Between the code standardization and the paper formalism more than half the job is done. I do not have a script, I simply copy an existing class (e.g. here SE3 and related) and do some renaming accordingly. I could make a script but I'm not sure it is worth it time-wise.

@joansola
Copy link
Collaborator

exp can be found in 5.1 here

@joansola
Copy link
Collaborator

log in 8.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interest in Unit Dual Quaternions?
3 participants