Collision Checker
trajectory_queries.h
Go to the documentation of this file.
1 #ifndef CPP_COLLISION_INCLUDE_COLLISION_SOLVERS_TRAJECTORY_QUERIES_H_
2 #define CPP_COLLISION_INCLUDE_COLLISION_SOLVERS_TRAJECTORY_QUERIES_H_
3 
6 
7 namespace collision {
8 
13 };
14 
16 
19  : enable_verification(false),
20  broadphase_class(BC_UNIFORMGRID),
21  num_cells(32),
22  fcl_broadphase_type(0),
23  fcl_num_buckets(1000),
24  auto_orientation(true),
25  optimize_triangles(true){};
28  int num_cells;
33 };
34 
36 
39  aligned_vector<int>* result;
40 };
41 
42 namespace trajectory_queries {
43 
46  trajectories_in,
48  dynamic_obstacles,
49  TrajectoryQueryResult& res, const TrajectoryRequest& treq);
52  trajectories_in,
53  const collision::ShapeGroup& static_obstacles, TrajectoryQueryResult& res,
54  const TrajectoryRequest& treq);
57  trajectories_in,
58  const collision::ShapeGroup& polygons, TrajectoryQueryResult& res,
59  const TrajectoryRequest& treq);
60 
63 
64 namespace deprecated { // slow deprecated functions for trajectory collision
65  // and polygon enclosure checks
66 
68  const RectangleOBB& pos1,
69  const RectangleOBB& pos2,
70  bool& res);
71 
73  const RectangleOBB& pos1,
74  const RectangleOBB& pos2,
75  bool& res);
76 
78  const ShapeGroup& sg, const RectangleOBB& pos1, const RectangleOBB& pos2,
79  bool& res);
80 
82  const ShapeGroup& sg, const RectangleOBB& pos1, const RectangleOBB& pos2,
83  bool& res);
84 } // namespace deprecated
85 
86 } // namespace trajectory_queries
87 
88 namespace detail {
89 
91  public:
93  typedef Eigen::Matrix<int, Eigen::Dynamic, 1> VectorXi;
94  typedef std::vector<OBB, Eigen::aligned_allocator<OBB>>::const_iterator
96 
97  int size(void) const { return traj_offsets_.size(); }
98 
99  int get_object_at_time_ptr(int traj_id, int timestep, OBB& obb,
100  AABB& aabb) const {
101  if (!(traj_id >= 0 && traj_id < size())) {
102  return -1;
103  }
104  int start_step = start_step_(traj_id);
105  int end_step = start_step + traj_length_ - 1;
106 
107  if (!((timestep >= start_step) && (timestep <= end_step))) {
108  return -1;
109  }
110 
111  if (!(aabbs_valid_)) computeAABBs();
112 
113  int real_timestep = timestep - start_step;
114  int offset = traj_offsets_[traj_id] + real_timestep;
115  aabb = *(aabb_begin_ + offset);
116  obb = *(obb_begin_ + offset);
117  return 0;
118  }
119 
120  void invalidateAABBs(void) { aabbs_valid_ = false; }
121 
122  // no input argument verification
123  int get_start_step(int traj_id) const { return start_step_[traj_id]; }
124 
125  // no verification of trajectory length
126  VectorXi get_start_step(void) const { return start_step_; }
127 
128  int length(void) const { return traj_length_; }
129 
130  // no checking if trajectory batch is empty
131  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
133  std::vector<OBB, Eigen::aligned_allocator<OBB>> rectangles,
134  int traj_length, const VectorXi& start_step)
135  : rectangles_(rectangles),
136  traj_length_(traj_length),
137  start_step_(start_step) {
138  int num_traj = rectangles.size() / traj_length;
139  if (num_traj * traj_length != rectangles.size()) throw;
140 
141  num_traj_ = num_traj;
142 
143  traj_offsets_.resize(num_traj_);
144 
145  for (int cc1 = 0; cc1 < num_traj; cc1++) {
146  traj_offsets_[cc1] = cc1 * traj_length;
147  }
148 
149  aabb_begin_ = aabbs_.begin();
150  obb_begin_ = rectangles_.begin();
151  invalidateAABBs();
152  }
153 
154  int computeAABBs(void) const {
155  aabbs_.clear();
156  aabbs_.reserve(rectangles_.size());
157  for (int cc1 = 0; cc1 < rectangles_.size(); cc1++) {
158  aabbs_.push_back(rectangles_[cc1].getAABB());
159  }
160  aabb_begin_ = aabbs_.begin();
161  aabbs_valid_ = true;
162  return 0;
163  }
164 
165  int preprocess_inplace(void);
166 
167  private:
168  std::vector<OBB, Eigen::aligned_allocator<OBB>> rectangles_;
169  mutable std::vector<AABB, Eigen::aligned_allocator<AABB>> aabbs_;
170  mutable std::vector<AABB, Eigen::aligned_allocator<AABB>>::iterator
171  aabb_begin_;
172  std::vector<OBB, Eigen::aligned_allocator<OBB>>::iterator obb_begin_;
173  mutable bool aabbs_valid_;
174  int num_traj_;
175  std::vector<int> traj_offsets_;
176  VectorXi start_step_;
177  int traj_length_;
178 };
179 
180 } // namespace detail
181 
182 } // namespace collision
183 
184 #endif /* CPP_COLLISION_INCLUDE_COLLISION_SOLVERS_TRAJECTORY_QUERIES_H_ */
Oriented rectangle.
Definition: rectangle_obb.h:19
std::vector< T, boost::alignment::aligned_allocator< T, 16 > > aligned_vector
Definition: declarations.h:9
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OBBDenseTrajectoryBatch(std::vector< OBB, Eigen::aligned_allocator< OBB >> rectangles, int traj_length, const VectorXi &start_step)
TimeVariantCollisionObject can contain a different CollisionObject or ShapeGroup at each time step...
std::size_t ccd_trajectory_test_polygon_enclosure_obb_sum(const ShapeGroup &sg, const RectangleOBB &pos1, const RectangleOBB &pos2, bool &res)
Checks if the over-approximative OBB box (OBB sum hull) for the two given OBB boxes boxes is enclosed...
int trajectories_collision_time_dynamic_obstacles(const aligned_vector< const collision::TimeVariantCollisionObject *> &trajectories_in, const aligned_vector< const collision::TimeVariantCollisionObject *> &dynamic_obstacles, TrajectoryQueryResult &res, const TrajectoryRequest &treq)
TrajectoryRequestBroadphaseClass
std::vector< OBB, Eigen::aligned_allocator< OBB > >::const_iterator OBBConstIterator
std::size_t ccd_trajectory_test_polygon_enclosure_chull(const ShapeGroup &sg, const RectangleOBB &pos1, const RectangleOBB &pos2, bool &res)
Checks if the convex hull of the Boolean union of two given OBB boxes is enclosed within the ShapeGro...
ShapeGroup can contain simple shapes.
Definition: shape_group.h:33
AABB getAABB(const CollisionObject *obj)
int get_object_at_time_ptr(int traj_id, int timestep, OBB &obb, AABB &aabb) const
int trajectory_preprocess_obb_sum(const TimeVariantCollisionObject *obj_old, TimeVariantCollisionObjectPtr &obj_new)
Preprocesses a TimeVariantCollisionObject for continuous collision detection using OBB sum hull for t...
std::size_t ccd_trajectory_test_collision_chull(const ShapeGroup &sg, const RectangleOBB &pos1, const RectangleOBB &pos2, bool &res)
Checks if the convex hull of the Boolean union of two given OBB boxes collides with any of the ShapeG...
int trajectories_enclosure_time_polygons_static(const aligned_vector< const collision::TimeVariantCollisionObject *> &trajectories_in, const collision::ShapeGroup &polygons, TrajectoryQueryResult &res, const TrajectoryRequest &treq)
int trajectories_collision_time_static_obstacles(const aligned_vector< const collision::TimeVariantCollisionObject *> &trajectories_in, const collision::ShapeGroup &static_obstacles, TrajectoryQueryResult &res, const TrajectoryRequest &treq)
TrajectoryQueryResultCollisionTime(aligned_vector< int > *res)
std::size_t ccd_trajectory_test_collision_obb_sum(const ShapeGroup &sg, const RectangleOBB &pos1, const RectangleOBB &pos2, bool &res)
Checks if the over-approximative OBB box (OBB sum hull) for the two given OBB boxes collides with any...
Eigen::Matrix< int, Eigen::Dynamic, 1 > VectorXi
TrajectoryRequestBroadphaseClass broadphase_class
std::shared_ptr< TimeVariantCollisionObject > TimeVariantCollisionObjectPtr