5 #ifndef __pinocchio_multibody_liegroup_vector_space_operation_hpp__
6 #define __pinocchio_multibody_liegroup_vector_space_operation_hpp__
8 #include "pinocchio/multibody/liegroup/liegroup-base.hpp"
11 #include <boost/integer/static_min_max.hpp>
15 template<
int Dim,
typename Scalar,
int Options = context::Options>
16 struct VectorSpaceOperationTpl;
18 template<
int Dim,
typename _Scalar,
int _Options>
21 typedef _Scalar Scalar;
30 template<
int Dim,
typename _Scalar,
int _Options>
32 :
public LieGroupBase<VectorSpaceOperationTpl<Dim, _Scalar, _Options>>
42 assert(size_.value() >= 0);
49 , size_(other.size_.value())
51 assert(size_.value() >= 0);
56 size_.setValue(other.size_.value());
57 assert(size_.value() >= 0);
70 ConfigVector_t neutral()
const
72 return ConfigVector_t::Zero(size_.value());
75 std::string name()
const
77 std::ostringstream oss;
82 template<
class ConfigL_t,
class ConfigR_t,
class Tangent_t>
83 static void difference_impl(
84 const Eigen::MatrixBase<ConfigL_t> & q0,
85 const Eigen::MatrixBase<ConfigR_t> & q1,
86 const Eigen::MatrixBase<Tangent_t> & d)
88 PINOCCHIO_EIGEN_CONST_CAST(Tangent_t, d) = q1 - q0;
91 template<ArgumentPosition arg,
class ConfigL_t,
class ConfigR_t,
class JacobianOut_t>
92 void dDifference_impl(
93 const Eigen::MatrixBase<ConfigL_t> &,
94 const Eigen::MatrixBase<ConfigR_t> &,
95 const Eigen::MatrixBase<JacobianOut_t> & J)
const
98 PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t, J) =
99 -JacobianMatrix_t::Identity(size_.value(), size_.value());
100 else if (arg == ARG1)
101 PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t, J).setIdentity();
110 static void dDifference_product_impl(
113 const JacobianIn_t & Jin,
114 JacobianOut_t & Jout,
116 const AssignmentOperatorType op)
141 template<
class ConfigIn_t,
class Velocity_t,
class ConfigOut_t>
142 static void integrate_impl(
143 const Eigen::MatrixBase<ConfigIn_t> & q,
144 const Eigen::MatrixBase<Velocity_t> & v,
145 const Eigen::MatrixBase<ConfigOut_t> & qout)
147 PINOCCHIO_EIGEN_CONST_CAST(ConfigOut_t, qout) = q + v;
150 template<
class Config_t,
class Jacobian_t>
151 static void integrateCoeffWiseJacobian_impl(
152 const Eigen::MatrixBase<Config_t> &,
const Eigen::MatrixBase<Jacobian_t> & J)
154 PINOCCHIO_EIGEN_CONST_CAST(Jacobian_t, J).setIdentity();
157 template<
class Config_t,
class Tangent_t,
class JacobianOut_t>
158 static void dIntegrate_dq_impl(
159 const Eigen::MatrixBase<Config_t> & ,
160 const Eigen::MatrixBase<Tangent_t> & ,
161 const Eigen::MatrixBase<JacobianOut_t> & J,
162 const AssignmentOperatorType op = SETTO)
164 Eigen::MatrixBase<JacobianOut_t> & Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t, J);
171 Jout.diagonal().array() += Scalar(1);
174 Jout.diagonal().array() -= Scalar(1);
177 assert(
false &&
"Wrong Op requesed value");
182 template<
class Config_t,
class Tangent_t,
class JacobianOut_t>
183 static void dIntegrate_dv_impl(
184 const Eigen::MatrixBase<Config_t> & ,
185 const Eigen::MatrixBase<Tangent_t> & ,
186 const Eigen::MatrixBase<JacobianOut_t> & J,
187 const AssignmentOperatorType op = SETTO)
189 Eigen::MatrixBase<JacobianOut_t> & Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t, J);
196 Jout.diagonal().array() += Scalar(1);
199 Jout.diagonal().array() -= Scalar(1);
202 assert(
false &&
"Wrong Op requesed value");
207 template<
class Config_t,
class Tangent_t,
class JacobianIn_t,
class JacobianOut_t>
208 static void dIntegrate_product_impl(
211 const JacobianIn_t & Jin,
212 JacobianOut_t & Jout,
215 const AssignmentOperatorType op)
229 assert(
false &&
"Wrong Op requesed value");
234 template<
class Config_t,
class Tangent_t,
class JacobianIn_t,
class JacobianOut_t>
235 static void dIntegrateTransport_dq_impl(
236 const Eigen::MatrixBase<Config_t> & ,
237 const Eigen::MatrixBase<Tangent_t> & ,
238 const Eigen::MatrixBase<JacobianIn_t> & Jin,
239 const Eigen::MatrixBase<JacobianOut_t> & Jout)
241 PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t, Jout) = Jin;
244 template<
class Config_t,
class Tangent_t,
class JacobianIn_t,
class JacobianOut_t>
245 static void dIntegrateTransport_dv_impl(
246 const Eigen::MatrixBase<Config_t> & ,
247 const Eigen::MatrixBase<Tangent_t> & ,
248 const Eigen::MatrixBase<JacobianIn_t> & Jin,
249 const Eigen::MatrixBase<JacobianOut_t> & Jout)
251 PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t, Jout) = Jin;
254 template<
class Config_t,
class Tangent_t,
class Jacobian_t>
255 static void dIntegrateTransport_dq_impl(
256 const Eigen::MatrixBase<Config_t> & ,
257 const Eigen::MatrixBase<Tangent_t> & ,
258 const Eigen::MatrixBase<Jacobian_t> & )
262 template<
class Config_t,
class Tangent_t,
class Jacobian_t>
263 static void dIntegrateTransport_dv_impl(
264 const Eigen::MatrixBase<Config_t> & ,
265 const Eigen::MatrixBase<Tangent_t> & ,
266 const Eigen::MatrixBase<Jacobian_t> & )
274 template<
class Config_t>
275 static void normalize_impl(
const Eigen::MatrixBase<Config_t> & )
279 template<
class Config_t>
281 isNormalized_impl(
const Eigen::MatrixBase<Config_t> & ,
const Scalar & )
286 template<
class Config_t>
287 static void random_impl(
const Eigen::MatrixBase<Config_t> & qout)
289 PINOCCHIO_EIGEN_CONST_CAST(Config_t, qout).setRandom();
292 template<
class ConfigL_t,
class ConfigR_t,
class ConfigOut_t>
293 void randomConfiguration_impl(
294 const Eigen::MatrixBase<ConfigL_t> & lower_pos_limit,
295 const Eigen::MatrixBase<ConfigR_t> & upper_pos_limit,
296 const Eigen::MatrixBase<ConfigOut_t> & qout)
const
298 ConfigOut_t & res = PINOCCHIO_EIGEN_CONST_CAST(ConfigOut_t, qout).derived();
299 for (
int i = 0; i < nq(); ++i)
301 if (check_expression_if_real<Scalar, false>(
302 lower_pos_limit[i] == -std::numeric_limits<typename ConfigL_t::Scalar>::infinity()
303 || upper_pos_limit[i] == std::numeric_limits<typename ConfigR_t::Scalar>::infinity()))
305 std::ostringstream error;
306 error <<
"non bounded limit. Cannot uniformly sample joint at rank " << i;
307 throw std::range_error(error.str());
310 lower_pos_limit[i] + ((upper_pos_limit[i] - lower_pos_limit[i]) * rand()) / RAND_MAX;
316 return size_.value() == other.size_.value();
320 Eigen::internal::variable_if_dynamic<Index, Dim> size_;
Main pinocchio namespace.
ArgumentPosition
Argument position. Used as template parameter to refer to an argument.
VectorSpaceOperationTpl(int size=boost::static_signed_max< 0, Dim >::value)
VectorSpaceOperationTpl(const VectorSpaceOperationTpl &other)
Common traits structure to fully define base classes for CRTP.