moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
collision_distance_field_types.cpp
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2010, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Author: E. Gil Jones */
36
38#include <geometric_shapes/body_operations.h>
41#include <rclcpp/clock.hpp>
42#include <rclcpp/logger.hpp>
43#include <rclcpp/time.hpp>
44#include <memory>
46
47static const double EPSILON{ 0.0001 };
48
49namespace collision_detection
50{
51namespace
52{
53rclcpp::Logger getLogger()
54{
55 return moveit::getLogger("moveit.core.collision_distance_field_types");
56}
57} // namespace
58
59std::vector<CollisionSphere> determineCollisionSpheres(const bodies::Body* body, Eigen::Isometry3d& relative_transform)
60{
61 std::vector<CollisionSphere> css;
62
63 if (body->getType() == shapes::ShapeType::SPHERE)
64 {
65 collision_detection::CollisionSphere cs(body->getPose().translation(), body->getDimensions()[0]);
66 css.push_back(cs);
67 }
68 else
69 {
70 bodies::BoundingCylinder cyl;
71 body->computeBoundingCylinder(cyl);
72 unsigned int num_points = ceil(cyl.length / (cyl.radius / 2.0));
73 double spacing{ cyl.length / ((num_points * 1.0) - 1.0) };
74 relative_transform = cyl.pose;
75
76 for (unsigned int i{ 1 }; i < num_points - 1; i++)
77 {
79 relative_transform * Eigen::Vector3d(0, 0, (-cyl.length / 2.0) + i * spacing), cyl.radius);
80 css.push_back(cs);
81 }
82 }
83
84 return css;
85}
86
87bool PosedDistanceField::getCollisionSphereGradients(const std::vector<CollisionSphere>& sphere_list,
88 const EigenSTL::vector_Vector3d& sphere_centers,
89 GradientInfo& gradient, const CollisionType& type,
90 double tolerance, bool subtract_radii, double maximum_value,
91 bool stop_at_first_collision)
92{
93 // assumes gradient is properly initialized
94
95 bool in_collision{ false };
96 for (unsigned int i{ 0 }; i < sphere_list.size(); ++i)
97 {
98 Eigen::Vector3d p = sphere_centers[i];
99 Eigen::Vector3d grad(0, 0, 0);
100 bool in_bounds;
101 double dist = getDistanceGradient(p.x(), p.y(), p.z(), grad.x(), grad.y(), grad.z(), in_bounds);
102 if (!in_bounds && grad.norm() > 0)
103 {
104 // out of bounds
105 return true;
106 }
107
108 if (dist < maximum_value)
109 {
110 if (subtract_radii)
111 {
112 dist -= sphere_list[i].radius_;
113
114 if ((dist < 0) && (-dist >= tolerance))
115 {
116 in_collision = true;
117 }
118
119 dist = std::abs(dist);
120 }
121 else
122 {
123 if (sphere_list[i].radius_ - dist > tolerance)
124 {
125 in_collision = true;
126 }
127 }
128
129 if (dist < gradient.closest_distance)
130 {
131 gradient.closest_distance = dist;
132 }
133
134 if (dist < gradient.distances[i])
135 {
136 gradient.types[i] = type;
137 gradient.distances[i] = dist;
138 gradient.gradients[i] = grad;
139 }
140 }
141
142 if (stop_at_first_collision && in_collision)
143 {
144 return true;
145 }
146 }
147 return in_collision;
148}
149
151 const std::vector<CollisionSphere>& sphere_list,
152 const EigenSTL::vector_Vector3d& sphere_centers, GradientInfo& gradient,
153 const CollisionType& type, double tolerance, bool subtract_radii, double maximum_value,
154 bool stop_at_first_collision)
155{
156 // assumes gradient is properly initialized
157
158 bool in_collision{ false };
159 for (unsigned int i{ 0 }; i < sphere_list.size(); ++i)
160 {
161 Eigen::Vector3d p = sphere_centers[i];
162 Eigen::Vector3d grad;
163 bool in_bounds;
164 double dist = distance_field->getDistanceGradient(p.x(), p.y(), p.z(), grad.x(), grad.y(), grad.z(), in_bounds);
165 if (!in_bounds && grad.norm() > EPSILON)
166 {
167 RCLCPP_DEBUG(getLogger(), "Collision sphere point is out of bounds %lf, %lf, %lf", p.x(), p.y(), p.z());
168 return true;
169 }
170
171 if (dist < maximum_value)
172 {
173 if (subtract_radii)
174 {
175 dist -= sphere_list[i].radius_;
176
177 if ((dist < 0) && (-dist >= tolerance))
178 {
179 in_collision = true;
180 }
181 }
182 else
183 {
184 if (sphere_list[i].radius_ - dist > tolerance)
185 {
186 in_collision = true;
187 }
188 }
189
190 if (dist < gradient.closest_distance)
191 {
192 gradient.closest_distance = dist;
193 }
194
195 if (dist < gradient.distances[i])
196 {
197 gradient.types[i] = type;
198 gradient.distances[i] = dist;
199 gradient.gradients[i] = grad;
200 }
201 }
202
203 if (stop_at_first_collision && in_collision)
204 {
205 return true;
206 }
207 }
208 return in_collision;
209}
210
212 const std::vector<CollisionSphere>& sphere_list,
213 const EigenSTL::vector_Vector3d& sphere_centers, double maximum_value,
214 double tolerance)
215{
216 for (unsigned int i{ 0 }; i < sphere_list.size(); ++i)
217 {
218 Eigen::Vector3d p = sphere_centers[i];
219 Eigen::Vector3d grad;
220 bool in_bounds = true;
221 double dist = distance_field->getDistanceGradient(p.x(), p.y(), p.z(), grad.x(), grad.y(), grad.z(), in_bounds);
222
223 if (!in_bounds && grad.norm() > 0)
224 {
225 RCLCPP_DEBUG(getLogger(), "Collision sphere point is out of bounds");
226 return true;
227 }
228
229 if ((maximum_value > dist) && (sphere_list[i].radius_ - dist > tolerance))
230 {
231 return true;
232 }
233 }
234
235 return false;
236}
237
239 const std::vector<CollisionSphere>& sphere_list,
240 const EigenSTL::vector_Vector3d& sphere_centers, double maximum_value,
241 double tolerance, unsigned int num_coll, std::vector<unsigned int>& colls)
242{
243 colls.clear();
244 for (unsigned int i = 0; i < sphere_list.size(); ++i)
245 {
246 Eigen::Vector3d p = sphere_centers[i];
247 Eigen::Vector3d grad;
248 bool in_bounds{ true };
249 double dist = distance_field->getDistanceGradient(p.x(), p.y(), p.z(), grad.x(), grad.y(), grad.z(), in_bounds);
250 if (!in_bounds && (grad.norm() > 0))
251 {
252 RCLCPP_DEBUG(getLogger(), "Collision sphere point is out of bounds");
253 return true;
254 }
255 if (maximum_value > dist && (sphere_list[i].radius_ - dist > tolerance))
256 {
257 if (num_coll == 0)
258 {
259 return true;
260 }
261
262 colls.push_back(i);
263 if (colls.size() >= num_coll)
264 {
265 return true;
266 }
267 }
268 }
269
270 return !colls.empty();
271}
272
276
277BodyDecomposition::BodyDecomposition(const shapes::ShapeConstPtr& shape, double resolution, double padding)
278{
279 std::vector<shapes::ShapeConstPtr> shapes;
280 EigenSTL::vector_Isometry3d poses(1, Eigen::Isometry3d::Identity());
281
282 shapes.push_back(shape);
283 init(shapes, poses, resolution, padding);
284}
285
286BodyDecomposition::BodyDecomposition(const std::vector<shapes::ShapeConstPtr>& shapes,
287 const EigenSTL::vector_Isometry3d& poses, double resolution, double padding)
288{
289 init(shapes, poses, resolution, padding);
290}
291
292void BodyDecomposition::init(const std::vector<shapes::ShapeConstPtr>& shapes, const EigenSTL::vector_Isometry3d& poses,
293 double resolution, double padding)
294{
295 bodies_.clear();
296 for (unsigned int i{ 0 }; i < shapes.size(); ++i)
297 {
298 bodies_.addBody(shapes[i].get(), poses[i], padding);
299 }
300
301 // collecting collision spheres
302 collision_spheres_.clear();
304 std::vector<CollisionSphere> body_spheres;
305 EigenSTL::vector_Vector3d body_collision_points;
306 for (unsigned int i{ 0 }; i < bodies_.getCount(); ++i)
307 {
308 body_spheres.clear();
309 body_collision_points.clear();
310
312 collision_spheres_.insert(collision_spheres_.end(), body_spheres.begin(), body_spheres.end());
313
314 distance_field::findInternalPointsConvex(*bodies_.getBody(i), resolution, body_collision_points);
315 relative_collision_points_.insert(relative_collision_points_.end(), body_collision_points.begin(),
316 body_collision_points.end());
317 }
318
319 sphere_radii_.resize(collision_spheres_.size());
320 for (unsigned int i{ 0 }; i < collision_spheres_.size(); ++i)
321 {
322 sphere_radii_[i] = collision_spheres_[i].radius_;
323 }
324
325 // computing bounding sphere
326 std::vector<bodies::BoundingSphere> bounding_spheres(bodies_.getCount());
327 for (unsigned int i{ 0 }; i < bodies_.getCount(); ++i)
328 {
329 bodies_.getBody(i)->computeBoundingSphere(bounding_spheres[i]);
330 }
331 bodies::mergeBoundingSpheres(bounding_spheres, relative_bounding_sphere_);
332
333 RCLCPP_DEBUG(getLogger(), "BodyDecomposition generated %zu collision spheres out of %zu shapes",
334 collision_spheres_.size(), shapes.size());
335}
336
341
342PosedBodyPointDecomposition::PosedBodyPointDecomposition(const BodyDecompositionConstPtr& body_decomposition)
343 : body_decomposition_(body_decomposition)
344{
345 posed_collision_points_ = body_decomposition_->getCollisionPoints();
346}
347
348PosedBodyPointDecomposition::PosedBodyPointDecomposition(const BodyDecompositionConstPtr& body_decomposition,
349 const Eigen::Isometry3d& trans)
350 : body_decomposition_(body_decomposition)
351{
352 updatePose(trans);
353}
354
355PosedBodyPointDecomposition::PosedBodyPointDecomposition(const std::shared_ptr<const octomap::OcTree>& octree)
356 : body_decomposition_()
357{
358 int num_nodes = octree->getNumLeafNodes();
359 posed_collision_points_.reserve(num_nodes);
360 for (octomap::OcTree::tree_iterator tree_iter = octree->begin_tree(); tree_iter != octree->end_tree(); ++tree_iter)
361 {
362 Eigen::Vector3d p = Eigen::Vector3d(tree_iter.getX(), tree_iter.getY(), tree_iter.getZ());
363 posed_collision_points_.push_back(p);
364 }
365}
366
367void PosedBodyPointDecomposition::updatePose(const Eigen::Isometry3d& trans)
368{
370 {
371 posed_collision_points_.resize(body_decomposition_->getCollisionPoints().size());
372
373 for (unsigned int i{ 0 }; i < body_decomposition_->getCollisionPoints().size(); ++i)
374 {
375 posed_collision_points_[i] = trans * body_decomposition_->getCollisionPoints()[i];
376 }
377 }
378}
379
380PosedBodySphereDecomposition::PosedBodySphereDecomposition(const BodyDecompositionConstPtr& body_decomposition)
381 : body_decomposition_(body_decomposition)
382{
383 posed_bounding_sphere_center_ = body_decomposition_->getRelativeBoundingSphere().center;
384 sphere_centers_.resize(body_decomposition_->getCollisionSpheres().size());
385 updatePose(Eigen::Isometry3d::Identity());
386}
387
388void PosedBodySphereDecomposition::updatePose(const Eigen::Isometry3d& trans)
389{
390 // updating sphere centers
391 posed_bounding_sphere_center_ = trans * body_decomposition_->getRelativeBoundingSphere().center;
392 for (unsigned int i{ 0 }; i < body_decomposition_->getCollisionSpheres().size(); ++i)
393 {
394 sphere_centers_[i] = trans * body_decomposition_->getCollisionSpheres()[i].relative_vec_;
395 }
396
397 // updating collision points
398 if (!body_decomposition_->getCollisionPoints().empty())
399 {
400 posed_collision_points_.resize(body_decomposition_->getCollisionPoints().size());
401 for (unsigned int i{ 0 }; i < body_decomposition_->getCollisionPoints().size(); ++i)
402 {
403 posed_collision_points_[i] = trans * body_decomposition_->getCollisionPoints()[i];
404 }
405 }
406}
407
408bool doBoundingSpheresIntersect(const PosedBodySphereDecompositionConstPtr& p1,
409 const PosedBodySphereDecompositionConstPtr& p2)
410{
411 Eigen::Vector3d p1_sphere_center = p1->getBoundingSphereCenter();
412 Eigen::Vector3d p2_sphere_center = p2->getBoundingSphereCenter();
413 double p1_radius{ p1->getBoundingSphereRadius() };
414 double p2_radius{ p2->getBoundingSphereRadius() };
415
416 double dist{ (p1_sphere_center - p2_sphere_center).squaredNorm() };
417 return dist < (p1_radius + p2_radius);
418}
419
420void getCollisionSphereMarkers(const std_msgs::msg::ColorRGBA& color, const std::string& frame_id,
421 const std::string& ns, const rclcpp::Duration& dur,
422 const std::vector<PosedBodySphereDecompositionPtr>& posed_decompositions,
423 visualization_msgs::msg::MarkerArray& arr)
424{
425 unsigned int count{ 0 };
426 rclcpp::Clock ros_clock;
427 for (const auto& posed_decomposition : posed_decompositions)
428 {
429 if (posed_decomposition)
430 {
431 for (unsigned int j{ 0 }; j < posed_decomposition->getCollisionSpheres().size(); ++j)
432 {
433 visualization_msgs::msg::Marker sphere;
434 sphere.type = visualization_msgs::msg::Marker::SPHERE;
435 sphere.header.stamp = ros_clock.now();
436 sphere.header.frame_id = frame_id;
437 sphere.ns = ns;
438 sphere.id = count++;
439 sphere.lifetime = dur;
440 sphere.color = color;
441 sphere.scale.x = sphere.scale.y = sphere.scale.z = posed_decomposition->getCollisionSpheres()[j].radius_ * 2.0;
442 sphere.pose.position.x = posed_decomposition->getSphereCenters()[j].x();
443 sphere.pose.position.y = posed_decomposition->getSphereCenters()[j].y();
444 sphere.pose.position.z = posed_decomposition->getSphereCenters()[j].z();
445 arr.markers.push_back(sphere);
446 }
447 }
448 }
449}
450
451void getProximityGradientMarkers(const std::string& frame_id, const std::string& ns, const rclcpp::Duration& /*dur*/,
452 const std::vector<PosedBodySphereDecompositionPtr>& posed_decompositions,
453 const std::vector<PosedBodySphereDecompositionVectorPtr>& posed_vector_decompositions,
454 const std::vector<GradientInfo>& gradients, visualization_msgs::msg::MarkerArray& arr)
455{
456 rclcpp::Clock ros_clock;
457 if (gradients.size() != posed_decompositions.size() + posed_vector_decompositions.size())
458 {
459 RCLCPP_WARN(getLogger(), "Size mismatch between gradients %u and decompositions %u",
460 static_cast<unsigned int>(gradients.size()),
461 static_cast<unsigned int>((posed_decompositions.size() + posed_vector_decompositions.size())));
462 return;
463 }
464 for (unsigned int i{ 0 }; i < gradients.size(); ++i)
465 {
466 for (unsigned int j{ 0 }; j < gradients[i].distances.size(); ++j)
467 {
468 visualization_msgs::msg::Marker arrow_mark;
469 arrow_mark.header.frame_id = frame_id;
470 arrow_mark.header.stamp = rclcpp::Clock(RCL_ROS_TIME).now();
471 if (ns.empty())
472 {
473 arrow_mark.ns = "self_coll_gradients";
474 }
475 else
476 {
477 arrow_mark.ns = ns;
478 }
479 arrow_mark.id = i * 1000 + j;
480 double xscale{ 0.0 };
481 double yscale{ 0.0 };
482 double zscale{ 0.0 };
483 if (gradients[i].distances[j] > 0.0 && gradients[i].distances[j] != DBL_MAX)
484 {
485 if (gradients[i].gradients[j].norm() > 0.0)
486 {
487 xscale = gradients[i].gradients[j].x() / gradients[i].gradients[j].norm();
488 yscale = gradients[i].gradients[j].y() / gradients[i].gradients[j].norm();
489 zscale = gradients[i].gradients[j].z() / gradients[i].gradients[j].norm();
490 }
491 else
492 {
493 RCLCPP_DEBUG(getLogger(), "Negative length for %u %d %lf", i, arrow_mark.id, gradients[i].gradients[j].norm());
494 }
495 }
496 else
497 {
498 RCLCPP_DEBUG(getLogger(), "Negative dist %lf for %u %d", gradients[i].distances[j], i, arrow_mark.id);
499 }
500 arrow_mark.points.resize(2);
501 if (i < posed_decompositions.size())
502 {
503 arrow_mark.points[1].x = posed_decompositions[i]->getSphereCenters()[j].x();
504 arrow_mark.points[1].y = posed_decompositions[i]->getSphereCenters()[j].y();
505 arrow_mark.points[1].z = posed_decompositions[i]->getSphereCenters()[j].z();
506 }
507 else
508 {
509 arrow_mark.points[1].x =
510 posed_vector_decompositions[i - posed_decompositions.size()]->getSphereCenters()[j].x();
511 arrow_mark.points[1].y =
512 posed_vector_decompositions[i - posed_decompositions.size()]->getSphereCenters()[j].y();
513 arrow_mark.points[1].z =
514 posed_vector_decompositions[i - posed_decompositions.size()]->getSphereCenters()[j].z();
515 }
516 arrow_mark.points[0] = arrow_mark.points[1];
517 arrow_mark.points[0].x -= xscale * gradients[i].distances[j];
518 arrow_mark.points[0].y -= yscale * gradients[i].distances[j];
519 arrow_mark.points[0].z -= zscale * gradients[i].distances[j];
520 arrow_mark.scale.x = 0.01;
521 arrow_mark.scale.y = 0.03;
522 arrow_mark.color.a = 1.0;
523 if (gradients[i].types[j] == SELF)
524 {
525 arrow_mark.color.r = 1.0;
526 arrow_mark.color.g = 0.2;
527 arrow_mark.color.b = .5;
528 }
529 else if (gradients[i].types[j] == INTRA)
530 {
531 arrow_mark.color.r = .2;
532 arrow_mark.color.g = 1.0;
533 arrow_mark.color.b = .5;
534 }
535 else if (gradients[i].types[j] == ENVIRONMENT)
536 {
537 arrow_mark.color.r = .2;
538 arrow_mark.color.g = .5;
539 arrow_mark.color.b = 1.0;
540 }
541 else if (gradients[i].types[j] == NONE)
542 {
543 arrow_mark.color.r = 1.0;
544 arrow_mark.color.g = .2;
545 arrow_mark.color.b = 1.0;
546 }
547 arr.markers.push_back(arrow_mark);
548 }
549 }
550}
551
552void getCollisionMarkers(const std::string& frame_id, const std::string& ns, const rclcpp::Duration& /*dur*/,
553 const std::vector<PosedBodySphereDecompositionPtr>& posed_decompositions,
554 const std::vector<PosedBodySphereDecompositionVectorPtr>& posed_vector_decompositions,
555 const std::vector<GradientInfo>& gradients, visualization_msgs::msg::MarkerArray& arr)
556{
557 rclcpp::Clock ros_clock;
558 if (gradients.size() != posed_decompositions.size() + posed_vector_decompositions.size())
559 {
560 RCLCPP_WARN(getLogger(), "Size mismatch between gradients %zu and decompositions %zu", gradients.size(),
561 posed_decompositions.size() + posed_vector_decompositions.size());
562 return;
563 }
564 for (unsigned int i{ 0 }; i < gradients.size(); ++i)
565 {
566 for (unsigned int j{ 0 }; j < gradients[i].types.size(); ++j)
567 {
568 visualization_msgs::msg::Marker sphere_mark;
569 sphere_mark.type = visualization_msgs::msg::Marker::SPHERE;
570 sphere_mark.header.frame_id = frame_id;
571 sphere_mark.header.stamp = rclcpp::Clock(RCL_ROS_TIME).now();
572 if (ns.empty())
573 {
574 sphere_mark.ns = "distance_collisions";
575 }
576 else
577 {
578 sphere_mark.ns = ns;
579 }
580 sphere_mark.id = i * 1000 + j;
581 if (i < posed_decompositions.size())
582 {
583 sphere_mark.scale.x = sphere_mark.scale.y = sphere_mark.scale.z =
584 posed_decompositions[i]->getCollisionSpheres()[j].radius_ * 2.0;
585 sphere_mark.pose.position.x = posed_decompositions[i]->getSphereCenters()[j].x();
586 sphere_mark.pose.position.y = posed_decompositions[i]->getSphereCenters()[j].y();
587 sphere_mark.pose.position.z = posed_decompositions[i]->getSphereCenters()[j].z();
588 }
589 else
590 {
591 sphere_mark.scale.x = sphere_mark.scale.y = sphere_mark.scale.z =
592 posed_vector_decompositions[i - posed_decompositions.size()]->getCollisionSpheres()[j].radius_ * 2.0;
593 sphere_mark.pose.position.x =
594 posed_vector_decompositions[i - posed_decompositions.size()]->getSphereCenters()[j].x();
595 sphere_mark.pose.position.y =
596 posed_vector_decompositions[i - posed_decompositions.size()]->getSphereCenters()[j].y();
597 sphere_mark.pose.position.z =
598 posed_vector_decompositions[i - posed_decompositions.size()]->getSphereCenters()[j].z();
599 }
600 sphere_mark.pose.orientation.w = 1.0;
601 sphere_mark.color.a = 1.0;
602 if (gradients[i].types[j] == SELF)
603 {
604 sphere_mark.color.r = 1.0;
605 sphere_mark.color.g = 0.2;
606 sphere_mark.color.b = .5;
607 }
608 else if (gradients[i].types[j] == INTRA)
609 {
610 sphere_mark.color.r = .2;
611 sphere_mark.color.g = 1.0;
612 sphere_mark.color.b = .5;
613 }
614 else if (gradients[i].types[j] == ENVIRONMENT)
615 {
616 sphere_mark.color.r = .2;
617 sphere_mark.color.g = .5;
618 sphere_mark.color.b = 1.0;
619 }
620 else
621 {
622 sphere_mark.color.r = 1.0;
623 sphere_mark.color.g = .2;
624 sphere_mark.color.b = 1.0;
625 }
626 arr.markers.push_back(sphere_mark);
627 }
628 }
629}
630} // namespace collision_detection
EIGEN_MAKE_ALIGNED_OPERATOR_NEW BodyDecomposition(const shapes::ShapeConstPtr &shape, double resolution, double padding=0.01)
void init(const std::vector< shapes::ShapeConstPtr > &shapes, const EigenSTL::vector_Isometry3d &poses, double resolution, double padding)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PosedBodyPointDecomposition(const BodyDecompositionConstPtr &body_decomposition)
void updatePose(const Eigen::Isometry3d &linkTransform)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PosedBodySphereDecomposition(const BodyDecompositionConstPtr &body_decomposition)
void updatePose(const Eigen::Isometry3d &linkTransform)
double getDistanceGradient(double x, double y, double z, double &gradient_x, double &gradient_y, double &gradient_z, bool &in_bounds) const
Gets not only the distance to the nearest cell but the gradient direction. The point defined by the x...
bool getCollisionSphereGradients(const std::vector< CollisionSphere > &sphere_list, const EigenSTL::vector_Vector3d &sphere_centers, GradientInfo &gradient, const CollisionType &type, double tolerance, bool subtract_radii, double maximum_value, bool stop_at_first_collision)
DistanceField is an abstract base class for computing distances from sets of 3D obstacle points....
void getProximityGradientMarkers(const std::string &frame_id, const std::string &ns, const rclcpp::Duration &dur, const std::vector< PosedBodySphereDecompositionPtr > &posed_decompositions, const std::vector< PosedBodySphereDecompositionVectorPtr > &posed_vector_decompositions, const std::vector< GradientInfo > &gradients, visualization_msgs::msg::MarkerArray &arr)
std::vector< CollisionSphere > determineCollisionSpheres(const bodies::Body *body, Eigen::Isometry3d &relativeTransform)
void getCollisionMarkers(const std::string &frame_id, const std::string &ns, const rclcpp::Duration &dur, const std::vector< PosedBodySphereDecompositionPtr > &posed_decompositions, const std::vector< PosedBodySphereDecompositionVectorPtr > &posed_vector_decompositions, const std::vector< GradientInfo > &gradients, visualization_msgs::msg::MarkerArray &arr)
void getCollisionSphereMarkers(const std_msgs::msg::ColorRGBA &color, const std::string &frame_id, const std::string &ns, const rclcpp::Duration &dur, const std::vector< PosedBodySphereDecompositionPtr > &posed_decompositions, visualization_msgs::msg::MarkerArray &arr)
bool getCollisionSphereCollision(const distance_field::DistanceField *distance_field, const std::vector< CollisionSphere > &sphere_list, const EigenSTL::vector_Vector3d &sphere_centers, double maximum_value, double tolerance)
bool doBoundingSpheresIntersect(const PosedBodySphereDecompositionConstPtr &p1, const PosedBodySphereDecompositionConstPtr &p2)
bool getCollisionSphereGradients(const distance_field::DistanceField *distance_field, const std::vector< CollisionSphere > &sphere_list, const EigenSTL::vector_Vector3d &sphere_centers, GradientInfo &gradient, const CollisionType &type, double tolerance, bool subtract_radii, double maximum_value, bool stop_at_first_collision)
Namespace for holding classes that generate distance fields.
void findInternalPointsConvex(const bodies::Body &body, double resolution, EigenSTL::vector_Vector3d &points)
Find all points on a regular grid that are internal to the body, assuming the body is a convex shape....
rclcpp::Logger getLogger(const std::string &name)
Creates a namespaced logger.
Definition logger.cpp:79
Definition world.h:49
EIGEN_MAKE_ALIGNED_OPERATOR_NEW double closest_distance