GCC Code Coverage Report


Directory: ./
File: bindings/python/algorithm/expose-aba-derivatives.cpp
Date: 2025-04-30 16:14:33
Exec Total Coverage
Lines: 22 30 73.3%
Branches: 14 40 35.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2018-2021 CNRS INRIA
3 //
4
5 #include "pinocchio/bindings/python/algorithm/algorithms.hpp"
6 #include "pinocchio/bindings/python/utils/namespace.hpp"
7 #include "pinocchio/algorithm/aba-derivatives.hpp"
8 #include "pinocchio/bindings/python/utils/eigen.hpp"
9 #include "pinocchio/bindings/python/utils/model-checker.hpp"
10
11 #include <eigenpy/eigen-to-python.hpp>
12
13 namespace pinocchio
14 {
15 namespace python
16 {
17
18 namespace bp = boost::python;
19 typedef PINOCCHIO_ALIGNED_STD_VECTOR(context::Force) ForceAlignedVector;
20
21 2 bp::tuple computeABADerivatives(
22 const context::Model & model,
23 context::Data & data,
24 const context::VectorXs & q,
25 const context::VectorXs & v,
26 const context::VectorXs & tau)
27 {
28 2 pinocchio::computeABADerivatives(model, data, q, v, tau);
29 2 make_symmetric(data.Minv);
30
3/6
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
4 return bp::make_tuple(make_ref(data.ddq_dq), make_ref(data.ddq_dv), make_ref(data.Minv));
31 }
32
33 1 bp::tuple computeABADerivatives_fext(
34 const context::Model & model,
35 context::Data & data,
36 const context::VectorXs & q,
37 const context::VectorXs & v,
38 const context::VectorXs & tau,
39 const ForceAlignedVector & fext)
40 {
41 1 pinocchio::computeABADerivatives(model, data, q, v, tau, fext);
42 1 make_symmetric(data.Minv);
43
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
2 return bp::make_tuple(make_ref(data.ddq_dq), make_ref(data.ddq_dv), make_ref(data.Minv));
44 }
45
46 bp::tuple computeABADerivatives_min(const context::Model & model, context::Data & data)
47 {
48 pinocchio::computeABADerivatives(model, data);
49 make_symmetric(data.Minv);
50 return bp::make_tuple(make_ref(data.ddq_dq), make_ref(data.ddq_dv), make_ref(data.Minv));
51 }
52
53 bp::tuple computeABADerivatives_min_fext(
54 const context::Model & model, context::Data & data, const ForceAlignedVector & fext)
55 {
56 pinocchio::computeABADerivatives(model, data, fext);
57 make_symmetric(data.Minv);
58 return bp::make_tuple(make_ref(data.ddq_dq), make_ref(data.ddq_dv), make_ref(data.Minv));
59 }
60
61 72 void exposeABADerivatives()
62 {
63 using namespace Eigen;
64
65
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 bp::def(
66
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
144 "computeABADerivatives", computeABADerivatives, bp::args("model", "data", "q", "v", "tau"),
67 "Computes the ABA derivatives, store the result in data.ddq_dq, data.ddq_dv and "
68 "data.Minv (aka ddq_dtau)\n"
69 "which correspond to the partial derivatives of the joint acceleration vector output "
70 "with respect to the joint configuration,\n"
71 "velocity and torque vectors.\n\n"
72 "Parameters:\n"
73 "\tmodel: model of the kinematic tree\n"
74 "\tdata: data related to the model\n"
75 "\tq: the joint configuration vector (size model.nq)\n"
76 "\tv: the joint velocity vector (size model.nv)\n"
77 "\ttau: the joint torque vector (size model.nv)\n\n"
78 "Returns: (ddq_dq, ddq_dv, ddq_da)",
79 72 mimic_not_supported_function<>(0));
80
81
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 bp::def(
82 "computeABADerivatives", computeABADerivatives_fext,
83
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
144 bp::args("model", "data", "q", "v", "tau", "fext"),
84 "Computes the ABA derivatives with external contact foces,\n"
85 "store the result in data.ddq_dq, data.ddq_dv and data.Minv (aka ddq_dtau)\n"
86 "which correspond to the partial derivatives of the acceleration output with respect "
87 "to the joint configuration,\n"
88 "velocity and torque vectors.\n\n"
89 "Parameters:\n"
90 "\tmodel: model of the kinematic tree\n"
91 "\tdata: data related to the model\n"
92 "\tq: the joint configuration vector (size model.nq)\n"
93 "\tv: the joint velocity vector (size model.nv)\n"
94 "\ttau: the joint torque vector (size model.nv)\n"
95 "\tfext: list of external forces expressed in the local frame of the joints (size "
96 "model.njoints)\n\n"
97 "Returns: (ddq_dq, ddq_dv, ddq_da)",
98 72 mimic_not_supported_function<>(0));
99
100
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 bp::def(
101
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
144 "computeABADerivatives", computeABADerivatives_min, bp::args("model", "data"),
102 "Computes the ABA derivatives, store the result in data.ddq_dq, data.ddq_dv and data.Minv\n"
103 "which correspond to the partial derivatives of the joint acceleration vector output with "
104 "respect to the joint configuration,\n"
105 "velocity and torque vectors.\n"
106 "By calling this function, the user assumes that pinocchio.optimized.aba has been called "
107 "first, allowing to significantly reduce the computation timings by not recalculating "
108 "intermediate results.",
109 72 mimic_not_supported_function<>(0));
110
111
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 bp::def(
112
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
144 "computeABADerivatives", computeABADerivatives_min_fext, bp::args("model", "data", "fext"),
113 "Computes the ABA derivatives, store the result in data.ddq_dq, data.ddq_dv and data.Minv\n"
114 "which correspond to the partial derivatives of the joint acceleration vector output with "
115 "respect to the joint configuration,\n"
116 "velocity and torque vectors.\n"
117 "By calling this function, the user assumes that pinocchio.optimized.aba has been called "
118 "first, allowing to significantly reduce the computation timings by not recalculating "
119 "intermediate results.",
120 72 mimic_not_supported_function<>(0));
121 72 }
122 } // namespace python
123 } // namespace pinocchio
124