GCC Code Coverage Report


Directory: ./
File: bindings/python/algorithm/expose-constrained-dynamics-derivatives.cpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 5 9 55.6%
Branches: 11 34 32.4%

Line Branch Exec Source
1 //
2 // Copyright (c) 2021-2022 INRIA
3 //
4
5 #include "pinocchio/bindings/python/algorithm/algorithms.hpp"
6 #include "pinocchio/algorithm/constrained-dynamics-derivatives.hpp"
7
8 #include "pinocchio/bindings/python/utils/std-vector.hpp"
9 #include "pinocchio/bindings/python/utils/eigen.hpp"
10
11 namespace bp = boost::python;
12
13 namespace pinocchio
14 {
15 namespace python
16 {
17 typedef PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(context::RigidConstraintModel)
18 RigidConstraintModelVector;
19 typedef PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(context::RigidConstraintData)
20 RigidConstraintDataVector;
21
22 bp::tuple computeConstraintDynamicsDerivatives_proxy(
23 const context::Model & model,
24 context::Data & data,
25 const RigidConstraintModelVector & contact_models,
26 RigidConstraintDataVector & contact_datas,
27 const context::ProximalSettings & settings = context::ProximalSettings())
28 {
29 pinocchio::computeConstraintDynamicsDerivatives(
30 model, data, contact_models, contact_datas,
31 const_cast<context::ProximalSettings &>(settings));
32
33 return bp::make_tuple(
34 make_ref(data.ddq_dq), make_ref(data.ddq_dv), make_ref(data.ddq_dtau),
35 make_ref(data.dlambda_dq), make_ref(data.dlambda_dv), make_ref(data.dlambda_dtau));
36 }
37
38 20 void exposeConstraintDynamicsDerivatives()
39 {
40 using namespace Eigen;
41
42
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
43 "computeConstraintDynamicsDerivatives", computeConstraintDynamicsDerivatives_proxy,
44
6/12
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 20 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 20 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 20 times.
✗ Branch 18 not taken.
60 (bp::arg("model"), bp::arg("data"), bp::arg("contact_models"), bp::arg("contact_datas"),
45
4/8
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
40 bp::arg("settings") = context::ProximalSettings()),
46 "Computes the derivatives of the forward dynamics with kinematic constraints (given in the "
47 "list of constraint models).\n"
48 "Assumes that constraintDynamics has been called first. See constraintDynamics for more "
49 "details.\n"
50 "This function returns the derivatives of joint acceleration (ddq) and contact forces "
51 "(lambda_c) of the system with respect to q, v and tau.\n"
52 "The output is a tuple with ddq_dq, ddq_dv, ddq_da, dlambda_dq, dlambda_dv, dlambda_da.");
53 20 }
54 } // namespace python
55 } // namespace pinocchio
56