5 #ifndef __pinocchio_python_lie_group_hpp__ 6 #define __pinocchio_python_lie_group_hpp__ 10 #include "pinocchio/multibody/liegroup/liegroup.hpp" 11 #include "pinocchio/multibody/liegroup/cartesian-product-variant.hpp" 12 #include "pinocchio/multibody/liegroup/liegroup-generic.hpp" 13 #include "pinocchio/multibody/liegroup/liegroup-collection.hpp" 21 template<
class LieGroupType>
28 static ConfigVector_t
integrate(
const LieGroupType& lg,
29 const ConfigVector_t&
q,
const TangentVector_t&
v)
31 return lg.integrate(q, v);
35 const ConfigVector_t&
q0,
36 const ConfigVector_t&
q1,
39 return lg.interpolate(q0,q1,u);
42 static TangentVector_t
difference(
const LieGroupType& lg,
43 const ConfigVector_t &
q0,
44 const ConfigVector_t &
q1)
46 return lg.difference(q0,q1);
50 const ConfigVector_t&
q0,
const ConfigVector_t&
q1,
53 JacobianMatrix_t
J(lg.nv(), lg.nv());
54 lg.dDifference(q0, q1,
J, arg);
59 const ConfigVector_t&
q0,
const ConfigVector_t&
q1,
61 const JacobianMatrix_t& Jin,
int self)
63 JacobianMatrix_t
J(Jin.rows(), Jin.cols());
66 lg.template dDifference<ARG0>(
q0,
q1, Jin,
self,
J,
SETTO);
69 lg.template dDifference<ARG1>(
q0,
q1, Jin,
self,
J,
SETTO);
72 throw std::invalid_argument(
"arg must be either ARG0 or ARG1");
78 const ConfigVector_t&
q0,
const ConfigVector_t&
q1,
80 int self,
const JacobianMatrix_t& Jin)
82 JacobianMatrix_t
J(Jin.rows(), Jin.cols());
85 lg.template dDifference<ARG0>(
q0,
q1,
self, Jin,
J,
SETTO);
88 lg.template dDifference<ARG1>(
q0,
q1,
self, Jin,
J,
SETTO);
91 throw std::invalid_argument(
"arg must be either ARG0 or ARG1");
96 static JacobianMatrix_t
dIntegrate(
const LieGroupType& lg,
97 const ConfigVector_t&
q,
98 const TangentVector_t&
v,
101 JacobianMatrix_t
J(lg.nv(), lg.nv());
102 lg.dIntegrate(q, v,
J, arg);
107 const ConfigVector_t&
q,
const TangentVector_t&
v)
109 JacobianMatrix_t
J(lg.nv(), lg.nv());
110 lg.dIntegrate_dq(q, v,
J);
115 const ConfigVector_t&
q,
const TangentVector_t&
v,
116 const JacobianMatrix_t& Jin,
int self)
118 JacobianMatrix_t
J(Jin.rows(), lg.nv());
119 lg.dIntegrate_dq(q, v, Jin,
self,
J,
SETTO);
124 const ConfigVector_t&
q,
const TangentVector_t&
v,
int self,
125 const JacobianMatrix_t& Jin)
127 JacobianMatrix_t
J(lg.nv(), Jin.cols());
128 lg.dIntegrate_dq(q, v,
self, Jin,
J,
SETTO);
133 const ConfigVector_t&
q,
const TangentVector_t&
v)
135 JacobianMatrix_t
J(lg.nv(), lg.nv());
136 lg.dIntegrate_dv(q, v,
J);
141 const ConfigVector_t&
q,
const TangentVector_t&
v,
142 const JacobianMatrix_t& Jin,
int self)
144 JacobianMatrix_t
J(Jin.rows(), lg.nv());
145 lg.dIntegrate_dv(q, v, Jin,
self,
J,
SETTO);
150 const ConfigVector_t&
q,
const TangentVector_t&
v,
int self,
151 const JacobianMatrix_t& Jin)
153 JacobianMatrix_t
J(lg.nv(), Jin.cols());
154 lg.dIntegrate_dv(q, v,
self, Jin,
J,
SETTO);
158 static JacobianMatrix_t
160 const ConfigVector_t &
q,
161 const TangentVector_t &
v,
162 const JacobianMatrix_t &
J,
165 JacobianMatrix_t Jout (lg.nv(), J.cols());
166 lg.dIntegrateTransport(q, v, J, Jout, arg);
171 template<
class LieGroupType>
173 :
public boost::python::def_visitor< LieGroupPythonVisitor<LieGroupType> >
178 template<
class PyClass>
185 .def(bp::init<>(
"Default constructor"))
188 .def(
"dIntegrate_dq", LieGroupWrapper::dIntegrate_dq1)
189 .def(
"dIntegrate_dq", LieGroupWrapper::dIntegrate_dq2)
190 .def(
"dIntegrate_dq", LieGroupWrapper::dIntegrate_dq3)
191 .def(
"dIntegrate_dv", LieGroupWrapper::dIntegrate_dv1)
192 .def(
"dIntegrate_dv", LieGroupWrapper::dIntegrate_dv2)
193 .def(
"dIntegrate_dv", LieGroupWrapper::dIntegrate_dv3)
194 .def(
"dIntegrateTransport", LieGroupWrapper::dIntegrateTransport_proxy)
197 .def(
"dDifference", LieGroupWrapper::dDifference1)
198 .def(
"dDifference", LieGroupWrapper::dDifference2)
199 .def(
"dDifference", LieGroupWrapper::dDifference3)
203 .def(
"random",
static_cast<typename LieGroupType::ConfigVector_t (LieGroupType::*)() const
>(&
LieGroupType::random))
204 .def(
"randomConfiguration", &LieGroupType::template randomConfiguration<ConfigVector_t, ConfigVector_t>)
205 .def(
"distance", &LieGroupType::template distance<ConfigVector_t, ConfigVector_t>)
206 .def(
"squaredDistance", &LieGroupType::template squaredDistance<ConfigVector_t, ConfigVector_t>)
207 .def(
"normalize", &LieGroupType::template normalize<ConfigVector_t>)
214 .def(bp::self * bp::self)
215 .def(bp::self *= bp::self)
216 .def(bp::self == bp::self)
222 bp::class_<LieGroupType>(
name, bp::no_init)
229 #endif // ifndef __pinocchio_python_geometry_model_hpp__ static ConfigVector_t integrate(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v)
static JacobianMatrix_t dIntegrate_dv3(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v, int self, const JacobianMatrix_t &Jin)
int nv(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNvVisitor to get the dimension of the joint tangent space...
static JacobianMatrix_t dIntegrate(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v, const ArgumentPosition arg)
ArgumentPosition
Argument position. Used as template parameter to refer to an argument.
int nq(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNqVisitor to get the dimension of the joint configuration space...
void integrate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< ReturnType > &qout)
Integrate a configuration vector for the specified model for a tangent vector during one unit time...
void difference(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorIn1 > &q0, const Eigen::MatrixBase< ConfigVectorIn2 > &q1, const Eigen::MatrixBase< ReturnType > &dvout)
Compute the tangent vector that must be integrated during one unit time to go from q0 to q1...
static JacobianMatrix_t dIntegrate_dq3(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v, int self, const JacobianMatrix_t &Jin)
static void expose(const char *name)
Eigen::Matrix< double, Eigen::Dynamic, 1 > ConfigVector_t
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.
static TangentVector_t difference(const LieGroupType &lg, const ConfigVector_t &q0, const ConfigVector_t &q1)
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
static JacobianMatrix_t dDifference1(const LieGroupType &lg, const ConfigVector_t &q0, const ConfigVector_t &q1, const ArgumentPosition arg)
Eigen::Matrix< double, Eigen::Dynamic, 1 > TangentVector_t
void dIntegrate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< JacobianMatrixType > &J, const ArgumentPosition arg, const AssignmentOperatorType op=SETTO)
Computes the Jacobian of a small variation of the configuration vector or the tangent vector into the...
static JacobianMatrix_t dIntegrate_dv2(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v, const JacobianMatrix_t &Jin, int self)
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > const Eigen::MatrixBase< ConfigVectorIn2 > const Scalar & u
static JacobianMatrix_t dDifference3(const LieGroupType &lg, const ConfigVector_t &q0, const ConfigVector_t &q1, const ArgumentPosition arg, int self, const JacobianMatrix_t &Jin)
static JacobianMatrix_t dIntegrate_dq2(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v, const JacobianMatrix_t &Jin, int self)
static JacobianMatrix_t dIntegrate_dv1(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v)
static JacobianMatrix_t dIntegrateTransport_proxy(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v, const JacobianMatrix_t &J, const ArgumentPosition arg)
static JacobianMatrix_t dIntegrate_dq1(const LieGroupType &lg, const ConfigVector_t &q, const TangentVector_t &v)
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > const Eigen::MatrixBase< ConfigVectorIn2 > & q1
void visit(PyClass &cl) const
Main pinocchio namespace.
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > & q0
void neutral(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ReturnType > &qout)
Return the neutral configuration element related to the model configuration space.
void random(const LieGroupGenericTpl< LieGroupCollection > &lg, const Eigen::MatrixBase< Config_t > &qout)
void interpolate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorIn1 > &q0, const Eigen::MatrixBase< ConfigVectorIn2 > &q1, const Scalar &u, const Eigen::MatrixBase< ReturnType > &qout)
Interpolate two configurations for a given model.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > JacobianMatrix_t
static JacobianMatrix_t dDifference2(const LieGroupType &lg, const ConfigVector_t &q0, const ConfigVector_t &q1, const ArgumentPosition arg, const JacobianMatrix_t &Jin, int self)
static ConfigVector_t interpolate(const LieGroupType &lg, const ConfigVector_t &q0, const ConfigVector_t &q1, const double &u)