1 |
|
|
// |
2 |
|
|
// Copyright (c) 2017-2019 CNRS INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#ifndef __pinocchio_force_ref_hpp__ |
6 |
|
|
#define __pinocchio_force_ref_hpp__ |
7 |
|
|
|
8 |
|
|
namespace pinocchio |
9 |
|
|
{ |
10 |
|
|
|
11 |
|
|
template<typename Vector6ArgType> |
12 |
|
|
struct traits< ForceRef<Vector6ArgType> > |
13 |
|
|
{ |
14 |
|
|
typedef typename Vector6ArgType::Scalar Scalar; |
15 |
|
|
typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(Vector6ArgType) Vector6; |
16 |
|
|
enum { |
17 |
|
|
LINEAR = 0, |
18 |
|
|
ANGULAR = 3, |
19 |
|
|
Options = Vector6::Options |
20 |
|
|
}; |
21 |
|
|
typedef Eigen::Matrix<Scalar,3,1,Options> Vector3; |
22 |
|
|
typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4; |
23 |
|
|
typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6; |
24 |
|
|
typedef Matrix6 ActionMatrixType; |
25 |
|
|
typedef Matrix4 HomogeneousMatrixType; |
26 |
|
|
typedef typename Vector6ArgType::template FixedSegmentReturnType<3>::Type LinearType; |
27 |
|
|
typedef typename Vector6ArgType::template FixedSegmentReturnType<3>::Type AngularType; |
28 |
|
|
typedef typename Vector6ArgType::template ConstFixedSegmentReturnType<3>::Type ConstLinearType; |
29 |
|
|
typedef typename Vector6ArgType::template ConstFixedSegmentReturnType<3>::Type ConstAngularType; |
30 |
|
|
typedef ForceTpl<Scalar,Options> ForcePlain; |
31 |
|
|
typedef typename PINOCCHIO_EIGEN_REF_TYPE(Vector6ArgType) DataRefType; |
32 |
|
|
typedef DataRefType ToVectorReturnType; |
33 |
|
|
typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6ArgType) ConstDataRefType; |
34 |
|
|
typedef ConstDataRefType ToVectorConstReturnType; |
35 |
|
|
typedef ForceRef<Vector6ArgType> ForceRefType; |
36 |
|
|
|
37 |
|
|
}; // traits ForceRef |
38 |
|
|
|
39 |
|
|
template<typename Vector6ArgType> |
40 |
|
|
struct SE3GroupAction< ForceRef<Vector6ArgType> > |
41 |
|
|
{ |
42 |
|
|
typedef typename traits< ForceRef<Vector6ArgType> >::ForcePlain ReturnType; |
43 |
|
|
}; |
44 |
|
|
|
45 |
|
|
template<typename Vector6ArgType, typename MotionDerived> |
46 |
|
|
struct MotionAlgebraAction< ForceRef<Vector6ArgType>, MotionDerived > |
47 |
|
|
{ |
48 |
|
|
typedef typename traits< ForceRef<Vector6ArgType> >::ForcePlain ReturnType; |
49 |
|
|
}; |
50 |
|
|
|
51 |
|
|
template<typename Vector6ArgType> |
52 |
|
|
class ForceRef : public ForceDense< ForceRef<Vector6ArgType> > |
53 |
|
|
{ |
54 |
|
|
public: |
55 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
56 |
|
|
typedef ForceDense<ForceRef> Base; |
57 |
|
|
typedef typename traits<ForceRef>::DataRefType DataRefType; |
58 |
|
|
FORCE_TYPEDEF_TPL(ForceRef); |
59 |
|
|
|
60 |
|
|
using Base::operator=; |
61 |
|
|
using Base::operator==; |
62 |
|
|
using Base::operator!=; |
63 |
|
|
|
64 |
|
|
/// \brief Default constructor from a 6 dimensional vector. |
65 |
|
110803 |
ForceRef(typename PINOCCHIO_EIGEN_REF_TYPE(Vector6ArgType) f_like) |
66 |
|
110803 |
: m_ref(f_like) |
67 |
|
|
{ |
68 |
|
|
EIGEN_STATIC_ASSERT(Vector6ArgType::ColsAtCompileTime == 1, |
69 |
|
|
YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX); |
70 |
✗✓ |
110803 |
assert(f_like.size() == 6); |
71 |
|
110803 |
} |
72 |
|
|
|
73 |
|
|
/// \brief Copy constructor from another ForceRef. |
74 |
|
|
ForceRef(const ForceRef & other) |
75 |
|
|
: m_ref(other.m_ref) |
76 |
|
|
{} |
77 |
|
|
|
78 |
|
|
ToVectorConstReturnType toVector_impl() const { return m_ref; } |
79 |
|
|
ToVectorReturnType toVector_impl() { return m_ref; } |
80 |
|
|
|
81 |
|
|
// Getters |
82 |
|
416 |
ConstAngularType angular_impl() const { return ConstAngularType(m_ref.derived(),ANGULAR); } |
83 |
|
814 |
ConstLinearType linear_impl() const { return ConstLinearType(m_ref.derived(),LINEAR); } |
84 |
|
155268 |
AngularType angular_impl() { return m_ref.template segment<3> (ANGULAR); } |
85 |
|
78160 |
LinearType linear_impl() { return m_ref.template segment<3> (LINEAR); } |
86 |
|
|
|
87 |
|
|
template<typename V3> |
88 |
|
|
void angular_impl(const Eigen::MatrixBase<V3> & w) |
89 |
|
|
{ |
90 |
|
|
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3,3); |
91 |
|
|
angular_impl()=w; |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
template<typename V3> |
95 |
|
|
void linear_impl(const Eigen::MatrixBase<V3> & v) |
96 |
|
|
{ |
97 |
|
|
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(V3,3); |
98 |
|
|
linear_impl()=v; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
2 |
ForceRef & ref() { return *this; } |
102 |
|
|
|
103 |
|
|
protected: |
104 |
|
|
DataRefType m_ref; |
105 |
|
|
|
106 |
|
|
}; // class ForceRef<Vector6Like> |
107 |
|
|
|
108 |
|
|
template<typename Vector6ArgType> |
109 |
|
|
struct traits< ForceRef<const Vector6ArgType> > |
110 |
|
|
{ |
111 |
|
|
typedef typename Vector6ArgType::Scalar Scalar; |
112 |
|
|
typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(Vector6ArgType) Vector6; |
113 |
|
|
enum { |
114 |
|
|
LINEAR = 0, |
115 |
|
|
ANGULAR = 3, |
116 |
|
|
Options = Vector6::Options |
117 |
|
|
}; |
118 |
|
|
typedef Eigen::Matrix<Scalar,3,1,Options> Vector3; |
119 |
|
|
typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6; |
120 |
|
|
typedef Matrix6 ActionMatrixType; |
121 |
|
|
typedef typename Vector6ArgType::template ConstFixedSegmentReturnType<3>::Type ConstLinearType; |
122 |
|
|
typedef typename Vector6ArgType::template ConstFixedSegmentReturnType<3>::Type ConstAngularType; |
123 |
|
|
typedef ConstLinearType LinearType; |
124 |
|
|
typedef ConstAngularType AngularType; |
125 |
|
|
typedef ForceTpl<Scalar,Options> ForcePlain; |
126 |
|
|
typedef ForcePlain PlainReturnType; |
127 |
|
|
typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6ArgType) ConstDataRefType; |
128 |
|
|
typedef ConstDataRefType ToVectorConstReturnType; |
129 |
|
|
typedef ConstDataRefType DataRefType; |
130 |
|
|
typedef DataRefType ToVectorReturnType; |
131 |
|
|
typedef ForceRef<const Vector6ArgType> ForceRefType; |
132 |
|
|
|
133 |
|
|
}; // traits ForceRef<const Vector6ArgType> |
134 |
|
|
|
135 |
|
|
template<typename Vector6ArgType> |
136 |
|
|
class ForceRef<const Vector6ArgType> |
137 |
|
|
: public ForceDense< ForceRef<const Vector6ArgType> > |
138 |
|
|
{ |
139 |
|
|
public: |
140 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
141 |
|
|
typedef ForceDense<ForceRef> Base; |
142 |
|
|
typedef typename traits<ForceRef>::DataRefType DataRefType; |
143 |
|
|
FORCE_TYPEDEF_TPL(ForceRef); |
144 |
|
|
|
145 |
|
12922 |
ForceRef(typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6ArgType) f_like) |
146 |
|
12922 |
: m_ref(f_like) |
147 |
|
|
{ |
148 |
|
|
EIGEN_STATIC_ASSERT(Vector6ArgType::ColsAtCompileTime == 1, |
149 |
|
|
YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX); |
150 |
✗✓ |
12922 |
assert(f_like.size() == 6); |
151 |
|
12922 |
} |
152 |
|
|
|
153 |
|
|
ToVectorConstReturnType toVector_impl() const { return m_ref; } |
154 |
|
|
|
155 |
|
|
// Getters |
156 |
|
12922 |
ConstAngularType angular_impl() const { return ConstAngularType(m_ref.derived(),ANGULAR); } |
157 |
|
8659 |
ConstLinearType linear_impl() const { return ConstLinearType(m_ref.derived(),LINEAR); } |
158 |
|
|
|
159 |
|
|
const ForceRef & ref() const { return *this; } |
160 |
|
|
|
161 |
|
|
protected: |
162 |
|
|
DataRefType m_ref; |
163 |
|
|
|
164 |
|
|
}; // class ForceRef<Vector6Like> |
165 |
|
|
|
166 |
|
|
} // namespace pinocchio |
167 |
|
|
|
168 |
|
|
#endif // ifndef __pinocchio_force_ref_hpp__ |