pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
force-base.hpp
1//
2// Copyright (c) 2015-2020 CNRS INRIA
3// Copyright (c) 2016 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4//
5
6#ifndef __pinocchio_spatial_force_base_hpp__
7#define __pinocchio_spatial_force_base_hpp__
8
9namespace pinocchio
10{
22 template<class Derived>
23 class ForceBase : NumericalBase<Derived>
24 {
25 public:
26 FORCE_TYPEDEF_TPL(Derived);
27
28 Derived & derived()
29 {
30 return *static_cast<Derived *>(this);
31 }
32 const Derived & derived() const
33 {
34 return *static_cast<const Derived *>(this);
35 }
37 Derived & const_cast_derived() const
38 {
39 return *const_cast<Derived *>(&derived());
40 }
41
47 ConstAngularType angular() const
48 {
49 return derived().angular_impl();
50 }
51
57 ConstLinearType linear() const
58 {
59 return derived().linear_impl();
60 }
61
63 AngularType angular()
64 {
65 return derived().angular_impl();
66 }
67
69 LinearType linear()
70 {
71 return derived().linear_impl();
72 }
73
81 template<typename V3Like>
82 void angular(const Eigen::MatrixBase<V3Like> & n)
83 {
84 derived().angular_impl(n.derived());
85 }
86
94 template<typename V3Like>
95 void linear(const Eigen::MatrixBase<V3Like> & f)
96 {
97 derived().linear_impl(f.derived());
98 }
99
108 ToVectorConstReturnType toVector() const
109 {
110 return derived().toVector_impl();
111 }
112
114 ToVectorReturnType toVector()
115 {
116 return derived().toVector_impl();
117 }
118
119 /*
120 * @brief C-style cast operator
121 * \copydoc ForceBase::toVector
122 */
123 operator Vector6() const
124 {
125 return toVector();
126 }
127
132 template<typename F2>
133 bool operator==(const ForceBase<F2> & other) const
134 {
135 return derived().isEqual_impl(other.derived());
136 }
137
140 template<typename F2>
141 bool operator!=(const ForceBase<F2> & other) const
142 {
143 return !(derived() == other.derived());
144 }
145
149 const Derived & other,
150 const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
151 {
152 return derived().isApprox_impl(other, prec);
153 }
154
158 bool isZero(const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
159 {
160 return derived().isZero_impl(prec);
161 }
162
167 {
168 return derived().setFrom(other.derived());
169 }
170
176 {
177 return derived().__pequ__(phi.derived());
178 }
179
185 {
186 return derived().__mequ__(phi.derived());
187 }
188
191 Derived operator+(const ForceBase<Derived> & phi) const
192 {
193 return derived().__plus__(phi.derived());
194 }
195
198 template<typename OtherScalar>
199 ForcePlain operator*(const OtherScalar & alpha) const
200 {
201 return derived().__mult__(alpha);
202 }
203
206 template<typename OtherScalar>
207 ForcePlain operator/(const OtherScalar & alpha) const
208 {
209 return derived().__div__(alpha);
210 }
211
214 Derived operator-() const
215 {
216 return derived().__opposite__();
217 }
218
221 Derived operator-(const ForceBase<Derived> & phi) const
222 {
223 return derived().__minus__(phi.derived());
224 }
225
228 template<typename MotionDerived>
229 Scalar dot(const MotionDense<MotionDerived> & m) const
230 {
231 return derived().dot(m.derived());
232 }
233
246 template<typename S2, int O2>
247 typename SE3GroupAction<Derived>::ReturnType se3Action(const SE3Tpl<S2, O2> & m) const
248 {
249 return derived().se3Action_impl(m);
250 }
251
264 template<typename S2, int O2>
265 typename SE3GroupAction<Derived>::ReturnType se3ActionInverse(const SE3Tpl<S2, O2> & m) const
266 {
267 return derived().se3ActionInverse_impl(m);
268 }
269
270 template<typename M1>
271 typename MotionAlgebraAction<Derived, M1>::ReturnType
272 motionAction(const MotionDense<M1> & v) const
273 {
274 return derived().motionAction(v.derived());
275 }
276
277 void disp(std::ostream & os) const
278 {
279 derived().disp_impl(os);
280 }
281 friend std::ostream & operator<<(std::ostream & os, const ForceBase<Derived> & X)
282 {
283 X.disp(os);
284 return os;
285 }
286
287 }; // class ForceBase
288
289} // namespace pinocchio
290
291#endif // ifndef __pinocchio_spatial_force_base_hpp__
Base interface for forces representation.
AngularType angular()
Return the angular part of the force vector.
bool operator!=(const ForceBase< F2 > &other) const
bool operator==(const ForceBase< F2 > &other) const
Derived & operator-=(const ForceBase< Derived > &phi)
Replaces *this by *this - other.
Derived & operator=(const ForceBase< Derived > &other)
Copies the Derived Force into *this.
SE3GroupAction< Derived >::ReturnType se3Action(const SE3Tpl< S2, O2 > &m) const
Transform from A to B coordinates the Force represented by *this such that.
void angular(const Eigen::MatrixBase< V3Like > &n)
Set the angular part of the force vector.
Derived operator-() const
bool isApprox(const Derived &other, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
Derived & operator+=(const ForceBase< Derived > &phi)
Replaces *this by *this + other.
ConstAngularType angular() const
Return the angular part of the force vector.
void linear(const Eigen::MatrixBase< V3Like > &f)
Set the linear part of the force vector.
Derived operator-(const ForceBase< Derived > &phi) const
ConstLinearType linear() const
Return the linear part of the force vector.
bool isZero(const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
LinearType linear()
Return the linear part of the force vector.
ForcePlain operator*(const OtherScalar &alpha) const
ToVectorReturnType toVector()
Return the force as an Eigen vector.
Derived operator+(const ForceBase< Derived > &phi) const
SE3GroupAction< Derived >::ReturnType se3ActionInverse(const SE3Tpl< S2, O2 > &m) const
Transform from B to A coordinates the Force represented by *this such that.
ToVectorConstReturnType toVector() const
Return the force as an Eigen vector.
ForcePlain operator/(const OtherScalar &alpha) const
Scalar dot(const MotionDense< MotionDerived > &m) const
Main pinocchio namespace.
Definition treeview.dox:11