GCC Code Coverage Report


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