hpp-core  6.0.0
Implement basic classes for canonical path planning for kinematic chains.
collision-pair.hh
Go to the documentation of this file.
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 {
48  coal::ComputeCollision computeCollision;
49 
51  : first(f),
52  second(s),
53  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  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  assert(!first->getTransform(d).translation().hasNaN());
74  assert(!first->getTransform(d).rotation().hasNaN());
75  assert(!second->getTransform(d).translation().hasNaN());
76  assert(!second->getTransform(d).rotation().hasNaN());
77  return computeCollision(toFclTransform3f(first->getTransform(d)),
78  toFclTransform3f(second->getTransform(d)), request,
79  result);
80  }
81 };
82 
83 } // namespace core
84 } // namespace hpp
85 #endif // HPP_CORE_COLLISION_PAIR_HH
std::vector< coal::CollisionRequest > CollisionRequests_t
Definition: collision-pair.hh:43
pinocchio::CollisionObjectConstPtr_t CollisionObjectConstPtr_t
Definition: fwd.hh:100
Definition: bi-rrt-planner.hh:35
Definition: collision-pair.hh:45
CollisionPair(CollisionObjectConstPtr_t f, CollisionObjectConstPtr_t s)
Definition: collision-pair.hh:50
CollisionObjectConstPtr_t second
Definition: collision-pair.hh:47
CollisionObjectConstPtr_t first
Definition: collision-pair.hh:46
auto collide(const pinocchio::DeviceData &d, coal::CollisionRequest &request, coal::CollisionResult &result) const
Definition: collision-pair.hh:67
auto collide(coal::CollisionRequest &request, coal::CollisionResult &result) const
Definition: collision-pair.hh:55
coal::ComputeCollision computeCollision
Definition: collision-pair.hh:48