OctomapCollisionChecker.cpp
Go to the documentation of this file.
1 // OctomapCollisionChecker.cpp
3 //
4 // Created on: Jan 24, 2014
5 // Author: mklingen
7 
8 #include "OctomapInterface.h"
10 #include "FastAABBTriangleTest.h"
11 
12 namespace or_octomap
13 {
14 
15  OctomapCollisionChecker::OctomapCollisionChecker(OpenRAVE::EnvironmentBasePtr env) :
16  CollisionCheckerBase(env), m_server(NULL), m_treeClone(NULL)
17  {
18  m_specialObject = "_OCTOMAP_MAP_";
19  }
20 
21  OctomapCollisionChecker::OctomapCollisionChecker(OpenRAVE::EnvironmentBasePtr env, OpenRAVE::CollisionCheckerBasePtr wrappedChecker, OctomapInterface* server) :
22  CollisionCheckerBase(env), m_wrappedChecker(wrappedChecker), m_server(server), m_treeClone(NULL)
23  {
24  m_specialObject = "_OCTOMAP_MAP_";
25 
26  // In this case there is no tree clone. We just use the tree from the server itself.
27  }
28 
30  {
31  if(m_treeClone)
32  {
33  delete m_treeClone;
34  m_treeClone = NULL;
35  }
36  }
37 
39  {
40  boost::mutex::scoped_lock(m_server->GetMutex());
41  if (m_treeClone)
42  {
43  return m_treeClone;
44  }
45 
46  if (m_server)
47  {
48  return m_server->GetTree();
49  }
50 
51  ROS_ERROR("No tree exists");
52  return NULL;
53  }
54 
55  void OctomapCollisionChecker::Clone(OpenRAVE::InterfaceBaseConstPtr preference, int cloningoptions)
56  {
57  boost::mutex::scoped_lock(m_server->GetMutex());
58  CollisionCheckerBase::Clone(preference, cloningoptions);
59 
60  const OctomapCollisionChecker* otherChecker = dynamic_cast<const OctomapCollisionChecker*>(preference.get());
61 
62  if(!otherChecker)
63  {
64  return;
65  }
66 
68  {
69  m_wrappedChecker->Clone(otherChecker->m_wrappedChecker, cloningoptions);
70  }
71  else
72  {
73  m_wrappedChecker = OpenRAVE::RaveCreateCollisionChecker(GetEnv(), otherChecker->m_wrappedChecker->GetXMLId());
74  m_wrappedChecker->Clone(otherChecker->m_wrappedChecker, cloningoptions);
75  }
76 
77  m_server = otherChecker->m_server;
78 
79  if(m_server)
80  {
81  m_treeClone = new octomap::OcTree(*(m_server->GetTree()));
82  }
83 
84  m_specialObject = otherChecker->m_specialObject;
85  }
86 
87  int OctomapCollisionChecker::CollisionTestTriangleAABB(const OpenRAVE::Vector& t1, const OpenRAVE::Vector& t2, const OpenRAVE::Vector& t3, float x, float y, float z, float eX, float eY, float eZ)
88  {
89  static float boxCenter[3];
90  boxCenter[0] = x;
91  boxCenter[1] = y;
92  boxCenter[2] = z;
93 
94  static float boxExtents[3];
95  boxExtents[0] = eX;
96  boxExtents[1] = eY;
97  boxExtents[2] = eZ;
98 
99  static float triVerts[3][3];
100 
101  triVerts[0][0] = t1.x;
102  triVerts[0][1] = t1.y;
103  triVerts[0][2] = t1.z;
104 
105  triVerts[1][0] = t2.x;
106  triVerts[1][1] = t2.y;
107  triVerts[1][2] = t2.z;
108 
109  triVerts[2][0] = t3.x;
110  triVerts[2][1] = t3.y;
111  triVerts[2][2] = t3.z;
112 
113  return FastAABTriangleTest::triBoxOverlap(boxCenter, boxExtents, triVerts);
114  }
115 
117  {
118  return m_wrappedChecker->SetCollisionOptions(collisionoptions);
119  }
120 
122  {
123  return m_wrappedChecker->GetCollisionOptions();
124  }
125 
126  void OctomapCollisionChecker::SetTolerance(OpenRAVE::dReal tolerance)
127  {
128  return m_wrappedChecker->SetTolerance(tolerance);
129  }
130 
131  bool OctomapCollisionChecker::InitKinBody(OpenRAVE::KinBodyPtr pbody)
132  {
133  return m_wrappedChecker->InitKinBody(pbody);
134  }
135 
136  bool OctomapCollisionChecker::CheckOctomapCollision(OpenRAVE::KinBodyConstPtr pbody1, OpenRAVE::CollisionReportPtr report)
137  {
138  std::vector<OpenRAVE::KinBodyConstPtr> vbodyExcluded;
139  const std::vector< OpenRAVE::KinBody::LinkConstPtr > vlinkExcluded;
140  return CheckOctomapCollision(pbody1, vbodyExcluded, vlinkExcluded, report);
141  }
142 
143  bool OctomapCollisionChecker::CheckOctomapCollision(OpenRAVE::KinBodyConstPtr pbody1, OpenRAVE::KinBodyConstPtr pbody2, OpenRAVE::CollisionReportPtr report)
144  {
145  if(pbody1->GetName() != m_specialObject && pbody2->GetName() != m_specialObject)
146  {
147  return false;
148  }
149  else if(pbody1->GetName() == m_specialObject && pbody2->GetName() != m_specialObject)
150  {
151  return CheckOctomapCollision(pbody2, report);
152  }
153  else if(pbody1->GetName() != m_specialObject && pbody2->GetName() == m_specialObject)
154  {
155  return CheckOctomapCollision(pbody1, report);
156  }
157  else
158  {
159  return false;
160  }
161  }
162 
163  bool OctomapCollisionChecker::CheckOctomapCollision(OpenRAVE::KinBody::LinkConstPtr plink, OpenRAVE::CollisionReportPtr report)
164  {
165  std::vector<OpenRAVE::KinBodyConstPtr> vbodyExcluded;
166  const std::vector< OpenRAVE::KinBody::LinkConstPtr > vlinkExcluded;
167  return CheckOctomapCollision(plink, vbodyExcluded, vlinkExcluded, report);
168  }
169 
170  bool OctomapCollisionChecker::CheckOctomapCollision(OpenRAVE::KinBody::LinkConstPtr plink1, OpenRAVE::KinBody::LinkConstPtr plink2, OpenRAVE::CollisionReportPtr report)
171  {
172  // Octomap tree never has links
173  return false;
174  }
175 
176  bool OctomapCollisionChecker::CheckOctomapCollision(OpenRAVE::KinBody::LinkConstPtr plink, OpenRAVE::KinBodyConstPtr pbody, OpenRAVE::CollisionReportPtr report)
177  {
178  if(pbody->GetName() != m_specialObject)
179  {
180  return false;
181  }
182 
183  return CheckOctomapCollision(plink, report);
184  }
185 
186  bool OctomapCollisionChecker::ContainsSpecialBody(const std::vector<OpenRAVE::KinBodyConstPtr>& bodies)
187  {
188  for(size_t i = 0; i < bodies.size(); i++)
189  {
190  if(bodies[i]->GetName() == m_specialObject)
191  {
192  return true;
193  }
194  }
195 
196  return false;
197  }
198 
199  bool OctomapCollisionChecker::ContainsBody(const std::vector<OpenRAVE::KinBodyConstPtr>& links, OpenRAVE::KinBodyConstPtr link)
200  {
201  for(size_t i = 0; i < links.size(); i++)
202  {
203  if(links[i] == link)
204  {
205  return true;
206  }
207  }
208 
209  return false;
210  }
211 
212  bool OctomapCollisionChecker::ContainsLink(const std::vector<OpenRAVE::KinBody::LinkConstPtr>& links, OpenRAVE::KinBody::LinkConstPtr link)
213  {
214  for(size_t i = 0; i < links.size(); i++)
215  {
216  if(links[i] == link)
217  {
218  return true;
219  }
220  }
221 
222  return false;
223  }
224 
225  inline float min(float a, float b, float c)
226  {
227  return fmin(a, fmin(b, c));
228  }
229 
230  inline float max(float a, float b, float c)
231  {
232  return fmax(a, fmax(b, c));
233  }
234 
235  void OctomapCollisionChecker::ComputeTriangleAABB(const OpenRAVE::Vector& t1, const OpenRAVE::Vector& t2, const OpenRAVE::Vector& t3, OpenRAVE::AABB& aabb)
236  {
237 
238  float minX = min(t1.x, t2.x, t3.x);
239  float minY = min(t1.y, t2.y, t3.y);
240  float minZ = min(t1.z, t2.z, t3.z);
241 
242  float maxX = max(t1.x, t2.x, t3.x);
243  float maxY = max(t1.y, t2.y, t3.y);
244  float maxZ = max(t1.z, t2.z, t3.z);
245 
246 
247  aabb.pos.x = (minX + maxX) * 0.5f;
248  aabb.pos.y = (minY + maxY) * 0.5f;
249  aabb.pos.z = (minZ + maxZ) * 0.5f;
250 
251  aabb.extents.x = (maxX - minX) * 0.5f;
252  aabb.extents.y = (maxY - minY) * 0.5f;
253  aabb.extents.z = (maxZ - minZ) * 0.5f;
254 
255  }
256 
257  int OctomapCollisionChecker::CollisionTestTriangle(const OpenRAVE::Vector& t1, const OpenRAVE::Vector& t2, const OpenRAVE::Vector& t3, octomap::OcTree::leaf_bbx_iterator& it)
258  {
259  const octomap::point3d& point = it.getCoordinate();
260  double resolution = it.getSize();
261 
262  int check = CollisionTestTriangleAABB(t1, t2, t3, point.x(), point.y(), point.z(), resolution, resolution, resolution);
263  if(check)
264  {
265  return check;
266  }
267  return 0;
268  }
269 
270  bool OctomapCollisionChecker::CheckOctomapCollision(OpenRAVE::KinBody::LinkConstPtr plink, const std::vector< OpenRAVE::KinBodyConstPtr > &vbodyexcluded, const std::vector< OpenRAVE::KinBody::LinkConstPtr > &vlinkexcluded, OpenRAVE::CollisionReportPtr report)
271  {
272  //TODO: Fill report!
273  if(ContainsSpecialBody(vbodyexcluded))
274  {
275  return false;
276  }
277 
278  OpenRAVE::AABB aabb = plink->ComputeAABB();
279 
280  const OpenRAVE::TriMesh& mesh = plink->GetCollisionData();
281 
282  OpenRAVE::Transform globalTransform = plink->GetTransform();
283 
284  octomap::OcTree::leaf_bbx_iterator leafIterBegin = GetTreeClone()->begin_leafs_bbx(octomap::point3d(aabb.pos.x - aabb.extents.x, aabb.pos.y - aabb.extents.y, aabb.pos.z - aabb.extents.z), octomap::point3d(aabb.pos.x + aabb.extents.x, aabb.pos.y + aabb.extents.y, aabb.pos.z + aabb.extents.z));
285  octomap::OcTree::leaf_bbx_iterator endIter = GetTreeClone()->end_leafs_bbx();
286 
287 
288  for(octomap::OcTree::leaf_bbx_iterator it = leafIterBegin; it!= endIter; it++)
289  {
290  if(it->getOccupancy() <= GetTreeClone()->getOccupancyThres())
291  {
292  continue;
293  }
294 
295  for(size_t j = 0; j < mesh.indices.size() / 3; j++)
296  {
297  OpenRAVE::Vector v1 = globalTransform * mesh.vertices.at(mesh.indices.at(j * 3 + 0));
298  OpenRAVE::Vector v2 = globalTransform * mesh.vertices.at(mesh.indices.at(j * 3 + 1));
299  OpenRAVE::Vector v3 = globalTransform * mesh.vertices.at(mesh.indices.at(j * 3 + 2));
300 
301  bool collides = CollisionTestTriangle(v1, v2, v3, it);
302 
303  if(collides)
304  {
305  return true;
306  }
307  }
308  }
309  return false;
310  }
311 
312  bool OctomapCollisionChecker::CheckOctomapCollision(OpenRAVE::KinBodyConstPtr pbody, const std::vector< OpenRAVE::KinBodyConstPtr > &vbodyexcluded, const std::vector< OpenRAVE::KinBody::LinkConstPtr > &vlinkexcluded, OpenRAVE::CollisionReportPtr report)
313  {
314  //TODO: Fill report!
315  if(ContainsSpecialBody(vbodyexcluded))
316  {
317  return false;
318  }
319 
320  if(pbody->GetName() != m_specialObject)
321  {
322  OpenRAVE::AABB aabb = pbody->ComputeAABB();
323 
324  octomap::point3d minPoint = octomap::point3d(aabb.pos.x - aabb.extents.x, aabb.pos.y - aabb.extents.y, aabb.pos.z - aabb.extents.z);
325  octomap::point3d maxPoint = octomap::point3d(aabb.pos.x + aabb.extents.x, aabb.pos.y + aabb.extents.y, aabb.pos.z + aabb.extents.z);
326 
327  octomap::OcTree::leaf_bbx_iterator it = GetTreeClone()->begin_leafs_bbx(minPoint, maxPoint);
328  bool foundOccupied = false;
329  while(it != GetTreeClone()->end_leafs_bbx())
330  {
331  if(it->getOccupancy() > GetTreeClone()->getOccupancyThres())
332  {
333  foundOccupied = true;
334  break;
335  }
336  it++;
337  }
338 
339  if(!foundOccupied) return false;
340 
341  for(size_t i = 0; i < pbody->GetLinks().size(); i++)
342  {
343  //ros::Time startLinkTime = ros::Time::now();
344  OpenRAVE::KinBody::LinkConstPtr link = pbody->GetLinks().at(i);
345 
346  if(ContainsLink(vlinkexcluded, link))
347  {
348  continue;
349  }
350 
351  bool collides = CheckOctomapCollision(link, vbodyexcluded, vlinkexcluded, report);
352 
353  if(collides)
354  {
355  return true;
356  }
357  }
358  }
359  else
360  {
361  std::vector<OpenRAVE::KinBodyPtr> bodies;
362  GetEnv()->GetBodies(bodies);
363 
364  for(size_t i = 0; i < bodies.size(); i++)
365  {
366  OpenRAVE::KinBodyConstPtr body = bodies.at(i);
367 
368  if(body->GetName() == m_specialObject || ContainsBody(vbodyexcluded, body))
369  {
370  continue;
371  }
372 
373  bool collidesBody = CheckOctomapCollision(body, vbodyexcluded, vlinkexcluded, report);
374 
375  if(collidesBody)
376  {
377  return true;
378  }
379  }
380  }
381  return false;
382  }
383 
384  bool OctomapCollisionChecker::CheckOctomapCollision(const OpenRAVE::RAY &ray, OpenRAVE::KinBody::LinkConstPtr plink, OpenRAVE::CollisionReportPtr report)
385  {
386  // Octomap never has links
387  return false;
388  }
389 
390  bool OctomapCollisionChecker::CheckOctomapCollision(const OpenRAVE::RAY &ray, OpenRAVE::KinBodyConstPtr pbody, OpenRAVE::CollisionReportPtr report)
391  {
392  if(pbody->GetName() != m_specialObject)
393  {
394  return false;
395  }
396 
397  return CheckOctomapCollision(ray, report);
398  }
399 
400  bool OctomapCollisionChecker::CheckOctomapCollision(const OpenRAVE::RAY &ray, OpenRAVE::CollisionReportPtr report)
401  {
402  octomap::point3d origin;
403  origin(0) = ray.pos.x;
404  origin(1) = ray.pos.y;
405  origin(2) = ray.pos.z;
406 
407  octomap::point3d dir;
408  dir(0) = ray.dir.x;
409  dir(1) = ray.dir.y;
410  dir(2) = ray.dir.z;
411 
412  octomap::point3d end;
413 
414  dir.normalize();
415 
416  // TODO: Fill report.
417  bool collision = GetTreeClone()->castRay(origin, dir, end, true, ray.dir.lengthsqr3());
418  report->minDistance = (end - origin).norm();
419 
420  return collision;
421  }
422 
423 
424  bool OctomapCollisionChecker::CheckCollision(OpenRAVE::KinBodyConstPtr pbody1, OpenRAVE::CollisionReportPtr report)
425  {
426  bool collides = m_wrappedChecker->CheckCollision(pbody1, report);
427  collides = collides || CheckOctomapCollision(pbody1, report);
428  return collides;
429  }
430 
431  bool OctomapCollisionChecker::CheckCollision(OpenRAVE::KinBodyConstPtr pbody1, OpenRAVE::KinBodyConstPtr pbody2, OpenRAVE::CollisionReportPtr report)
432  {
433  return m_wrappedChecker->CheckCollision(pbody1, pbody2, report) || CheckOctomapCollision(pbody1, pbody2, report);
434  }
435 
436  bool OctomapCollisionChecker::CheckCollision(OpenRAVE::KinBody::LinkConstPtr plink, OpenRAVE::CollisionReportPtr report)
437  {
438  return m_wrappedChecker->CheckCollision(plink, report) || CheckOctomapCollision(plink, report);
439  }
440 
441  bool OctomapCollisionChecker::CheckCollision(OpenRAVE::KinBody::LinkConstPtr plink1, OpenRAVE::KinBody::LinkConstPtr plink2, OpenRAVE::CollisionReportPtr report)
442  {
443  return m_wrappedChecker->CheckCollision(plink1, plink2, report) || CheckOctomapCollision(plink1, plink2, report);
444  }
445 
446  bool OctomapCollisionChecker::CheckCollision(OpenRAVE::KinBody::LinkConstPtr plink, OpenRAVE::KinBodyConstPtr pbody, OpenRAVE::CollisionReportPtr report)
447  {
448  return m_wrappedChecker->CheckCollision(plink, pbody, report) || CheckOctomapCollision(plink, pbody, report);
449  }
450 
451  bool OctomapCollisionChecker::CheckCollision(OpenRAVE::KinBody::LinkConstPtr plink, const std::vector< OpenRAVE::KinBodyConstPtr > &vbodyexcluded, const std::vector< OpenRAVE::KinBody::LinkConstPtr > &vlinkexcluded, OpenRAVE::CollisionReportPtr report)
452  {
453  return m_wrappedChecker->CheckCollision(plink, vbodyexcluded, vlinkexcluded, report) || CheckOctomapCollision(plink, vbodyexcluded, vlinkexcluded, report);
454  }
455 
456  bool OctomapCollisionChecker::CheckCollision(OpenRAVE::KinBodyConstPtr pbody, const std::vector< OpenRAVE::KinBodyConstPtr > &vbodyexcluded, const std::vector< OpenRAVE::KinBody::LinkConstPtr > &vlinkexcluded, OpenRAVE::CollisionReportPtr report)
457  {
458  return m_wrappedChecker->CheckCollision(pbody, vbodyexcluded, vlinkexcluded, report) || CheckOctomapCollision(pbody, vbodyexcluded, vlinkexcluded, report);
459  }
460 
461  bool OctomapCollisionChecker::CheckCollision(const OpenRAVE::RAY &ray, OpenRAVE::KinBody::LinkConstPtr plink, OpenRAVE::CollisionReportPtr report)
462  {
463  return m_wrappedChecker->CheckCollision(ray, plink, report) || CheckOctomapCollision(ray, plink, report);
464  }
465 
466  bool OctomapCollisionChecker::CheckCollision(const OpenRAVE::RAY &ray, OpenRAVE::KinBodyConstPtr pbody, OpenRAVE::CollisionReportPtr report)
467  {
468  return m_wrappedChecker->CheckCollision(ray, pbody, report)|| CheckOctomapCollision(ray, pbody, report);
469  }
470 
471  bool OctomapCollisionChecker::CheckCollision(const OpenRAVE::RAY &ray, OpenRAVE::CollisionReportPtr report)
472  {
473  return m_wrappedChecker->CheckCollision(ray, report) || CheckOctomapCollision(ray, report);
474  }
475 
476  bool OctomapCollisionChecker::CheckStandaloneSelfCollision(OpenRAVE::KinBodyConstPtr body, OpenRAVE::CollisionReportPtr report)
477  {
478  return m_wrappedChecker->CheckStandaloneSelfCollision(body, report);
479  }
480 
481  bool OctomapCollisionChecker::CheckStandaloneSelfCollision(OpenRAVE::KinBody::LinkConstPtr body, OpenRAVE::CollisionReportPtr report)
482  {
483  return m_wrappedChecker->CheckStandaloneSelfCollision(body, report);
484  }
485 
487  {
488  return m_wrappedChecker->InitEnvironment();
489  }
490 
492  {
493  return m_wrappedChecker->DestroyEnvironment();
494  }
495 
496 
497  void OctomapCollisionChecker::RemoveKinBody(OpenRAVE::KinBodyPtr body)
498  {
499  m_wrappedChecker->RemoveKinBody(body);
500  }
501 
502  void OctomapCollisionChecker::GetNodesColliding(const std::string& objectName, std::vector<octomap::OcTreeNode*>& nodes)
503  {
504  ROS_INFO("Finding nodes colliding with %s\n", objectName.c_str());
505  octomap::OcTree* tree = GetTreeClone();
506 
507  if (!tree->getRoot())
508  {
509  ROS_WARN("Tree has no root.\n");
510  return;
511  }
512 
513  OpenRAVE::KinBodyPtr pbody = GetEnv()->GetKinBody(objectName);
514 
515  if(!pbody.get())
516  {
517  ROS_WARN("Unable to find object %s\n", objectName.c_str());
518  return;
519  }
520  else
521  {
522  ROS_INFO("Masking...\n");
523  }
524 
525  OpenRAVE::AABB aabb = pbody->ComputeAABB();
526  if (!GetTreeClone())
527  {
528  ROS_ERROR("No tree!\n");
529  return;
530  }
531  float halfResolution = tree->getResolution() * 1.5f;
532 
533  for(size_t i = 0; i < pbody->GetLinks().size(); i++)
534  {
535  OpenRAVE::KinBody::LinkConstPtr plink = pbody->GetLinks().at(i);
536 
537  aabb = plink->ComputeAABB();
538  aabb.extents *= 1.25f;
539 
540  octomap::point3d minPoint = octomap::point3d(aabb.pos.x - aabb.extents.x, aabb.pos.y - aabb.extents.y, aabb.pos.z - aabb.extents.z);
541  octomap::point3d maxPoint = octomap::point3d(aabb.pos.x + aabb.extents.x, aabb.pos.y + aabb.extents.y, aabb.pos.z + aabb.extents.z);
542  ROS_INFO("Computing nodes for link %s\n", plink->GetName().c_str());
543  ROS_INFO("Bounding box is %f %f %f %f %f %f\n", minPoint.x(), minPoint.y(), minPoint.z(), maxPoint.x(), maxPoint.y(), maxPoint.z());
544  octomap::OcTree::leaf_bbx_iterator it = tree->begin_leafs_bbx(minPoint, maxPoint);
545  printf("Created iterator\n");
546  bool foundOccupied = false;
547  while(it !=tree->end_leafs_bbx())
548  {
549  if(it->getOccupancy() > tree->getOccupancyThres())
550  {
551  foundOccupied = true;
552  break;
553  }
554  it++;
555  }
556 
557  if(!foundOccupied) continue;
558 
559  const OpenRAVE::TriMesh& mesh = plink->GetCollisionData();
560 
561  OpenRAVE::Transform globalTransform = plink->GetTransform();
562 
563  octomap::OcTree::leaf_bbx_iterator leafIterBegin = tree->begin_leafs_bbx(octomap::point3d(aabb.pos.x - aabb.extents.x, aabb.pos.y - aabb.extents.y, aabb.pos.z - aabb.extents.z), octomap::point3d(aabb.pos.x + aabb.extents.x, aabb.pos.y + aabb.extents.y, aabb.pos.z + aabb.extents.z));
564  octomap::OcTree::leaf_bbx_iterator endIter = tree->end_leafs_bbx();
565 
566  for(octomap::OcTree::leaf_bbx_iterator it = leafIterBegin; it!= endIter; it++)
567  {
568  const octomap::point3d& point = it.getCoordinate();
569  float size = it.getSize() * 1.5f;
570 
571  if(it->getOccupancy() > tree->getOccupancyThres())
572  {
573  for(size_t j = 0; j < mesh.indices.size() / 3; j++)
574  {
575  OpenRAVE::Vector t1 = globalTransform * mesh.vertices.at(mesh.indices.at(j * 3 + 0));
576  OpenRAVE::Vector t2 = globalTransform * mesh.vertices.at(mesh.indices.at(j * 3 + 1));
577  OpenRAVE::Vector t3 = globalTransform * mesh.vertices.at(mesh.indices.at(j * 3 + 2));
578 
579  int check = CollisionTestTriangleAABB(t1, t2, t3, point.x(), point.y(), point.z(), size, size, size);
580 
581  if(check)
582  {
583  nodes.push_back(tree->search(it.getKey()));
584  }
585  }
586  }
587  }
588  }
589  }
590 
591  bool OctomapCollisionChecker::MaskObject(std::string name)
592  {
593  std::vector<octomap::OcTreeNode*> nodes;
594  GetNodesColliding(name, nodes);
595 
596  ROS_INFO("Got %lu colliding nodes\n", nodes.size());
597  for(std::vector<octomap::OcTreeNode*>::iterator it = nodes.begin(); it != nodes.end(); it++)
598  {
599  if(*it)
600  {
601  for(int i = 0; i < 10; i++)
602  GetTreeClone()->integrateMiss(*it);
603  }
604  }
605  return true;
606  }
607 } /* namespace perception_utils */
void ComputeTriangleAABB(const OpenRAVE::Vector &t1, const OpenRAVE::Vector &t2, const OpenRAVE::Vector &t3, OpenRAVE::AABB &aabb)
int CollisionTestTriangleAABB(const OpenRAVE::Vector &t1, const OpenRAVE::Vector &t2, const OpenRAVE::Vector &t3, float x, float y, float z, float eX, float eY, float eZ)
OpenRAVE::CollisionCheckerBasePtr m_wrappedChecker
virtual bool CheckCollision(OpenRAVE::KinBodyConstPtr pbody1, OpenRAVE::CollisionReportPtr report=OpenRAVE::CollisionReportPtr())
OctomapCollisionChecker(OpenRAVE::EnvironmentBasePtr env)
virtual bool CheckStandaloneSelfCollision(OpenRAVE::KinBodyConstPtr body, OpenRAVE::CollisionReportPtr report=OpenRAVE::CollisionReportPtr())
bool ContainsBody(const std::vector< OpenRAVE::KinBodyConstPtr > &links, OpenRAVE::KinBodyConstPtr link)
float max(float a, float b, float c)
bool ContainsLink(const std::vector< OpenRAVE::KinBody::LinkConstPtr > &links, OpenRAVE::KinBody::LinkConstPtr link)
virtual void Clone(OpenRAVE::InterfaceBaseConstPtr preference, int cloningoptions)
octomap::OcTree * GetTree()
float min(float a, float b, float c)
void GetNodesColliding(const std::string &objectName, std::vector< octomap::OcTreeNode * > &nodes)
virtual bool CheckOctomapCollision(OpenRAVE::KinBodyConstPtr pbody1, OpenRAVE::CollisionReportPtr report=OpenRAVE::CollisionReportPtr())
virtual bool SetCollisionOptions(int collisionoptions)
virtual void RemoveKinBody(OpenRAVE::KinBodyPtr body)
virtual bool InitKinBody(OpenRAVE::KinBodyPtr pbody)
bool ContainsSpecialBody(const std::vector< OpenRAVE::KinBodyConstPtr > &bodies)
int CollisionTestTriangle(const OpenRAVE::Vector &t1, const OpenRAVE::Vector &t2, const OpenRAVE::Vector &t3, octomap::OcTree::leaf_bbx_iterator &it)
virtual void SetTolerance(OpenRAVE::dReal tolerance)
int triBoxOverlap(float boxcenter[3], float boxhalfsize[3], float triverts[3][3])


or_octomap_plugin
Author(s): Yan Yu
autogenerated on Tue Oct 24 2017 18:02:48