GCC Code Coverage Report


Directory: ./
File: include/hpp/core/collision-pair.hh
Date: 2024-12-13 16:14:03
Exec Total Coverage
Lines: 12 19 63.2%
Branches: 10 32 31.2%

Line Branch Exec Source
1 //
2 // Copyright (c) 2021 CNRS
3 // Authors: Joseph Mirabel
4 //
5
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // 2. Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in the
15 // documentation and/or other materials provided with the distribution.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28 // DAMAGE.
29
30 #ifndef HPP_CORE_COLLISION_PAIR_HH
31 #define HPP_CORE_COLLISION_PAIR_HH
32
33 #include <coal/collision.h>
34
35 #include <hpp/core/fwd.hh>
36 #include <hpp/pinocchio/collision-object.hh>
37 #include <hpp/pinocchio/device-data.hh>
38 #include <pinocchio/spatial/fcl-pinocchio-conversions.hpp>
39
40 namespace hpp {
41 namespace core {
42
43 typedef std::vector<coal::CollisionRequest> CollisionRequests_t;
44
45 struct CollisionPair {
46 CollisionObjectConstPtr_t first;
47 CollisionObjectConstPtr_t second;
48 coal::ComputeCollision computeCollision;
49
50 5283 inline CollisionPair(CollisionObjectConstPtr_t f, CollisionObjectConstPtr_t s)
51 5283 : first(f),
52 5283 second(s),
53
3/6
✓ Branch 2 taken 5283 times.
✗ Branch 3 not taken.
✓ Branch 7 taken 5283 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 5283 times.
✗ Branch 12 not taken.
5283 computeCollision(f->geometry().get(), s->geometry().get()) {}
54
55 inline auto collide(coal::CollisionRequest& request,
56 coal::CollisionResult& result) const
57 // decltype(computeCollision(tf1,tf2,request,result))
58 {
59 assert(!first->getTransform().translation().hasNaN());
60 assert(!first->getTransform().rotation().hasNaN());
61 assert(!second->getTransform().translation().hasNaN());
62 assert(!second->getTransform().rotation().hasNaN());
63 return computeCollision(first->getFclTransform(), second->getFclTransform(),
64 request, result);
65 }
66
67 293498 inline auto collide(const pinocchio::DeviceData& d,
68 coal::CollisionRequest& request,
69 coal::CollisionResult& result) const
70 // decltype(computeCollision(tf1,tf2,request,result))
71 {
72 using ::pinocchio::toFclTransform3f;
73
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 293483 times.
293498 assert(!first->getTransform(d).translation().hasNaN());
74
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 293560 times.
293483 assert(!first->getTransform(d).rotation().hasNaN());
75
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 293572 times.
293560 assert(!second->getTransform(d).translation().hasNaN());
76
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 293636 times.
293572 assert(!second->getTransform(d).rotation().hasNaN());
77
3/6
✓ Branch 2 taken 293614 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 293604 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 293431 times.
✗ Branch 9 not taken.
293604 return computeCollision(toFclTransform3f(first->getTransform(d)),
78 587067 toFclTransform3f(second->getTransform(d)), request,
79 586862 result);
80 }
81 };
82
83 } // namespace core
84 } // namespace hpp
85 #endif // HPP_CORE_COLLISION_PAIR_HH
86