GCC Code Coverage Report


Directory: ./
File: bindings/python/collision/expose-collision.cpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 28 31 90.3%
Branches: 33 66 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2024 INRIA
3 //
4
5 #include "pinocchio/fwd.hpp"
6 #include "pinocchio/bindings/python/utils/std-aligned-vector.hpp"
7 #include "pinocchio/bindings/python/collision/geometry-functors.hpp"
8 #include "pinocchio/bindings/python/collision/collision.hpp"
9
10 #include "pinocchio/collision/collision.hpp"
11 #include "pinocchio/collision/distance.hpp"
12
13 #include <Eigen/Core>
14
15 namespace pinocchio
16 {
17 namespace python
18 {
19
20 template<
21 typename Scalar,
22 int Options,
23 template<typename, int>
24 class JointCollectionTpl,
25 typename ConfigVectorType>
26 static std::size_t computeDistances_proxy(
27 const ModelTpl<Scalar, Options, JointCollectionTpl> & model,
28 DataTpl<Scalar, Options, JointCollectionTpl> & data,
29 const GeometryModel & geom_model,
30 GeometryData & geom_data,
31 const Eigen::MatrixBase<ConfigVectorType> & q)
32 {
33 return computeDistances(model, data, geom_model, geom_data, q);
34 }
35
36 20 void exposeCollision()
37 {
38 using namespace Eigen;
39
40 20 bp::register_ptr_to_python<std::shared_ptr<hpp::fcl::CollisionGeometry const>>();
41
42 20 bp::class_<ComputeCollision>(
43 "ComputeCollision", "Collision function between two geometry objects.\n\n", bp::no_init)
44
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 .def(GeometryFunctorPythonVisitor<ComputeCollision>());
45
3/6
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 20 times.
✗ Branch 10 not taken.
20 StdAlignedVectorPythonVisitor<ComputeCollision>::expose("StdVec_ComputeCollision");
46
47 20 bp::class_<ComputeDistance>(
48 "ComputeDistance", "Distance function between two geometry objects.\n\n", bp::no_init)
49
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 .def(GeometryFunctorPythonVisitor<ComputeDistance>());
50
3/6
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 20 times.
✗ Branch 10 not taken.
20 StdAlignedVectorPythonVisitor<ComputeDistance>::expose("StdVec_ComputeDistance");
51
52
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
53 "computeCollision",
54 static_cast<bool (*)(
55 const GeometryModel &, GeometryData &, const PairIndex, fcl::CollisionRequest &)>(
56 computeCollision),
57 40 bp::args("geometry_model", "geometry_data", "pair_index", "collision_request"),
58 "Check if the collision objects of a collision pair for a given Geometry Model and "
59 "Data are in collision.\n"
60 "The collision pair is given by the two index of the collision objects.");
61
62
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
63 "computeCollision",
64 static_cast<bool (*)(const GeometryModel &, GeometryData &, const PairIndex)>(
65 computeCollision),
66 40 bp::args("geometry_model", "geometry_data", "pair_index"),
67 "Check if the collision objects of a collision pair for a given Geometry Model and "
68 "Data are in collision.\n"
69 "The collision pair is given by the two index of the collision objects.");
70
71
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
72 "computeCollisions",
73 (bool (*)(const GeometryModel &, GeometryData &, const bool)) & computeCollisions,
74
2/4
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
60 (bp::arg("geometry_model"), bp::arg("geometry_data"),
75
3/6
✓ 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.
40 bp::arg("stop_at_first_collision") = false),
76 "Determine if all collision pairs are effectively in collision or not.");
77
78
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
79 "computeCollisions", &computeCollisions<double, 0, JointCollectionDefaultTpl, VectorXd>,
80
7/14
✓ 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.
✓ Branch 20 taken 20 times.
✗ Branch 21 not taken.
60 (bp::arg("model"), bp::arg("data"), bp::arg("geometry_model"), bp::arg("geometry_data"),
81
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.
60 bp::arg("q"), bp::arg("stop_at_first_collision") = false),
82 "Update the geometry for a given configuration and "
83 "determine if all collision pairs are effectively in collision or not.");
84
85
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
86 "computeDistance", &computeDistance,
87
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
40 bp::args("geometry_model", "geometry_data", "pair_index"),
88 "Compute the distance between the two geometry objects of a given collision pair for "
89 "a GeometryModel and associated GeometryData.",
90 bp::with_custodian_and_ward_postcall<
91 0, 2, bp::return_value_policy<bp::reference_existing_object>>());
92
93
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
94 "computeDistances",
95 (std::size_t(*)(const GeometryModel &, GeometryData &)) & computeDistances,
96 40 bp::args("geometry_model", "geometry_data"),
97 "Compute the distance between each collision pair for a given GeometryModel and "
98 "associated GeometryData.");
99
100
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
101 "computeDistances", &computeDistances_proxy<double, 0, JointCollectionDefaultTpl, VectorXd>,
102 40 bp::args("model", "data", "geometry_model", "geometry_data", "q"),
103 "Update the geometry for a given configuration and "
104 "compute the distance between each collision pair");
105
106
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 bp::def(
107 "computeBodyRadius", &computeBodyRadius<double, 0, JointCollectionDefaultTpl>,
108 40 bp::args("model", "geometry_model", "geometry_data"),
109 "Compute the radius of the geometry volumes attached to every joints.");
110
111 20 exposeBroadphase();
112 20 }
113
114 } // namespace python
115 } // namespace pinocchio
116