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> 17 template<
int Dim,
typename _Scalar,
int _Options>
20 typedef _Scalar Scalar;
28 template<
int Dim,
typename _Scalar,
int _Options>
30 :
public LieGroupBase< VectorSpaceOperationTpl<Dim,_Scalar,_Options> >
40 assert(size_.value() >= 0);
46 : Base(), size_(other.size_.value())
48 assert(size_.value() >= 0);
62 return ConfigVector_t::Zero(size_.value());
65 std::string
name ()
const 67 std::ostringstream oss; oss <<
"R^" <<
nq();
71 template <
class ConfigL_t,
class ConfigR_t,
class Tangent_t>
72 static void difference_impl(
const Eigen::MatrixBase<ConfigL_t> & q0,
73 const Eigen::MatrixBase<ConfigR_t> & q1,
74 const Eigen::MatrixBase<Tangent_t> & d)
76 PINOCCHIO_EIGEN_CONST_CAST(Tangent_t,d) = q1 - q0;
79 template <ArgumentPosition arg,
class ConfigL_t,
class ConfigR_t,
class JacobianOut_t>
80 void dDifference_impl (
const Eigen::MatrixBase<ConfigL_t> &,
81 const Eigen::MatrixBase<ConfigR_t> &,
82 const Eigen::MatrixBase<JacobianOut_t> & J)
const 85 PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J) = -JacobianMatrix_t::Identity();
87 PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J).setIdentity();
90 template <
class ConfigIn_t,
class Velocity_t,
class ConfigOut_t>
91 static void integrate_impl(
const Eigen::MatrixBase<ConfigIn_t> & q,
92 const Eigen::MatrixBase<Velocity_t> & v,
93 const Eigen::MatrixBase<ConfigOut_t> & qout)
95 PINOCCHIO_EIGEN_CONST_CAST(ConfigOut_t,qout) = q + v;
98 template <
class Config_t,
class Jacobian_t>
99 static void integrateCoeffWiseJacobian_impl(
const Eigen::MatrixBase<Config_t> &,
100 const Eigen::MatrixBase<Jacobian_t> & J)
102 PINOCCHIO_EIGEN_CONST_CAST(Jacobian_t,J).setIdentity();
105 template <
class Config_t,
class Tangent_t,
class JacobianOut_t>
106 static void dIntegrate_dq_impl(
const Eigen::MatrixBase<Config_t > & ,
107 const Eigen::MatrixBase<Tangent_t> & ,
108 const Eigen::MatrixBase<JacobianOut_t> & J,
109 const AssignmentOperatorType op=SETTO)
111 Eigen::MatrixBase<JacobianOut_t>& Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J);
118 Jout.diagonal().array() += Scalar(1);
121 Jout.diagonal().array() -= Scalar(1);
124 assert(
false &&
"Wrong Op requesed value");
129 template <
class Config_t,
class Tangent_t,
class JacobianOut_t>
130 static void dIntegrate_dv_impl(
const Eigen::MatrixBase<Config_t > & ,
131 const Eigen::MatrixBase<Tangent_t> & ,
132 const Eigen::MatrixBase<JacobianOut_t> & J,
133 const AssignmentOperatorType op=SETTO)
135 Eigen::MatrixBase<JacobianOut_t>& Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J);
142 Jout.diagonal().array() += Scalar(1);
145 Jout.diagonal().array() -= Scalar(1);
148 assert(
false &&
"Wrong Op requesed value");
154 template <
class Config_t,
class Tangent_t,
class JacobianIn_t,
class JacobianOut_t>
155 void dIntegrateTransport_dq_impl(
const Eigen::MatrixBase<Config_t > & ,
156 const Eigen::MatrixBase<Tangent_t> & ,
157 const Eigen::MatrixBase<JacobianIn_t> & Jin,
158 const Eigen::MatrixBase<JacobianOut_t> & Jout)
const 160 PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,Jout) = Jin;
163 template <
class Config_t,
class Tangent_t,
class JacobianIn_t,
class JacobianOut_t>
164 void dIntegrateTransport_dv_impl(
const Eigen::MatrixBase<Config_t > & ,
165 const Eigen::MatrixBase<Tangent_t> & ,
166 const Eigen::MatrixBase<JacobianIn_t> & Jin,
167 const Eigen::MatrixBase<JacobianOut_t> & Jout)
const 169 PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,Jout) = Jin;
172 template <
class Config_t,
class Tangent_t,
class Jacobian_t>
173 void dIntegrateTransport_dq_impl(
const Eigen::MatrixBase<Config_t > & ,
174 const Eigen::MatrixBase<Tangent_t> & ,
175 const Eigen::MatrixBase<Jacobian_t> & )
const {}
177 template <
class Config_t,
class Tangent_t,
class Jacobian_t>
178 void dIntegrateTransport_dv_impl(
const Eigen::MatrixBase<Config_t > & ,
179 const Eigen::MatrixBase<Tangent_t> & ,
180 const Eigen::MatrixBase<Jacobian_t> & )
const {}
188 template <
class Config_t>
189 static void normalize_impl (
const Eigen::MatrixBase<Config_t>& )
192 template <
class Config_t>
193 void random_impl (
const Eigen::MatrixBase<Config_t>& qout)
const 195 PINOCCHIO_EIGEN_CONST_CAST(Config_t,qout).setRandom();
198 template <
class ConfigL_t,
class ConfigR_t,
class ConfigOut_t>
199 void randomConfiguration_impl
200 (
const Eigen::MatrixBase<ConfigL_t> & lower_pos_limit,
201 const Eigen::MatrixBase<ConfigR_t> & upper_pos_limit,
202 const Eigen::MatrixBase<ConfigOut_t> & qout)
const 204 ConfigOut_t & res = PINOCCHIO_EIGEN_CONST_CAST(ConfigOut_t,qout).derived();
205 for (
int i = 0; i <
nq (); ++i)
207 if(lower_pos_limit[i] == -std::numeric_limits<typename ConfigL_t::Scalar>::infinity() ||
208 upper_pos_limit[i] == std::numeric_limits<typename ConfigR_t::Scalar>::infinity() )
210 std::ostringstream error;
211 error <<
"non bounded limit. Cannot uniformly sample joint at rank " << i;
213 throw std::range_error(error.str());
215 res[i] = lower_pos_limit[i] + (( upper_pos_limit[i] - lower_pos_limit[i]) * rand())/RAND_MAX;
221 Eigen::internal::variable_if_dynamic<Index, Dim> size_;
226 #endif // ifndef __pinocchio_multibody_liegroup_vector_space_operation_hpp__ int nv(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNvVisitor to get the dimension of the joint tangent space...
int nq(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNqVisitor to get the dimension of the joint configuration space...
VectorSpaceOperationTpl(int size=boost::static_signed_max< 0, Dim >::value)
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.
VectorSpaceOperationTpl(const VectorSpaceOperationTpl &other)
Main pinocchio namespace.
void neutral(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ReturnType > &qout)
Return the neutral configuration element related to the model configuration space.
Common traits structure to fully define base classes for CRTP.