pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
delassus-operator.hpp
1//
2// Copyright (c) 2024 INRIA
3//
4
5#ifndef __pinocchio_python_algorithm_delssus_operator_hpp__
6#define __pinocchio_python_algorithm_delssus_operator_hpp__
7
8#include <eigenpy/memory.hpp>
9#include "pinocchio/algorithm/delassus-operator-base.hpp"
10
11namespace pinocchio
12{
13 namespace python
14 {
15 namespace bp = boost::python;
16
17 template<typename DelassusOperator>
18 struct DelassusOperatorBasePythonVisitor
19 : public boost::python::def_visitor<DelassusOperatorBasePythonVisitor<DelassusOperator>>
20 {
21 typedef DelassusOperator Self;
22 typedef typename DelassusOperator::Scalar Scalar;
23 typedef context::MatrixXs Matrix;
24 typedef typename DelassusOperator::Vector Vector;
25
26 template<class PyClass>
27 void visit(PyClass & cl) const
28 {
29 cl.def(bp::self * bp::other<Matrix>())
30 .def(
31 "__matmul__",
32 +[](const DelassusOperator & self, const Matrix & other) -> Matrix {
33 return self * other;
34 },
35 bp::args("self", "other"),
36 "Matrix multiplication between self and another matrix. Returns the result of Delassus "
37 "* matrix.")
38
39 .def(
40 "solve", &DelassusOperator::template solve<Matrix>, bp::args("self", "mat"),
41 "Returns the solution x of Delassus * x = mat using the current decomposition of "
42 "the Delassus matrix.")
43
44 .def(
45 "computeLargestEigenValue",
46 (Scalar(DelassusOperator::*)(const bool, const int, const Scalar)
47 const)&DelassusOperator::computeLargestEigenValue,
48 (bp::arg("self"), bp::arg("reset") = true, bp::arg("max_it") = 10,
49 bp::arg("prec") = Scalar(1e-8)),
50 "Compute the largest eigenvalue associated to the underlying Delassus matrix.")
51 .def(
52 "computeLowestEigenValue",
53 (Scalar(DelassusOperator::*)(const bool, const bool, const int, const Scalar)
54 const)&DelassusOperator::computeLowestEigenValue,
55 (bp::arg("self"), bp::arg("reset") = true, bp::arg("compute_largest") = true,
56 bp::arg("max_it") = 10, bp::arg("prec") = Scalar(1e-8)),
57 "Compute the lowest eigenvalue associated to the underlying Delassus matrix.")
58
59 .def(
60 "updateDamping",
61 (void(DelassusOperator::*)(const Scalar &)) & DelassusOperator::updateDamping,
62 bp::args("self", "mu"),
63 "Add a damping term to the diagonal of the Delassus matrix. The damping term should "
64 "be positive.")
65 .def(
66 "updateDamping", &DelassusOperator::template updateDamping<Vector>,
67 bp::args("self", "mus"),
68 "Add a damping term to the diagonal of the Delassus matrix. The damping terms "
69 "should be all positive.")
70
71 .def(
72 "matrix", &DelassusOperator::matrix, bp::arg("self"),
73 "Returns the Delassus expression as a dense matrix.")
74 .def(
75 "inverse", &DelassusOperator::inverse, bp::arg("self"),
76 "Returns the inverse of the Delassus expression as a dense matrix.")
77
78 .def(
79 "size", &DelassusOperator::size, bp::arg("self"),
80 "Returns the size of the decomposition.")
81 .def("rows", &DelassusOperator::rows, bp::arg("self"), "Returns the number of rows.")
82 .def("cols", &DelassusOperator::cols, bp::arg("self"), "Returns the number of columns.");
83 }
84 };
85
86 } // namespace python
87} // namespace pinocchio
88
89#endif // ifndef __pinocchio_python_algorithm_delssus_operator_hpp__
Main pinocchio namespace.
Definition treeview.dox:11