5 #ifndef __pinocchio_python_algorithm_contact_cholesky_hpp__
6 #define __pinocchio_python_algorithm_contact_cholesky_hpp__
27 template<
typename ContactCholeskyDecomposition>
29 :
public boost::python::def_visitor<
30 ContactCholeskyDecompositionPythonVisitor<ContactCholeskyDecomposition>>
36 typedef typename ContactCholeskyDecomposition::Matrix
Matrix;
37 typedef typename ContactCholeskyDecomposition::Vector
Vector;
39 RigidConstraintModelVector;
41 RigidConstraintDataVector;
46 template<
class PyClass>
49 cl.def(bp::init<>(bp::arg(
"self"),
"Default constructor."))
50 .def(bp::init<const Model &>(bp::args(
"self",
"model"),
"Constructor from a model."))
51 .def(bp::init<const Model &, const RigidConstraintModelVector &>(
52 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"contact_models")),
53 "Constructor from a model and a collection of RigidConstraintModels."))
55 .PINOCCHIO_ADD_PROPERTY_READONLY_BYVALUE(
Self,
U,
"")
56 .PINOCCHIO_ADD_PROPERTY_READONLY_BYVALUE(
Self,
D,
"")
57 .PINOCCHIO_ADD_PROPERTY_READONLY_BYVALUE(
Self, Dinv,
"")
59 .def(
"size", &
Self::size, bp::arg(
"self"),
"Size of the decomposition.")
61 "constraintDim", &Self::constraintDim, bp::arg(
"self"),
62 "Returns the total dimension of the constraints contained in the Cholesky "
65 "numContacts", &Self::numContacts, bp::arg(
"self"),
66 "Returns the number of contacts associated to this decomposition.")
68 "matrix", (
Matrix(
Self::*)(
void)
const) & Self::matrix, bp::arg(
"self"),
69 "Returns the matrix resulting from the decomposition.")
74 Self &
self,
const Model &,
Data &,
const RigidConstraintModelVector &,
75 RigidConstraintDataVector &,
const Scalar))
77 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"contact_models"),
78 bp::arg(
"contact_datas"), bp::arg(
"mu") = 0),
79 "Computes the Cholesky decompostion of the augmented matrix containing the KKT matrix\n"
80 "related to the system mass matrix and the Jacobians of the contact patches contained "
82 "the vector of RigidConstraintModel named contact_models. The decomposition is "
83 "regularized with a factor mu.")
88 Self &
self,
const Model &,
Data &,
const RigidConstraintModelVector &,
89 RigidConstraintDataVector &,
const Vector &))
91 (bp::arg(
"self"), bp::arg(
"model"), bp::arg(
"data"), bp::arg(
"contact_models"),
92 bp::arg(
"contact_datas"), bp::arg(
"mus")),
93 "Computes the Cholesky decompostion of the augmented matrix containing the KKT matrix\n"
94 "related to the system mass matrix and the Jacobians of the contact patches contained "
96 "the vector of RigidConstraintModel named contact_models. The decomposition is "
97 "regularized with a factor mu.")
100 "updateDamping", (
void(
Self::*)(
const Scalar &)) & Self::updateDamping,
101 bp::args(
"self",
"mu"),
102 "Update the damping term on the upper left block part of the KKT matrix. The "
103 "damping term should be positive.")
106 "updateDamping", &Self::template updateDamping<Vector>, bp::args(
"self",
"mus"),
107 "Update the damping terms on the upper left block part of the KKT matrix. The "
108 "damping terms should be all positives.")
111 "getInverseOperationalSpaceInertiaMatrix",
112 (
Matrix(
Self::*)(
void)
const) & Self::getInverseOperationalSpaceInertiaMatrix,
114 "Returns the Inverse of the Operational Space Inertia Matrix resulting from the "
116 bp::return_value_policy<bp::return_by_value>())
119 "getOperationalSpaceInertiaMatrix",
120 (
Matrix(
Self::*)(
void)
const) & Self::getOperationalSpaceInertiaMatrix, bp::arg(
"self"),
121 "Returns the Operational Space Inertia Matrix resulting from the decomposition.",
122 bp::return_value_policy<bp::return_by_value>())
125 "getInverseMassMatrix", (
Matrix(
Self::*)(
void)
const) & Self::getInverseMassMatrix,
127 "Returns the inverse of the Joint Space Inertia Matrix or \"mass matrix\".",
128 bp::return_value_policy<bp::return_by_value>())
131 "solve", &solve<Matrix>, bp::args(
"self",
"matrix"),
132 "Computes the solution of \f$ A x = b \f$ where self corresponds to the Cholesky "
133 "decomposition of A.",
134 bp::return_value_policy<bp::return_by_value>())
138 "Returns the inverse matrix resulting from the decomposition.")
141 "getMassMatrixChoeslkyDecomposition",
142 &Self::template getMassMatrixChoeslkyDecomposition<
145 "Retrieves the Cholesky decomposition of the Mass Matrix contained in the current "
149 "getDelassusCholeskyExpression", &Self::getDelassusCholeskyExpression, bp::arg(
"self"),
150 "Returns the Cholesky decomposition expression associated to the underlying "
152 bp::with_custodian_and_ward_postcall<0, 1>())
159 bp::class_<ContactCholeskyDecomposition>(
160 "ContactCholeskyDecomposition",
161 "Contact information container for contact dynamic algorithms.", bp::no_init)
166 typedef typename ContactCholeskyDecomposition::DelassusCholeskyExpression
167 DelassusCholeskyExpression;
169 bp::class_<DelassusCholeskyExpression>(
170 "DelassusCholeskyExpression",
171 "Delassus Cholesky expression associated to a "
172 "given ContactCholeskyDecomposition object.",
174 .def(bp::init<const ContactCholeskyDecomposition &>(
175 bp::args(
"self",
"cholesky_decomposition"),
176 "Build from a given ContactCholeskyDecomposition object.")
177 [bp::with_custodian_and_ward<1, 2>()])
184 "Returns the Constraint Cholesky decomposition associated to this "
185 "DelassusCholeskyExpression.",
186 bp::return_internal_reference<>())
193 bp::class_<DelassusOperatorDense>(
194 "DelassusOperatorDense",
"Delassus Cholesky dense operator from a dense matrix.",
196 .def(
bp::init<
const Eigen::Ref<const context::MatrixXs>>(
197 bp::args(
"self",
"matrix"),
"Build from a given dense matrix"))
205 bp::class_<DelassusOperatorSparse, boost::noncopyable>(
206 "DelassusOperatorSparse",
"Delassus Cholesky sparse operator from a sparse matrix.",
208 .def(bp::init<const context::SparseMatrix &>(
209 bp::args(
"self",
"matrix"),
"Build from a given sparse matrix"))
213 #ifdef PINOCCHIO_WITH_ACCELERATE_SUPPORT
215 typedef Eigen::AccelerateLLT<context::SparseMatrix> AccelerateCholeskyDecomposition;
218 DelassusOperatorSparseAccelerate;
219 bp::class_<DelassusOperatorSparseAccelerate, boost::noncopyable>(
220 "DelassusOperatorSparseAccelerate",
221 "Delassus Cholesky sparse operator leveraging the Accelerate framework on APPLE "
224 .def(bp::init<const context::SparseMatrix &>(
225 bp::args(
"self",
"matrix"),
"Build from a given sparse matrix"))
232 template<
typename MatrixType>
235 return self.solve(
mat);
264 #endif // ifndef __pinocchio_python_algorithm_contact_cholesky_hpp__