Closed willat343 closed 3 months ago
We did not implement the Lie bracket in manif. But I agree this could be a valuable tool, and it should be easy.
@artivis ?
Regarding the formulas, if I am not wrong the Lie bracket can be computed as [a,b] = a^ b^ - b^ a^
for all matrix Lie groups. Then, for some groups perhaps there exist simplified forms. The result is an element of the Lie Algebra. In manif, this element could be represented back into the Cartesian tangent space:
[ a, b ]v = (a^ b^ - b^ a^)v
where v
is the vee operator, so we would have the general implementation as
LieGroupTangent a, b;
LieGroupTangent ab_bracket = ( a.hat() * b.hat() - b.hat() * a.hat() ).vee();
I am not fully sure of what I wrote here. If you can confirm this, then this would be possibly added to manif.
The infos above are confirmed here
and here
"The standard Lie bracket for Lie algebras of matrix Lie groups is given by [A, B] = AB − BA."
which can be found here:
http://www.math.uchicago.edu/~may/VIGRE/VIGRE2010/REUPapers/Turzillo.pdf
Yes @joansola that seems right to me. I didn't realise that before, and i can use ( a.hat() * b.hat() - b.hat() * a.hat() ).vee()
in the meantime for my application. I've had a chance to skim a couple textbooks (e.g. Barfoot's State Estimation for Robotics) and I believe this applies for matrix lie groups.
For reference, Sophus implements this as a static function in each lie group class, taking A and B as arguments and returning the simplified form of [A, B] for that group. I don't see the general commutator implementation above, perhaps because they don't need it.
manif uses CRTP rather than virtual polymorphism, so i'm not sure off the top of my head what the best implementation would be. Something equivalent to the general commutator in lie_group_base.h (or tangent_base.h) and simplified implmentations in each derived class.
For all immplementation issues, @artivis is the man :-) but yes, it seems that in the Tangent base class we could add this implementation, it would become immediately available to all Tangent classes.
One additional note is that it would be convenient to have a lie bracket function on the lie algebra elements themselves, which would avoid recomputation / unnecessary mapping to/from the tangent vector in my case. Perhaps this could be an overload, or a different function. For example:
LieGroupTangent lie_bracket(const LieGroupTangent::LieAlg& A, const LieGroupTangent::LieAlg& B) {
return (A * B - B * A).vee();
}
LieGroupTangent lie_bracket(const LieGroupTangent& a, const LieGroupTangent& b) {
return lie_bracket(a.hat(), b.hat());
}
Implementation of course will differ, but this is the idea.
Hello there,
This feature is indeed missing and would be a nice addition. However I'm not sure what the syntax would be at the moment. Let me play with it a little and I'll come back with a proposal.
One key issue is: we do not have a class for the LieAlgebra
space apart from the TangentBase::LieAlg
type, and so the vee()
operator is missing in manif. I wonder whether it can be added to the TangentBase
class, with an API like so:
static TangentBase vee( TangentBase::LieAlg _v_hat)
{
TangentBase v;
// build v from _v_hat
return v;
}
or even from the constructor, with someting like
TangentBase::TangentBase(TangentBase::LieAlg _v_hat)
{
// build v from _v_hat
coeffs() = v;
}
An additional note is that the lie bracket also equals $[X, Y] = adj(X)Y = XY - YX$. where $adj$ is the small adjoint. See section 10.2.6 equation 10.37 of "Stochastic Models, Information Theory, and Lie Groups, Vol 2".
I thought I would point this out since the small adjoint operation is already defined in code, but it may not help at all.
Is there an update regarding this request? I'm refactoring code here, and I would like to get rid of our definitions of the Lie-bracket operations outside of manif. If it is still unclear how this should look like, at least the .vee()
operator would be nice to have to allow for a single generic expression for the Lie-bracket operation for all manif types. Perhaps Eigen's expression templates would even be able to go a long way in optimizing these (e.g., Rn commutators always being zero).
I it helps, I could open a PR for the .vee()
operators.
Perhaps the lie bracket could be implemented something like:
TangentBase::LieAlg TangentBase::lieBracket(TangentBase rhs)
{
return TangentBase(smallAdj() * rhs.coeffs()).hat();
}
In equation form, this is $(\text{adj}(l^{\wedge}) r)^{\wedge}$, which I'm pretty sure should be exactly $[l^{\wedge}, r^{\wedge}]$.
Potentially this could be specialised for each type to avoid computation (e.g. Rn commutators always being zero as @nielsvd said).
Hi there, sorry for not coming back to this earlier. I appreciate all the comments and suggestions, they're really helpful. I'm currently on vacation but I should have some free time to look at implementing the bracket once back and before the routine kicks back in :+1:
Hi @willat343, @nielsvd, the bracket is implemented in #300. If you could provide some feedback as to wether this works for you that would be much appreciated :)
Sorry for the delay. Works great for me. Same for the vee operator in the other PR.
Compared (numerically) against my versions and got the same results (tested only on SO(2), SO(3), SE(2), SE(3)). Will happily deprecate my own functions and use the 0.0.5 release, thanks for the change.
I can't seem to find the Lie Bracket (sometimes called commutator) operation in any of the code, documentation or issues and wondered if this exists yet in manif, perhaps under a different name?
This is quite a hard blocker for my application (Manif with ceres, where i need the lie bracket operator in my computation).
If $A$ is a Lie algebra, then the lie bracket is is a mapping of form $[\cdot, \cdot]: A \times A \rightarrow A$. I noticed Sophus has a function
Tangent lieBracket(Tangent const& a, Tangent const& b)
which performs this operation with tangents instead.As far as I know the lie bracket operation is unique to each lie algebra, so its not really something that is easy to implement in my code (I template for different lie groups) but would belong in manif. Most of the Lie brackets for common groups are not difficult to compute. Off the top of my head:
Is this something you would consider implementing, or perhaps already exists that I haven't found?