30 :
public boost::python::def_visitor<
31 ConstraintCholeskyDecompositionPythonVisitor<ConstraintCholeskyDecomposition>>
33 typedef ConstraintCholeskyDecomposition Self;
34 typedef typename Self::Scalar Scalar;
35 typedef context::RigidConstraintModel RigidConstraintModel;
36 typedef context::RigidConstraintData RigidConstraintData;
37 typedef typename Self::Matrix Matrix;
38 typedef typename Self::RowMatrix RowMatrix;
39 typedef typename Self::Vector Vector;
41 typedef context::ConstraintModel ConstraintModel;
42 typedef context::ConstraintData ConstraintData;
44 typedef Eigen::Ref<Matrix> RefMatrix;
45 typedef Eigen::Ref<RowMatrix> RefRowMatrix;
46 typedef Eigen::Ref<Vector> RefVector;
48 typedef typename std::vector<RigidConstraintModel> RigidConstraintModelVector;
49 typedef typename std::vector<RigidConstraintData> RigidConstraintDataVector;
51 typedef context::ConstraintModelVector ConstraintModelVector;
52 typedef context::ConstraintDataVector ConstraintDataVector;
54 typedef pinocchio::python::context::Model Model;
55 typedef pinocchio::python::context::Data Data;
57 template<
class PyClass>
58 void visit(PyClass & cl)
const 60 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor."))
62 bp::init<const Model &, const Data &>(
63 bp::args(
"self",
"model",
"data"),
67 const Model &,
const Data &,
const RigidConstraintModelVector &,
68 const RigidConstraintDataVector>(
69 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"contact_models"),
70 bp::arg(
"contact_datas")),
71 "Constructor from a model and a collection of RigidConstraintModels.")
75 const Model &,
const Data &,
const ConstraintModelVector &,
76 const ConstraintDataVector>(
77 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"constraint_models"),
78 bp::arg(
"constraint_datas")),
79 "Constructor from a model and a collection of ConstraintModels.")
85 +[](
const Self & self) -> RefRowMatrix {
return RefRowMatrix(self.U); },
86 bp::with_custodian_and_ward_postcall<0, 1>()),
91 +[](
const Self & self) -> RefVector {
return RefVector(self.D); },
92 bp::with_custodian_and_ward_postcall<0, 1>()),
97 +[](
const Self & self) -> RefVector {
return RefVector(self.Dinv); },
98 bp::with_custodian_and_ward_postcall<0, 1>()),
101 .def(
"size", &Self::size, bp::arg(
"self"),
"Size of the decomposition.")
103 "constraintDim", &Self::constraintDim, bp::arg(
"self"),
104 "Returns the total dimension of the constraints contained in the Cholesky " 107 "matrix", (Matrix (Self::*)(
void)
const) & Self::matrix, bp::arg(
"self"),
108 "Returns the matrix resulting from the decomposition.")
113 Self & self,
const Model &,
const Data &,
const RigidConstraintModelVector &,
114 const RigidConstraintDataVector &))&rebuild,
115 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"constraint_models"),
116 bp::arg(
"constraint_datas")),
117 "Rebuild the Cholesky decompostion internal memory according to the input constraint " 123 Self & self,
const Model &,
const Data &,
const ConstraintModelVector &,
124 const ConstraintDataVector &))&rebuild,
125 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"constraint_models"),
126 bp::arg(
"constraint_datas")),
127 "Rebuild the Cholesky decompostion internal memory according to the input constraint " 133 Self & self,
const Model &, Data &,
const RigidConstraintModelVector &,
134 RigidConstraintDataVector &,
const Scalar))&compute,
135 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"contact_models"),
136 bp::arg(
"contact_datas"), bp::arg(
"mu") = 0),
137 "Computes the Cholesky decompostion of the augmented matrix containing the KKT matrix\n" 138 "related to the system mass matrix and the Jacobians of the contact patches contained " 140 "the vector of RigidConstraintModel named contact_models. The decomposition is " 141 "regularized with a factor mu.",
147 Self & self,
const Model &, Data &,
const RigidConstraintModelVector &,
148 RigidConstraintDataVector &,
const Vector &))&compute,
149 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"contact_models"),
150 bp::arg(
"contact_datas"), bp::arg(
"mus")),
151 "Computes the Cholesky decompostion of the augmented matrix containing the KKT matrix\n" 152 "related to the system mass matrix and the Jacobians of the contact patches contained " 154 "the vector of RigidConstraintModel named contact_models. The decomposition is " 155 "regularized with a factor mu.",
161 Self & self,
const Model &, Data &,
const ConstraintModelVector &,
162 ConstraintDataVector &,
const Scalar))&compute,
163 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"constraint_models"),
164 bp::arg(
"constraint_datas"), bp::arg(
"mu") = 0),
165 "Computes the Cholesky decompostion of the augmented matrix containing the KKT matrix\n" 166 "related to the system mass matrix and the Jacobians of the contact patches contained " 168 "the vector of ConstraintModel named constraint_models. The decomposition is " 169 "regularized with a factor mu.")
174 Self & self,
const Model &, Data &,
const ConstraintModelVector &,
175 ConstraintDataVector &,
const Vector &))&compute,
176 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"constraint_models"),
177 bp::arg(
"constraint_datas"), bp::arg(
"mus")),
178 "Computes the Cholesky decompostion of the augmented matrix containing the KKT matrix\n" 179 "related to the system mass matrix and the Jacobians of the contact patches contained " 181 "the vector of ConstraintModel named constraint_models. The decomposition is " 182 "regularized with a factor mu.")
185 "updateDamping", (
void (Self::*)(
const Scalar &))&Self::updateDamping,
186 bp::args(
"self",
"mu"),
187 "Update the damping term on the upper left block part of the KKT matrix. The damping " 188 "term should be positive.")
191 "updateDamping", &Self::template updateDamping<Vector>, bp::args(
"self",
"mus"),
192 "Update the damping terms on the upper left block part of the KKT matrix. The damping " 193 "terms should be all positives.")
196 "getDamping", +[](
const Self & self) -> Matrix {
return self.getDamping().matrix(); },
197 bp::arg(
"self"),
"Returns the current damping as a dense matrix.")
200 "getInverseOperationalSpaceInertiaMatrix",
201 (Matrix (Self::*)(
bool)
const) & Self::getInverseOperationalSpaceInertiaMatrix,
202 (bp::arg(
"self"), bp::arg(
"enforce_symmetry") =
false),
203 "Returns the Inverse of the Operational Space Inertia Matrix resulting from the " 205 bp::return_value_policy<bp::return_by_value>())
208 "getOperationalSpaceInertiaMatrix",
209 (Matrix (Self::*)(
void)
const) & Self::getOperationalSpaceInertiaMatrix,
211 "Returns the Operational Space Inertia Matrix resulting from the decomposition.",
212 bp::return_value_policy<bp::return_by_value>())
215 "getInverseMassMatrix", (Matrix (Self::*)(
void)
const) & Self::getInverseMassMatrix,
217 "Returns the inverse of the Joint Space Inertia Matrix or \"mass matrix\".",
218 bp::return_value_policy<bp::return_by_value>())
221 "solve", &solve<Matrix>, bp::args(
"self",
"matrix"),
222 "Computes the solution of \f$ A x = b \f$ where self corresponds to the Cholesky " 223 "decomposition of A.",
224 bp::return_value_policy<bp::return_by_value>())
227 "inverse", (Matrix (Self::*)(
void)
const) & Self::inverse, bp::arg(
"self"),
228 "Returns the inverse matrix resulting from the decomposition.")
231 "getMassMatrixChoeslkyDecomposition",
232 &Self::template getMassMatrixChoeslkyDecomposition<
233 Scalar, 0, JointCollectionDefaultTpl>,
235 "Retrieves the Cholesky decomposition of the Mass Matrix contained in the current " 239 "getDelassusOperatorCholeskyExpression", &Self::getDelassusOperatorCholeskyExpression,
241 "Returns the Cholesky decomposition expression associated to the underlying Delassus " 243 bp::with_custodian_and_ward_postcall<0, 1>())
245 "getDelassusCholeskyExpression", &Self::getDelassusOperatorCholeskyExpression,
246 bp::arg(
"self"),
"Deprecated. Use getDelassusOperatorCholeskyExpression instead.",
247 ::eigenpy::deprecated_member<
248 eigenpy::DeprecationType::DEPRECATION, bp::with_custodian_and_ward_postcall<0, 1>>(
249 "Deprecated member. Use getDelassusOperatorCholeskyExpression instead."))
256 bp::class_<ConstraintCholeskyDecomposition>(
257 "ConstraintCholeskyDecomposition",
258 "Contact information container for contact dynamic algorithms.", bp::no_init)
260 .def(::eigenpy::CopyableVisitor<ConstraintCholeskyDecomposition>());
262 bp::scope().attr(
"ContactCholeskyDecomposition") =
263 bp::scope().attr(
"ConstraintCholeskyDecomposition");
265 typedef typename ConstraintCholeskyDecomposition::DelassusOperatorCholeskyExpression
266 DelassusOperatorCholeskyExpression;
268 bp::class_<DelassusOperatorCholeskyExpression>(
269 "DelassusOperatorCholeskyExpression",
270 "Delassus Cholesky expression associated to a given ConstraintCholeskyDecomposition " 274 bp::init<ConstraintCholeskyDecomposition &>(
275 bp::args(
"self",
"cholesky_decomposition"),
276 "Build from a given ConstraintCholeskyDecomposition object.")
277 [bp::with_custodian_and_ward<1, 2>()])
280 +[](DelassusOperatorCholeskyExpression & self) -> ConstraintCholeskyDecomposition & {
281 return self.cholesky();
284 "Returns the Constraint Cholesky decomposition associated to this " 285 "DelassusOperatorCholeskyExpression.",
286 bp::return_internal_reference<>())
289 bp::scope().attr(
"DelassusCholeskyExpression") =
290 bp::scope().attr(
"DelassusOperatorCholeskyExpression");
294#ifndef PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED 295 typedef DelassusOperatorDenseTpl<context::Scalar, context::Options> DelassusOperatorDense;
296 bp::class_<DelassusOperatorDense>(
297 "DelassusOperatorDense",
"Delassus Cholesky dense operator from a dense matrix.",
300 bp::init<const context::RefConstMatrixXs>(
301 bp::args(
"self",
"matrix"),
"Build from a given dense matrix"))
308#ifndef PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED 309 typedef DelassusOperatorSparseTpl<context::Scalar, context::Options>
310 DelassusOperatorSparse;
311 using SparseMatrix =
typename DelassusOperatorSparse::SparseMatrix;
312 bp::class_<DelassusOperatorSparse, boost::noncopyable>(
313 "DelassusOperatorSparse",
"Delassus Cholesky sparse operator from a sparse matrix.",
316 bp::init<const context::SparseMatrix &>(
317 bp::args(
"self",
"matrix"),
"Build from a given sparse matrix"))
321 static_cast<SparseMatrix (DelassusOperatorSparse::*)(
bool) const
>(
322 &DelassusOperatorSparse::sparseMatrix),
323 (bp::arg(
"self"), bp::arg(
"with_damping") =
true),
324 "Returns the Delassus expression as a sparse matrix.");
327#ifdef PINOCCHIO_WITH_ACCELERATE_SUPPORT 329 typedef Eigen::AccelerateLLT<context::SparseMatrix> AccelerateCholeskyDecomposition;
330 typedef DelassusOperatorSparseTpl<
331 context::Scalar, context::Options, AccelerateCholeskyDecomposition>
332 DelassusOperatorSparseAccelerate;
333 bp::class_<DelassusOperatorSparseAccelerate, boost::noncopyable>(
334 "DelassusOperatorSparseAccelerate",
335 "Delassus Cholesky sparse operator leveraging the Accelerate framework on APPLE " 339 bp::init<const context::SparseMatrix &>(
340 bp::args(
"self",
"matrix"),
"Build from a given sparse matrix"))
347 template<
typename MatrixType>
348 static Matrix solve(
const Self & self,
const MatrixType & mat)
350 return self.solve(mat);
354 typename ConstraintModel,
355 typename ConstraintModelAllocator,
356 typename ConstraintData,
357 typename ConstraintDataAllocator>
362 const std::vector<ConstraintModel, ConstraintModelAllocator> & contact_models,
363 const std::vector<ConstraintData, ConstraintDataAllocator> & contact_datas)
365 self.rebuild(model, data, contact_models, contact_datas);
369 typename ConstraintModel,
370 typename ConstraintModelAllocator,
371 typename ConstraintData,
372 typename ConstraintDataAllocator>
377 const std::vector<ConstraintModel, ConstraintModelAllocator> & contact_models,
378 std::vector<ConstraintData, ConstraintDataAllocator> & contact_datas,
379 const Scalar mu =
static_cast<Scalar
>(0))
381 self.compute(model, data, contact_models, contact_datas, mu);
385 typename ConstraintModel,
386 typename ConstraintModelAllocator,
387 typename ConstraintData,
388 typename ConstraintDataAllocator>
393 const std::vector<ConstraintModel, ConstraintModelAllocator> & contact_models,
394 std::vector<ConstraintData, ConstraintDataAllocator> & contact_datas,
397 self.compute(model, data, contact_models, contact_datas, mus);