45 #include <geometric_shapes/shapes.h>
46 #include <geometric_shapes/bodies.h>
47 #include <octomap/OcTree.h>
52 #include <visualization_msgs/msg/marker_array.hpp>
53 #include <rclcpp/duration.hpp>
54 #include <rclcpp/logging.hpp>
55 #include <rclcpp/clock.hpp>
56 #include <rclcpp/rclcpp.hpp>
57 #include <rclcpp/time.hpp>
58 #include <rclcpp/utilities.hpp>
96 std::vector<CollisionType>
types;
126 bool propagate_negative_distances =
false)
128 origin.
z(), max_distance, propagate_negative_distances)
129 ,
pose_(Eigen::Isometry3d::Identity())
163 bool& in_bounds)
const
169 gx, gy, gz, in_bounds);
171 gradient_x = grad.x();
172 gradient_y = grad.y();
173 gradient_z = grad.z();
193 const EigenSTL::vector_Vector3d& sphere_centers,
GradientInfo& gradient,
195 double maximum_value,
bool stop_at_first_collision);
209 const std::vector<CollisionSphere>& sphere_list,
210 const EigenSTL::vector_Vector3d& sphere_centers,
GradientInfo& gradient,
211 const CollisionType&
type,
double tolerance,
bool subtract_radii,
double maximum_value,
212 bool stop_at_first_collision);
215 const std::vector<CollisionSphere>& sphere_list,
216 const EigenSTL::vector_Vector3d& sphere_centers,
double maximum_value,
220 const std::vector<CollisionSphere>& sphere_list,
221 const EigenSTL::vector_Vector3d& sphere_centers,
double maximum_value,
222 double tolerance,
unsigned int num_coll, std::vector<unsigned int>& colls);
225 class BodyDecompositionVector;
234 BodyDecomposition(
const shapes::ShapeConstPtr& shape,
double resolution,
double padding = 0.01);
237 double resolution,
double padding);
244 const Eigen::Isometry3d& new_relative_cylinder_pose)
267 const bodies::Body*
getBody(
unsigned int i)
const
288 void init(
const std::vector<shapes::ShapeConstPtr>&
shapes,
const EigenSTL::vector_Isometry3d& poses,
289 double resolution,
double padding);
338 void updatePose(
const Eigen::Isometry3d& linkTransform);
363 void updatePose(
const Eigen::Isometry3d& linkTransform);
381 return collision_spheres_;
386 return posed_collision_spheres_;
391 return sphere_radii_;
396 sphere_index_map_[decomp_vector_.size()] = collision_spheres_.size();
397 decomp_vector_.push_back(bd);
398 collision_spheres_.insert(collision_spheres_.end(), bd->getCollisionSpheres().begin(),
399 bd->getCollisionSpheres().end());
400 posed_collision_spheres_.insert(posed_collision_spheres_.end(), bd->getSphereCenters().begin(),
401 bd->getSphereCenters().end());
402 sphere_radii_.insert(sphere_radii_.end(), bd->getSphereRadii().begin(), bd->getSphereRadii().end());
407 return decomp_vector_.size();
412 if (i >= decomp_vector_.size())
414 RCLCPP_INFO(LOGGER,
"No body decomposition");
417 return decomp_vector_[i];
420 void updatePose(
unsigned int ind,
const Eigen::Isometry3d& pose)
422 if (ind >= decomp_vector_.size())
424 RCLCPP_WARN(LOGGER,
"Can't update pose");
427 decomp_vector_[ind]->updatePose(pose);
428 for (
unsigned int i = 0; i < decomp_vector_[ind]->getSphereCenters().size(); ++i)
430 posed_collision_spheres_[sphere_index_map_[ind] + i] = decomp_vector_[ind]->getSphereCenters()[i];
435 static const rclcpp::Logger LOGGER;
436 PosedBodySphereDecompositionConstPtr empty_ptr_;
437 std::vector<PosedBodySphereDecompositionPtr> decomp_vector_;
438 std::vector<CollisionSphere> collision_spheres_;
439 EigenSTL::vector_Vector3d posed_collision_spheres_;
440 std::vector<double> sphere_radii_;
441 std::map<unsigned int, unsigned int> sphere_index_map_;
455 EigenSTL::vector_Vector3d ret_points;
456 for (
const PosedBodyPointDecompositionPtr& decomp : decomp_vector_)
458 ret_points.insert(ret_points.end(), decomp->getCollisionPoints().begin(), decomp->getCollisionPoints().end());
465 decomp_vector_.push_back(bd);
470 return decomp_vector_.size();
475 if (i >= decomp_vector_.size())
477 RCLCPP_INFO(
LOGGER,
"No body decomposition");
480 return decomp_vector_[i];
483 void updatePose(
unsigned int ind,
const Eigen::Isometry3d& pose)
485 if (ind < decomp_vector_.size())
487 decomp_vector_[ind]->updatePose(pose);
491 RCLCPP_WARN(
LOGGER,
"Can't update pose");
500 PosedBodyPointDecompositionPtr empty_ptr_;
501 std::vector<PosedBodyPointDecompositionPtr> decomp_vector_;
518 const PosedBodySphereDecompositionConstPtr& p2);
521 const std::string& ns,
const rclcpp::Duration& dur,
522 const std::vector<PosedBodySphereDecompositionPtr>& posed_decompositions,
523 visualization_msgs::msg::MarkerArray& arr);
526 const std::vector<PosedBodySphereDecompositionPtr>& posed_decompositions,
527 const std::vector<PosedBodySphereDecompositionVectorPtr>& posed_vector_decompositions,
528 const std::vector<GradientInfo>& gradients, visualization_msgs::msg::MarkerArray& arr);
531 const std::vector<PosedBodySphereDecompositionPtr>& posed_decompositions,
532 const std::vector<PosedBodySphereDecompositionVectorPtr>& posed_vector_decompositions,
533 const std::vector<GradientInfo>& gradients, visualization_msgs::msg::MarkerArray& arr);
ROS/KDL based interface for the inverse kinematics of the PR2 arm.
const std::vector< double > & getSphereRadii() const
std::vector< CollisionSphere > collision_spheres_
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)
const EigenSTL::vector_Vector3d & getCollisionPoints() const
bodies::BoundingSphere relative_bounding_sphere_
friend class BodyDecompositionVector
const bodies::Body * getBody(unsigned int i) const
const std::vector< CollisionSphere > & getCollisionSpheres() const
Eigen::Isometry3d relative_cylinder_pose_
EigenSTL::vector_Vector3d relative_collision_points_
unsigned int getBodiesCount()
Eigen::Isometry3d getRelativeCylinderPose() const
bodies::BodyVector bodies_
void replaceCollisionSpheres(const std::vector< CollisionSphere > &new_collision_spheres, const Eigen::Isometry3d &new_relative_cylinder_pose)
std::vector< double > sphere_radii_
const bodies::BoundingSphere & getRelativeBoundingSphere() const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PosedBodyPointDecompositionVector()
void addToVector(PosedBodyPointDecompositionPtr &bd)
static const rclcpp::Logger LOGGER
PosedBodyPointDecompositionConstPtr getPosedBodyDecomposition(unsigned int i) const
unsigned int getSize() const
void updatePose(unsigned int ind, const Eigen::Isometry3d &pose)
EigenSTL::vector_Vector3d getCollisionPoints() const
const EigenSTL::vector_Vector3d & getCollisionPoints() const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PosedBodyPointDecomposition(const BodyDecompositionConstPtr &body_decomposition)
void updatePose(const Eigen::Isometry3d &linkTransform)
EigenSTL::vector_Vector3d posed_collision_points_
BodyDecompositionConstPtr body_decomposition_
const std::vector< double > & getSphereRadii() const
void addToVector(PosedBodySphereDecompositionPtr &bd)
const std::vector< CollisionSphere > & getCollisionSpheres() const
unsigned int getSize() const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PosedBodySphereDecompositionVector()
const EigenSTL::vector_Vector3d & getSphereCenters() const
void updatePose(unsigned int ind, const Eigen::Isometry3d &pose)
PosedBodySphereDecompositionConstPtr getPosedBodySphereDecomposition(unsigned int i) const
const std::vector< CollisionSphere > & getCollisionSpheres() const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PosedBodySphereDecomposition(const BodyDecompositionConstPtr &body_decomposition)
const std::vector< double > & getSphereRadii() const
Eigen::Vector3d posed_bounding_sphere_center_
const EigenSTL::vector_Vector3d & getCollisionPoints() const
EigenSTL::vector_Vector3d posed_collision_points_
BodyDecompositionConstPtr body_decomposition_
void updatePose(const Eigen::Isometry3d &linkTransform)
const Eigen::Vector3d & getBoundingSphereCenter() const
const EigenSTL::vector_Vector3d & getSphereCenters() const
EigenSTL::vector_Vector3d sphere_centers_
double getBoundingSphereRadius() const
const Eigen::Isometry3d & getPose() const
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...
void updatePose(const Eigen::Isometry3d &transform)
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)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PosedDistanceField(const Eigen::Vector3d &size, const Eigen::Vector3d &origin, double resolution, double max_distance, bool propagate_negative_distances=false)
DistanceField is an abstract base class for computing distances from sets of 3D obstacle points....
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 gradient is computed a...
A DistanceField implementation that uses a vector propagation method. Distances propagate outward fro...
PropagationDistanceField(double size_x, double size_y, double size_z, double resolution, double origin_x, double origin_y, double origin_z, double max_distance, bool propagate_negative_distances=false)
Constructor that initializes entire distance field to empty - all cells will be assigned maximum dist...
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)
MOVEIT_CLASS_FORWARD(AllowedCollisionMatrix)
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.
Vec3fX< details::Vec3Data< double > > Vector3d
CollisionSphere(const Eigen::Vector3d &rel, double radius)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d relative_vec_
EIGEN_MAKE_ALIGNED_OPERATOR_NEW double closest_distance
EigenSTL::vector_Vector3d gradients
std::vector< double > distances
std::vector< double > sphere_radii
EigenSTL::vector_Vector3d sphere_locations
std::vector< CollisionType > types
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::string link_name
Eigen::Vector3d closest_gradient
std::string attached_object_name
unsigned int sphere_index
Eigen::Vector3d closest_point