pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
broadphase-manager.hpp
1//
2// Copyright (c) 2022 INRIA
3//
4
5#ifndef __pinocchio_collision_broadphase_manager_hpp__
6#define __pinocchio_collision_broadphase_manager_hpp__
7
8#include <hpp/fcl/broadphase/broadphase_collision_manager.h>
9
10#include "pinocchio/collision/broadphase-manager-base.hpp"
11#include "pinocchio/multibody/geometry-object-filter.hpp"
12
13namespace pinocchio
14{
15
16 template<typename _Manager>
17 struct BroadPhaseManagerTpl : public BroadPhaseManagerBase<BroadPhaseManagerTpl<_Manager>>
18 {
20
22 typedef std::vector<CollisionObject> CollisionObjectVector;
23 typedef Eigen::VectorXd VectorXs;
24 typedef _Manager Manager;
25
29
31 BroadPhaseManagerTpl() // for std::vector
32 : Base()
33 {
34 }
35
43 const Model * model_ptr,
48 {
50 selected_geometry_objects = filter.apply(geom_model.geometryObjects);
51
53 geometry_model_ptr->geometryObjects.size(), (std::numeric_limits<size_t>::max)());
55 for (size_t k = 0; k < selected_geometry_objects.size(); ++k)
56 {
59 collision_object_is_active[k] = !geom_model.geometryObjects[geometry_id].disableCollision;
60 }
61
62 selected_collision_pairs.reserve(geom_model.collisionPairs.size());
63 for (size_t k = 0; k < geom_model.collisionPairs.size(); ++k)
64 {
65 const CollisionPair & pair = geom_model.collisionPairs[k];
66 if (
67 geometry_to_collision_index[pair.first] != (std::numeric_limits<size_t>::max)()
68 && geometry_to_collision_index[pair.second] != (std::numeric_limits<size_t>::max)())
69 {
70 selected_collision_pairs.push_back(k);
71 }
72
74 }
75
77 static_cast<Eigen::DenseIndex>(selected_geometry_objects.size()));
78
79 init();
80 }
81
96
99 using Base::getModel;
100
108 void update(bool compute_local_aabb = false);
109
116
118
121 bool check() const;
122
124 bool check(CollisionCallBackBase * callback) const;
125
127 const CollisionObjectVector & getCollisionObjects() const
128 {
129 return collision_objects;
130 }
132 CollisionObjectVector & getCollisionObjects()
133 {
134 return collision_objects;
135 }
136
139 {
141 }
142
146
148 bool collide(CollisionCallBackBase * callback) const;
149
152
153 // /// @brief Performs distance computation between one object and all the objects belonging to
154 // the manager void distance(CollisionObject* obj, DistanceCallBackBase * callback) const;
155
156 // /// @brief Performs distance test for the objects belonging to the manager (i.e., N^2 self
157 // distance) void distance(DistanceCallBackBase * callback) const;
158
159 // /// @brief Performs distance test with objects belonging to another manager
160 // void distance(BroadPhaseCollisionManager* other_manager, DistanceCallBackBase * callback)
161 // const;
162
165 {
166 return manager;
167 }
168
170 const Manager & getManager() const
171 {
172 return manager;
173 }
174
176 const std::vector<bool> & getCollisionObjectStatus() const
177 {
179 }
180
181 protected:
184
186 CollisionObjectVector collision_objects;
187
190
192 std::vector<size_t> selected_geometry_objects;
193
195 std::vector<size_t> geometry_to_collision_index;
196
198 std::vector<size_t> selected_collision_pairs;
199
201 std::vector<bool> collision_object_is_active;
202
204 void init();
205
206 }; // struct BroadPhaseManagerTpl<BroadPhaseManagerDerived>
207
208} // namespace pinocchio
209
210/* --- Details -------------------------------------------------------------------- */
211#include "pinocchio/collision/broadphase-manager.hxx"
212
213#endif // ifndef __pinocchio_collision_broadphase_manager_hpp__
Main pinocchio namespace.
Definition treeview.dox:11
const GeometryData & getGeometryData() const
Returns the geometry data associated to the manager.
const GeometryModel * geometry_model_ptr
Pointer to the geometry model.
const Model & getModel() const
Returns the model associated to the manager.
const GeometryModel & getGeometryModel() const
Returns the geometry model associated to the manager.
const Manager & getManager() const
Returns internal manager.
void init()
Initialialisation of BroadPhaseManagerTpl.
void update(GeometryData *geom_data_ptr_new)
Update the manager with a new geometry data.
std::vector< bool > collision_object_is_active
Disable status related to each collision objects.
BroadPhaseManagerTpl(const BroadPhaseManagerTpl &other)
Copy contructor.
std::vector< size_t > geometry_to_collision_index
Mapping between a given geometry index and a collision index.
bool collide(CollisionObject &obj, CollisionCallBackBase *callback) const
Performs collision test between one object and all the objects belonging to the manager.
CollisionObjectVector collision_objects
the vector of collision objects.
const VectorXs & getCollisionObjectInflation()
Returns the inflation value related to each collision object.
VectorXs collision_object_inflation
the inflation value related to each collision object.
BroadPhaseManagerTpl()
Default constructor.
BroadPhaseManagerTpl(const Model *model_ptr, const GeometryModel *geometry_model_ptr, GeometryData *geometry_data_ptr, const GeometryObjectFilterBase &filter=GeometryObjectFilterNothing())
Constructor from a given geometry model and data.
const std::vector< bool > & getCollisionObjectStatus() const
Returns the status of the collision object.
bool check() const
Check whether the base broad phase manager is aligned with the current collision_objects.
bool check(CollisionCallBackBase *callback) const
Check whether the callback is inline with *this.
std::vector< size_t > selected_collision_pairs
Selected collision pairs in the original geometry_model.
Manager & getManager()
Returns internal manager.
bool collide(BroadPhaseManagerTpl &other_manager, CollisionCallBackBase *callback) const
Performs collision test with objects belonging to another manager.
std::vector< size_t > selected_geometry_objects
Selected geometry objects in the original geometry_model.
CollisionObjectVector & getCollisionObjects()
Returns the vector of collision objects associated to the manager.
void update(bool compute_local_aabb=false)
Update the manager from the current geometry positions and update the underlying FCL broad phase mana...
const CollisionObjectVector & getCollisionObjects() const
Returns the vector of collision objects associated to the manager.
bool collide(CollisionCallBackBase *callback) const
Performs collision test for the objects belonging to the manager.
Interface for Pinocchio collision callback functors.