GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/pinocchio/multibody/liegroup/liegroup-generic.hpp Lines: 12 15 80.0 %
Date: 2024-04-26 13:14:21 Branches: 1 2 50.0 %

Line Branch Exec Source
1
//
2
// Copyright (c) 2018 CNRS
3
//
4
5
#ifndef __pinocchio_lie_group_generic_hpp__
6
#define __pinocchio_lie_group_generic_hpp__
7
8
#include "pinocchio/multibody/liegroup/liegroup-base.hpp"
9
#include "pinocchio/multibody/liegroup/liegroup-variant-visitors.hpp"
10
11
namespace pinocchio
12
{
13
  template<typename LieGroupCollection> struct LieGroupGenericTpl;
14
15
  template<typename LieGroupCollection>
16
  struct traits< LieGroupGenericTpl<LieGroupCollection> >
17
  {
18
    typedef typename LieGroupCollection::Scalar Scalar;
19
    enum {
20
      Options = LieGroupCollection::Options,
21
      NQ = Eigen::Dynamic,
22
      NV = Eigen::Dynamic
23
    };
24
  };
25
26
  template<typename LieGroupCollection>
27
  struct LieGroupGenericTpl
28
  : LieGroupBase< LieGroupGenericTpl<LieGroupCollection> >, LieGroupCollection::LieGroupVariant
29
  {
30
    typedef typename LieGroupCollection::LieGroupVariant Base;
31
    typedef typename LieGroupCollection::LieGroupVariant LieGroupVariant;
32
33
    typedef typename LieGroupCollection::Scalar Scalar;
34
    enum { Options = LieGroupCollection::Options };
35
36
    template<typename LieGroupDerived>
37
60
    LieGroupGenericTpl(const LieGroupBase<LieGroupDerived> & lg_base)
38
60
    : Base(lg_base.derived())
39
60
    {}
40
41
    template<typename LieGroup>
42
    LieGroupGenericTpl(const LieGroupVariant & lg_variant)
43
    : Base(lg_variant)
44
    {}
45
46
22
    LieGroupGenericTpl(const LieGroupGenericTpl & lg_generic) = default;
47
    LieGroupGenericTpl & operator=(const LieGroupGenericTpl & other) = default;
48
49
24
    const LieGroupVariant & toVariant() const
50
24
    { return static_cast<const LieGroupVariant &>(*this); }
51
52
    LieGroupVariant & toVariant()
53
    { return static_cast<LieGroupVariant &>(*this); }
54
55
12
    bool isEqual_impl (const LieGroupGenericTpl& other) const
56
    {
57
12
      return boost::apply_visitor(visitor::LieGroupEqual<Scalar, Options>(), toVariant(), other.toVariant());
58
    }
59
60
    int nq() const { return ::pinocchio::nq(*this); }
61
    int nv() const { return ::pinocchio::nv(*this); }
62
63
1
    bool operator== (const LieGroupGenericTpl& other) const
64
    {
65
1
      return isEqual_impl(other);
66
    }
67
68
1
    bool operator!= (const LieGroupGenericTpl& other) const
69
    {
70
1
      return this->isDifferent_impl(other);
71
    }
72
73
    std::string name() const
74
    {
75
      return LieGroupNameVisitor::run(*this);
76
    }
77
  };
78
79
}
80
81
#endif // ifndef __pinocchio_lie_group_generic_hpp__
82