GCC Code Coverage Report


Directory: ./
File: bindings/python/algorithm/pgs-solver.cpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 9 11 81.8%
Branches: 13 26 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2022-2024 INRIA
3 //
4
5 #include "pinocchio/algorithm/pgs-solver.hpp"
6 #include "pinocchio/bindings/python/fwd.hpp"
7
8 #include "pinocchio/bindings/python/algorithm/contact-solver-base.hpp"
9 #include "pinocchio/bindings/python/utils/std-vector.hpp"
10 #include <eigenpy/eigen-from-python.hpp>
11
12 namespace pinocchio
13 {
14 namespace python
15 {
16 namespace bp = boost::python;
17
18 typedef PGSContactSolverTpl<context::Scalar> Solver;
19
20 #ifdef PINOCCHIO_PYTHON_PLAIN_SCALAR_TYPE
21 template<typename DelassusMatrixType>
22 static bool solve_wrapper(
23 Solver & solver,
24 const DelassusMatrixType & G,
25 const context::VectorXs & g,
26 const context::CoulombFrictionConeVector & cones,
27 Eigen::Ref<context::VectorXs> x,
28 const context::Scalar over_relax = 1)
29 {
30 return solver.solve(G, g, cones, x, over_relax);
31 }
32 #endif
33
34 20 void exposePGSContactSolver()
35 {
36 #ifdef PINOCCHIO_PYTHON_PLAIN_SCALAR_TYPE
37
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::class_<Solver>(
38 "PGSContactSolver", "Projected Gauss Siedel solver for contact dynamics.",
39
1/2
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
40 bp::init<int>(bp::args("self", "problem_dim"), "Default constructor."))
40
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 .def(ContactSolverBasePythonVisitor<Solver>())
41
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 .def(
42 "solve", solve_wrapper<context::MatrixXs>,
43
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::args("self", "G", "g", "cones", "x"), (bp::arg("over_relax") = context::Scalar(1))),
44 "Solve the constrained conic problem composed of problem data (G,g,cones) and starting "
45 "from the initial guess.")
46
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 .def(
47 "solve", solve_wrapper<context::SparseMatrix>,
48
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::args("self", "G", "g", "cones", "x"), (bp::arg("over_relax") = context::Scalar(1))),
49 "Solve the constrained conic problem composed of problem data (G,g,cones) and starting "
50 "from the initial guess.");
51
52 #endif
53 20 }
54
55 } // namespace python
56 } // namespace pinocchio
57