GCC Code Coverage Report


Directory: ./
File: bindings/python/algorithm/expose-aba-derivatives.cpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 14 26 53.8%
Branches: 7 32 21.9%

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